#include #include struct mystruct1 { unsigned int mystruct1_foo:4; unsigned int mystruct1_bar:4; uint8_t mystruct1_other; uint16_t mystruct1_other2; }; struct mystruct2 { unsigned int mystruct2_foo:4; unsigned int mystruct2_bar:4; }; struct mystruct3 { uint8_t mystruct3_other; uint16_t mystruct3_other2; unsigned int mystruct3_foo:4; unsigned int mystruct3_bar:4; }; struct mystruct4 { unsigned int mystruct4_foo1:7; unsigned int mystruct4_foo2:1; unsigned int mystruct4_bar1:5; unsigned int mystruct4_bar2:3; uint8_t mystruct4_other; uint16_t mystruct4_other2; }; struct mystruct5 { struct mystruct1 mystruct5_one; struct mystruct2 mystruct5_two; }; struct mystruct6 { struct mystruct1 mystruct6_one; struct mystruct2 mystruct6_two; uint8_t mystruct6_other; uint16_t mystruct6_other2; }; int main(int argc, char *argv[]) { struct mystruct1 test; assert(sizeof(struct mystruct1) == 4); assert(sizeof(struct mystruct2) == 1); assert(sizeof(struct mystruct3) == 4); assert(sizeof(struct mystruct4) == 5); assert(sizeof(struct mystruct5) == (sizeof(struct mystruct1) + sizeof(struct mystruct2))); assert(sizeof(struct mystruct6) == (sizeof(struct mystruct1) + sizeof(struct mystruct2) + 3)); test.mystruct1_other2 = 0xffff; return 0; }