Calling convention of `HostCallbackProc` causes warnings
Boscop opened this issue · 1 comments
Boscop commented
Running cargo test
says:
warning: `extern` fn uses type `fn(*mut AEffect, i32, i32, isize, *mut c_void, f32) -> isize`, which is not FFI-safe
--> src\lib.rs:182:47
|
179 | pub extern "system" fn MAIN(callback: $crate::api::HostCallbackProc) -> *mut $crate::api::AEffect {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
...
325 | plugin_main!(TestPlugin);
| ------------------------- in this macro invocation
|
= note: `#[warn(improper_ctypes_definitions)]` on by default
= help: consider using an `extern fn(...) -> ...` function pointer instead
= note: this function pointer has Rust-specific calling convention
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
(same warning for VSTPluginMain
)
The issue is that HostCallbackProc
is defined without extern
, defaulting to Rust calling convention:
pub type HostCallbackProc =
fn(effect: *mut AEffect, opcode: i32, index: i32, value: isize, ptr: *mut c_void, opt: f32) -> isize;
We have
Lines 165 to 186 in 3f88b99
so the calling conv of
HostCallbackProc
would have to be "system"
for main_macho
and MAIN
, but "C"
for VSTPluginMain
.
We can't make HostCallbackProc
instantiatable for different calling conventions, but what should we do about the warning?
Should we do anything about it, or just #[allow()]
it?