Skip to content
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

Don't use empty enum for opaque FFI type anymore #44

Open
Boscop opened this issue Dec 6, 2018 · 0 comments
Open

Don't use empty enum for opaque FFI type anymore #44

Boscop opened this issue Dec 6, 2018 · 0 comments

Comments

@Boscop
Copy link
Owner

Boscop commented Dec 6, 2018

We have:

pub enum CWebView {} // opaque type, only used in ffi pointers

Even though the book was recommending to use empty enums for opaque FFI pointer types, it's not recommended anymore because it turned out it's UB:

https://www.reddit.com/r/rust/comments/a3bf2p/patterns_of_refactoring_c_to_rust_the_case_of/eb5xqje/

So it should be

#[repr(C)] pub struct CWebView { _private: [u8; 0] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant