You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently for any c structure (the parent struct) that contains an unnamed union struct with a bitfield (the child struct) bindgen will generate a struct with BindgenBitFieldUnit, that generated struct will also have the #[repr(align(#))] trait.
If the parent struct is packed then this gives the "error[E0588]: packed type cannot transitively contain a #[repr(align)] type" during build.
This can normally be avoided if one doesn't need to use this struct my making the struct an opaque blob of bytes by signaling that in "bindgen_parameters".
However, some issues are present. Firstly, when the struct is unnamed this becomes more difficult. The only way I have found to signal that an unnamed struct needs to be an opaque blob is by identifying the unnamed struct's generated name (in rust/bindings_generated.rs) and putting that in "bindgen_parameters", which means one needs to have to build fail, so the bindings get generated, then find the name of the unnamed struct manually and add that to "bindgen_parameters"
Second this means that if one needs to use a stuct that contains such a child struct, the only solution is to manually modify bindings_generated.rs to remove the align trait on the generated child struct. This works in all scenarios I have run into since the align trait is the same size as the generated struct.
This means without manually modifying hv_ring_buffer__bindgen_ty_1__bindgen_ty_1 and removing the align trait, the build will fail. This is tedious due to it requiring running the build once for it to fail after generating the bindings, then manually modifying them, to run the build a second time where it will succeed.
Third, having to add every struct that contains an unnamed child struct with bitfields leads to a lot of structs having to be added to “bindgen_parameters” which in the long term seems unsustainable. I am not sure what the best solution could be, but perhaps splitting bindgen_parameters similar to makefiles, where each directory would have its own bindgen_parameters, that way it doesn’t all get put in one monolithic file.
The text was updated successfully, but these errors were encountered:
Currently for any c structure (the parent struct) that contains an unnamed union struct with a bitfield (the child struct) bindgen will generate a struct with BindgenBitFieldUnit, that generated struct will also have the #[repr(align(#))] trait.
If the parent struct is packed then this gives the "error[E0588]: packed type cannot transitively contain a
#[repr(align)]
type" during build.This can normally be avoided if one doesn't need to use this struct my making the struct an opaque blob of bytes by signaling that in "bindgen_parameters".
However, some issues are present. Firstly, when the struct is unnamed this becomes more difficult. The only way I have found to signal that an unnamed struct needs to be an opaque blob is by identifying the unnamed struct's generated name (in rust/bindings_generated.rs) and putting that in "bindgen_parameters", which means one needs to have to build fail, so the bindings get generated, then find the name of the unnamed struct manually and add that to "bindgen_parameters"
Second this means that if one needs to use a stuct that contains such a child struct, the only solution is to manually modify bindings_generated.rs to remove the align trait on the generated child struct. This works in all scenarios I have run into since the align trait is the same size as the generated struct.
Example:
generates
This means without manually modifying hv_ring_buffer__bindgen_ty_1__bindgen_ty_1 and removing the align trait, the build will fail. This is tedious due to it requiring running the build once for it to fail after generating the bindings, then manually modifying them, to run the build a second time where it will succeed.
Third, having to add every struct that contains an unnamed child struct with bitfields leads to a lot of structs having to be added to “bindgen_parameters” which in the long term seems unsustainable. I am not sure what the best solution could be, but perhaps splitting bindgen_parameters similar to makefiles, where each directory would have its own bindgen_parameters, that way it doesn’t all get put in one monolithic file.
The text was updated successfully, but these errors were encountered: