-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Description
Summary
csbindgen connot generate C# Native method declarations from Rust 2024 edition sources
because some attributes (such as no_mangle
and export_name
) must now be marked as unsafe
using new introduced attribute unsafe
but csbindgen cannot recognize it.
Workaround
Use 2021 edition and no_mangle
and export_name
without unsafe
attribute.
Details
From Rust 1.82, some attributes has ability in all editions to mark as unsafe like this:
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hoge_init() {}
#[allow(non_snake_case)]
#[unsafe(export_name = "hoge_deinit")]
pub unsafe extern "C" fn Destroy() {}
Last February 21, Rust 1.85 stable has been released with 2024 edition!
But in 2024 edition, these attributes must be marked as unsafe.
csbindgen cannot recognize unsafe
attribute, so generated codes contains no DllImport
ed native methods.
Reproduce
- Extract the attached tarball.
- Run
cargo build
. - Open
./target/csbindgen/NativeMethods.g.cs
but It contains no DllImported methods.
arontsang, jkelin, andriipopazov and Odonno
Metadata
Metadata
Assignees
Labels
No labels