-
Notifications
You must be signed in to change notification settings - Fork 729
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
Opaque types don't include !Send
, !Sync
, !Pin
#2685
Comments
Hello. I was asked to look at this issue but I don't have any wider context of your specific project. That said, I'd advise the following: /// S-expression data that is opaque to Rust
#[repr(transparent)]
pub struct SEXPREC(c_void);
// if you want this alias too
pub type s_object = SEXPREC; I'm genuinely not sure why the Nomicon is concerned with the value itself being Send/Sync or not because pointers to it will naturally be !Send and !Sync. The |
Thanks! My use case requires So /// S-expression data that is opaque to Rust
#[repr(transparent)]
pub struct SEXPREC(c_void);
// if you want this alias too
pub type SEXP = *mut SEXPREC; Is it possible to make bindgen produce this pattern? |
I haven't used bindgen in years, I just make bindings by hand generally. You would probably have to file an issue to make them support this. |
I agree that the current codegen for opaque types is unnecessarily dangerous and should be changed to follow the current nomicon guidelines. |
We have a pointer type to an opaque type in our FFI project.
Bindgen generates this definition for the opaque type:
But then I was reading https://stackoverflow.com/questions/38315383/whats-the-rust-idiom-to-define-a-field-pointing-to-a-c-opaque-pointer, and https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs,
which says that the definition of the above should really be:
Is this something I should replace the bindgen-version with this?
Lastly, I merely have these in the C-headers:
with no definition of
s_object
, and I'm quite certain this is intended behavior.The text was updated successfully, but these errors were encountered: