#[ffi_function]
Expand description

Enable an extern "C" function to appear in generated bindings.

This will derive FunctionInfo for a helper struct of the same name containing the function’s name, parameters and return value.

In order to appear in generated bindings the function also has to be mentioned in the inventory function.

Parameters

The following parameters can be provided:

ParameterExplanation
debugPrint generated helper code in console.

Safety

⚠️ You must ensure that methods exported with #[ffi_function] will never panic. We highly encourage you to wrap all your code in panic guards. This is a standard Rust FFI concern and has nothing to do with Interoptopus. Failure to follow this advice will probably lead to undefined behavior down the road. The author has been there and does not recommend it.

Example

use interoptopus::ffi_function;

#[ffi_function]
#[no_mangle]
pub extern "C" fn my_function(x: u32) -> u32 {
    x
}