I have a project. Some code needs to run fast, other code I would prefer to be able to build it quickly. So I'm experimenting with splitting off the performance-sensitive code into dylibs and compiling it in release mode, then compiling the main project in debug mode and loading the functions.
Anyways, the compiler is complaining that my types, which the extern fn
s take, are not #[repr(C)]
. However, I'm not using extern "C"
functions, just extern
("Rust") functions, so it seems like it might be fine. On the other hand, if optimizations can change a struct's layout, that could cause issues.
Should I annotate my types with #[repr(C)]
? Or is this dogmatic? And if so, is it valid to wrap external non-#[repr(C)]
with #[repr(C)]
newtypes?
warning: `extern` fn uses type `game::graphics::BlockVertexEditSubmitter`, which is not FFI-safe
--> fastcode\src\lib.rs:26:21
|
26 | edit_submitter: BlockVertexEditSubmitter,
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout