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

Ensure that structs and unions in C are never empty. #611

Conversation

sunfishcode
Copy link
Member

Empty structs and unions are a non-standard extension in C, and have a different layout between C and C++, so avoid emitting them. If a generated struct or union would have zero members, give it a u8 __empty; member so that it's not actually empty, so that it gets a consistent layout no matter how it's being compiled.

Empty structs and unions are a non-standard extension in C, and have a
different layout between C and C++, so avoid emitting them. If a generated
struct or union would have zero members, give it a `u8 __empty;` member so
that it's not actually empty, so that it gets a consistent layout no
matter how it's being compiled.
@sunfishcode
Copy link
Member Author

This approach of inserting __empty fields isn't working well, so I'm going to take a different approach here.

@sunfishcode sunfishcode deleted the sunfishcode/no-empties-in-c branch July 12, 2023 22:32
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