-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate unsafe extern
blocks (Edition 2024)
#2901
Comments
The proposed Or perhaps a C implementation could add something like that to improve interop with Rust for their users... :) |
Just FYI, |
## Description This replaces the declaration of `extern "C"` blocks with `unsafe extern "C"` as will be required by Rust 2024. Remove this when rust-lang/rust-bindgen#2901 is merged and [bindgen](https://crates.io/crates/bindgen) can generate these blocks automatically as required.
once #3002 is merged, bindgen will have support for editions. However, it seems to me that this should be enabled regardless of the edition for every rust target greater or equal than 1.82 as not using |
Yeah, as far as I can see, the lint is not enabled by default ( |
I know Edition 2024 is very experimental at the moment, so this is more of a heads-up than an actual issue.
Description
Rust has just implemented RFC 3484, requiring all
extern
blocks to be markedunsafe extern
in Edition 2024. Older editions don't yet compile thisunsafe extern
construct (as of the latest stable,rustc-1.80.0
), but they will eventually accept theunsafe
keyword for compatibility reasons. This crate needs some way of generating bindings with this future requirements, either viaBuilder
configuration, or by detecting the current edition.I've implemented a minimal (but complete) example that triggers the error here: bindgen-unsafe-extern.
Input C/C++ Header
Bindgen Invocation
Actual Results
Generated file:
Compiler error:
Expected Results
For Edition 2024, the generated file should be:
The text was updated successfully, but these errors were encountered: