I'm calling a Rust function from C but the pointer address is changed when returned.
#[no_mangle]
pub extern fn plugin_get_config_string(config: *const toml::Value, k: *const c_char) -> *const c_char {
let a = CString::new("dwadwad").unwrap();
let p = a.as_ptr();
println!("{:?}", p);
mem::forget(a);
p
}
__declspec(dllexport) void initialize(void *config) {
char *dwad = plugin_get_config_string(config, "host");
printf("%p\n", dwad);
}
In Rust: 0x220d3ceee30
In C: FFFFFFFFD3CEEE30
The first 3 bytes are always stripped in C.
I'm using Visual Studio 2017 x64 Dev Command Prompt and stable-x86_64-pc-windows-msvc.
Anyone know what the problem might be?