* Doug McIlroy via Gcc: > What was the rationale for the gcc ABI convention that int > bit fields force the containing struct to be int-aligned? > > For example, the size of struct{int x:2;} is 4 in Linux > gcc, completely wasting 3 out of every 4 bytes of memory.
I'm pretty sure that this follows from the struct alignment rules in the relevant ABIs, which do not treat bitfield members differently from non-bitfield members. > One can get finer alignment by declaring small fields > to be char, but this is non-portable because char bit > fields are an optional feature of the C standard. And the ABIs need to support compilers which support int bit fields only. Thanks, Florian