1
Make *const (), *mut () okay for FFI by dtolnay · Pull Request #84267 · rust-lan...
source link: https://github.com/rust-lang/rust/pull/84267
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples:
I believe it's useful for the same purpose in FFI signatures, even while ()
itself is not FFI safe. The following should be allowed:
extern "C" { fn demo(pc: *const (), pm: *mut ()); }
Prior to this PR, those pointers were not considered okay for an extern signature.
warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:17 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^^^ not FFI-safe | = note: `#[warn(improper_ctypes)]` on by default = help: consider using a struct instead = note: tuples have unspecified layout warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:32 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^ not FFI-safe | = help: consider using a struct instead = note: tuples have unspecified layout
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK