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 wrap struct padding in __bindgen_marker_Opaque #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tchebb
Copy link

@tchebb tchebb commented Mar 17, 2025

Just as with zero-sized structs, this usage of blob() doesn't mean the type is opaque: padding is perfectly safe to allocate, modify, and pass around. By marking it with __bindgen_marker_Opaque, we prevent autocxx from making padded structs POD.

This hasn't cropped up so far because explicit padding fields are quite rare in bindgen, but they do show up when a struct ends with a bitfield. I'm about to contribute POD bitfield support to autocxx (edit: now submitted as google/autocxx#1478), which this fix helps enable.

Just as with zero-sized structs, this usage of blob() doesn't mean the
type is opaque: padding is perfectly safe to allocate, modify, and pass
around. By marking it with __bindgen_marker_Opaque, we prevent autocxx
from making padded structs POD.

This hasn't cropped up so far because explicit padding fields are quite
rare in bindgen, but they do show up when a struct ends with a bitfield.
I'm about to contribute POD bitfield support to autocxx, which this fix
helps enable.
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

Successfully merging this pull request may close these issues.

1 participant