Macro dlib::ffi_dispatch
source · macro_rules! ffi_dispatch { (feature=$feature: expr, $handle: expr, $func: ident, $($arg: expr),*) => { ... }; ($handle: expr, $func: ident, $($arg: expr),*) => { ... }; }
Expand description
Macro for generically invoking a FFI function
The expected arguments are, in order:
- (Optional) The name of the cargo feature conditioning the usage of dlopen, in the form
feature="feature-name"
. If ommited, the feature"dlopen"
will be used. - A value of the handle generated by the macro
external_library!
when the dlopen-controlling feature is enabled - The name of the function to invoke
- The arguments to be passed to the function
The macro invocation evaluates to the return value of the FFI function.
§Example
Assuming an FFI function of signature fn(u32, u32) -> u32
:
ⓘ
let sum = unsafe { ffi_dispatch!(feature="dlopen", LIBRARY_HANDLE, sum, 2, 2) };