Macro deno_libffi::ffi_call [−][src]
macro_rules! ffi_call { { ($fun : expr) ($($arg : expr), *) -> $ty : ty } => { ... }; { $fun : ident($($arg : expr), *) -> $ty : ty } => { ... }; { ($fun : expr) ($($arg : expr), *) } => { ... }; { $fun : ident($($arg : expr), *) } => { ... }; }
Expand description
Performs a dynamic call to a C function.
This macro provides sugar for call::arg
and call::call
. For more
control, see high::call::call
.
Examples
extern "C" fn hypot(x: f32, y: f32) -> f32 { (x * x + y * y).sqrt() } use deno_libffi::ffi_call; let result = unsafe { ffi_call!{ hypot(3f32, 4f32) -> f32 } }; assert!((result - 5f32).abs() < 0.0001);