-
Notifications
You must be signed in to change notification settings - Fork 748
Bindgen fail to generate bindings for struct. #1314
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
Comments
Thanks for the report! A bit reduced: #include <stdint.h>
typedef struct {
uint16_t f6;
uint8_t f11 : 2;
uint8_t f12 : 4;
uint16_t f13 : 10;
uint8_t f14;
uint32_t f15 : 19;
} S; |
The size of: We should have "pub _bitfield_2: __BindgenBitfieldUnit<[u8; 3usize], u8>," |
In section 6.7.2.1 #10 of C99 spec (http://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf): |
Clang implementation is here: (section Detailed Description) |
The following structs have different layouts But bindgen gives same struct. |
I took a look at this today, will submit a fix. |
We should also align the allocation unit even if it's the first bitfield in the allocation unit. Fixes rust-lang#1314
Header:
#include <stdint.h>
typedef struct {
uint32_t f : 20;
uint8_t f1 : 4;
uint8_t f2 : 1;
uint8_t f3 : 1;
uint8_t f4 : 1;
uint8_t f5 : 5;
uint16_t f6;
uint8_t f7;
uint8_t f8;
uint8_t f9;
uint8_t f10;
uint8_t f11 : 2;
uint8_t f12 : 4;
uint16_t f13 : 10;
uint8_t f14;
uint32_t f15 : 19;
} S;
Bindgen command:
bindgen types.h -o t.rs
ERROR 2018-05-17T23:24:11Z: bindgen::codegen::struct_layout: Calculated wrong layout for S, too more 1 bytes
Bindgen version:
bindgen 0.36.1
The text was updated successfully, but these errors were encountered: