[][src]Macro libffi::ffi_call

macro_rules! ffi_call {
    { ( $fun:expr ) ( $( $arg:expr ),* ) -> $ty:ty } => { ... };
    { $fun:ident ( $( $arg:expr ),* ) -> $ty:ty } => { ... };
    { ( $fun:expr ) ( $( $arg:expr ),* ) } => { ... };
    { $fun:ident ( $( $arg:expr ),* ) } => { ... };
}

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 libffi::ffi_call;

let result = unsafe { ffi_call!{ hypot(3f32, 4f32) -> f32 } };

assert!((result - 5f32).abs() < 0.0001);