-
Notifications
You must be signed in to change notification settings - Fork 723
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
How to avoid bindgen being out of sync with cc? #2962
Comments
the easiest I can think of is to set the relevant environment variables for The docs for |
I also ran into the problem recently that I had generated bindings that were incorrect because of enum size differences; similarly on a I had this idea for a "this would've prevented my mistake" feature: when bindgen encounters an enum, if it detects that the target platform is one that common C compilers disagree on the size of enums1 and you haven't manually specified A warning seemed like the most useful UX here because, at least for my use case, bindgen couldn't know that I was planning to link with code compiled by gcc, but the warning would've prompted me to figure out that the bindings were wrong before I learned so the hard way. Footnotes
|
ARM defers enum ABI choice to platform ABI, but of course typedef enum { Hello = 1 } Test; Solutions that have run through my mind include:
|
My understanding is, that it is very common to wrap a C library in a Rust
*-sys
crate by usingbindgen
to automatically generate Rust bindings andcc
to compile the C code.As far as I understand it
bindgen
useslibclang
to parse the C headers andcc
uses whatever compiler the user provides.This can lead to problems, because both toolchains don't need to agree on everything. While cross compiling for
thumbv6m-none-eabi
on Windows,bindgen
generatedu32
for enums andcc
usedu8
when possible (-fshort-enums
).This is quite unfortunate and hard to catch. Is there a common workaround for this?
PS: If there is a better place for this issue please tell me.
The text was updated successfully, but these errors were encountered: