More comments and args()[1..]
@@ -123,7 +123,7 @@ fn real_main(
let mut rccjit = rcc::RccJIT::from_module(result?);
rccjit.finalize();
if let Some(main) = rccjit.get_compiled_function("main") {
- let args = std::env::args();
+ let args = std::env::args()[1..];
let argc = args.len() as i32;
let exit_code = {
// we use block there so we can be 100% sure that memory allocated for CString is freed.
@@ -138,7 +138,7 @@ fn real_main(
.as_ptr() as *const *const u8;
let main: unsafe extern "C" fn(i32, *const *const u8) -> i32 =
unsafe { std::mem::transmute(main) }; // this transmute is safe: this function is finalized(`rccjit.finalize()`) and **guaranteed** to be non-null
- unsafe { main(argc, pointer) }
+ unsafe { main(argc, pointer) } // through transmute is safe,invoking this function is unsafe because we invoke C code.
};
std::process::exit(exit_code);
}
