dtolnay/cxx

Support passing function pointers across the FFI

Open

#52 opened on Mar 2, 2020

View on GitHub
 (6 comments) (9 reactions) (0 assignees)Rust (4,472 stars) (253 forks)batch import
help wanted

Description

i.e. function parameters with the type fn(...) -> ....

#[cxx::bridge]
mod ffi {
    extern "Rust" {
        fn f(arg: u8, callback: fn(u8));
    }
}

fn f(arg: u8, callback: fn(u8)) {
    callback(256 - arg);
}

Contributor guide