phosphorus
phosphorus copied to clipboard
generated structs should be `#repr(C)` and the `_priv` field should be a `[u8; 0]`
I noticed the structs generated, such as __GLSync, are generated as follows:
#[doc(hidden)]
pub struct __GLsync {
_priv: u8,
}
Although this type is only ever used as a pointer, it disagrees with the FFI chapter of the nomicon: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
The nomicon says such as type should be #[repr(C)] and should have a field of [u8; 0] to ensure it is impossible to instantiate. The PhantomPinned appears to ensure you can't pin the thing either.
Those types are never passed over FFI, just an opaque pointer to them, so it's fine.