-
Notifications
You must be signed in to change notification settings - Fork 716
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
Enums don't match expected behaviour with value mem::zeroed(). #483
Comments
Right, this is known (see stuff like #225, etc.) and there are two ways to workaround it. The first one is using the |
Thank you for your response. This workaround works but has another problem however because it is not possible to match name of the enum using the --bitfield-enum regex expression. The enum in my example above has no direct name, because it is typedef'd as |
Yes, for unnamed enums, since they're effectively toplevel constants, we match against the individual variants too, you could use `--bitfield-enum "FLAG_.*", and that should work :) |
Thank you again, this does indeed work! |
Cool, closing this for now then! This is effectively a lack of documentation problem (we are trying to address that, though time is not infinite, so we do our best :P). Sorry for the trouble and please file more issues if you find any other trouble getting bindgen to work :) |
Hello, while generating bindings for harfbuzz I came upon a very strange bug in my code that wrapped one of the generated types into an
Option
. Basically this assertion failed:After lots of debugging, I think I found the reason for this obvious misbehaviour. The value I wrapped into the
Option
was returned from one of harfbuzz's functions. However that value contains an C-enum field that was converted by bindgen (using no flags) into a Rust enum like this:original C code:
code produced by bindgen
As you can see the only enum variant that the C code exposes is FLAG_1 with value 1. However the harfbuzz library sometimes returns 0 for values of type
SomeHarfbuzzFlag
to signify that no flags are given.This results in very weird behaviour when using the bindings. For example using the code snippets above the following tests fail:
I used
mem::zeroed()
in these examples to mimic the zero value that a C library would return.The text was updated successfully, but these errors were encountered: