github dtolnay/cxx 0.5.1

latest releases: 1.0.128, 1.0.127, 1.0.126...
3 years ago
  • Enable functions to have a different name between Rust and C++ (#349)
    • Within cxx::bridge, write #[rust_name = "..."] or #[cxx_name = "..."] to make a change to either name of a function
    • In general many functions can have the same C++ name (due to overloading); every function must continue to have a unique Rust name
#[cxx::bridge]
mod ffi {
    extern "C++" {
        include!("path/to/header.h");

        #[cxx_name = "take"]
        fn take_int(i: i32);

        #[cxx_name = "take"] // different overload of the same name in C++
        fn take_str(s: &str);
    }
}

Don't miss a new cxx release

NewReleases is sending notifications on new releases.