Didier Barvaux wrote:
On a structure such as:
  struct mystruct1
  {
     unsigned int mystruct1_foo:4;
     unsigned int mystruct1_bar:4;
     uint8_t mystruct1_other;
     uint16_t mystruct1_other2;
  };

The 2 first fields uses 1 byte with GCC/Clang while they use
sizeof(unsigned int) bytes with TCC. GCC/Clang pack the bit fields on
the smaller type available. So, sizeof(struct mystruct1) = 4 with
GCC/Clang and sizeof(struct mystruct1) = 8 with TCC.

I tried your "bitfield.c" test with GCC and it failed on the 2nd
assertion.  Hm ...

--- grischka

My program (and probably many others, as the struct iphdr for IPv4
header defined by the GNU libc is defined that way) relies on this
behaviour. That's why I created the patch. It packs bit fields "the way
GCC does". If you got a better description, I'll be happy to change
it :)


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to