Skip to main content

extern_safe

Macro extern_safe 

Source
macro_rules! extern_safe {
    (
        $(
            $(#[$meta:meta])*
            fn $name:ident($($arg:ident: $ty:ty),* $(,)?) -> $ret:ty;
        )*
    ) => { ... };
}
Expand description

This will extern the C function and make it to safe.

ยงExample

use proka_kernel::extern_safe;

// Make sure that the C function was defined and linked currectly.
extern_safe! {
    fn add(a: i32, b: i32) -> i32;
}

// Then use it, with the header "safe_".
let result = safe_add(1, 2);
assert_eq!(result, 3);