What's the correct way to pass struct in FFI?
⚓ Rust 📅 2025-06-26 👤 surdeus 👁️ 18Usually, I pass the FFI struct in extern "system" fn directly.
#[repr(C)]
pub struct Buffer {
data:*mut u8,
len: i32,
}
extern "system" fn some_function(a:Buffer) -> Buffer {
todo!()
}
But since the C ABI Changes for wasm32-unknown-unknown | Rust Blog, now I use it like this.
extern "system" fn some_function(a:&Buffer) ->Buffer {
todo!()
}
It is fine when using it in Windows, but I got a crash when it runs on Android.
So what's the proper way to be compatible on all platforms?
7 posts - 4 participants
🏷️ rust_feed