-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
c_void should not be an enum with public variants #48
Comments
I don't think there's another approach - @tomjakubowski suggested That said, I don't think this is a problem: it isn't memory-unsafe to be able to construct a c_void, so I don't think libc needs to do anything about this. If you go and say (It is more of a problem for libraries which are using the same trick to represent an opaque struct, i.e., what C means by |
See rust-lang/rust#27303 and rust-lang/libc#48 for discussion of the optimization, or just try compiling `unsafe {free(malloc(16))}` with various Rust definitions of `void *` in the FFI binding.
See rust-lang/rust#27303 and rust-lang/libc#48 for discussion of the optimization, or just try compiling `unsafe {free(malloc(16))}` with various Rust definitions of `void *` in the FFI binding.
In my opinion there is no reason to change this. The implementation of If other people feel strongly that a struct is more appropriate, I think it is now possible with rust-lang/rust#43036: #[repr(transparent)]
pub struct c_void(Void);
#[repr(u8)]
enum Void {
Irrelevant,
Likewise,
} |
@dtolnay IIRC this should just be: extern {
type c_void;
} but I might be misunderstanding what |
Anyways any change in this direction should be done together with other breaking changes, so maybe one should label this as "worth experimenting with it for the 0.3 release" (not that a 0.3 release will ever happen until the whole |
|
…rrect Add a test for x86 runtime support
originally filed as rust-lang/rust#20274
The text was updated successfully, but these errors were encountered: