-
Notifications
You must be signed in to change notification settings - Fork 711
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
Bad bindings for empty C struct on windows #1683
Comments
In C all structs need to have a different address. It is unexpected that the size is four in windows though... |
I was expecting it to not have an _address field because that is what is generated on Linux. The "Expected Results" in the issue is the output that I get when I run bindgen on Linux with the same input. |
Ah, I didn't notice that... That's weird indeed, probably MSVC has a different ABI than gcc for empty structs and we're choking on it. |
It is worth mentioning that the C standard makes empty structs UB.
MSVC seems to reject this outright, GCC makes it size zero. Not sure what clang says on Windows. Might mimick GCC's behaviour. |
rustc also has problems with |
Input C Header
Bindgen Invocation
This is specifically for windows. I've installed LLVM according to the documentation, and I'm setting my LIBCLANG_PATH like so (in powershell):
Then I invoke bindgen like so:
Actual Results
Expected Results
I expected it to generate an empty rust struct, like so:
From this issue I understand that the
_address field is supposed to be added for C++ structs, but this is a C struct. Also, the tests
that are generated are incorrect, the u8 _address field is 1usize not 4usize.
I've tested this on linux and it's not a problem there.
Here are the debugging logs:
The text was updated successfully, but these errors were encountered: