#mangling

macro cxx_linker

A procedural macro for linking Rust functions with C++ using Itanium name mangling

1 unstable release

0.1.0 Aug 29, 2024

#484 in Procedural macros

MIT license

4KB

cxx_linker

A procedural macro for linking Rust functions with C++ using Itanium name mangling.

Example

use cxx_linker::cxx_link;

extern "C" {
    #[cxx_link("blobstore::foo<int>::bar(int, blobstore::SomeType&, bool)")]
    fn bar(a: i32, b: *mut (), c: bool);
}

will be expanded to

extern "C" {
    #[link_name = "_ZN9blobstore3fooIiE3barEiRNS_8SomeTypeEb"]
    fn bar(a: i32, b: *mut (), c: bool);
}

lib.rs:

A procedural macro for linking Rust functions with C++ using Itanium name mangling.

Example

A procedural macro for linking Rust functions with C++ using Itanium name mangling.

Example

use cxx_linker::cxx_link;

extern "C" {
    #[cxx_link("blobstore::foo<int>::bar(int, blobstore::SomeType&, bool)")]
    fn bar(a: i32, b: *mut (), c: bool);
}

will be expanded to

extern "C" {
    #[link_name = "_ZN9blobstore3fooIiE3barEiRNS_8SomeTypeEb"]
    fn bar(a: i32, b: *mut (), c: bool);
}

Dependencies

~2.1–2.8MB
~57K SLoC