Originally Posted by
matsp
The second attempt is what you get
if you change "int" to "short" in the bit_t struct. Remember
that the compiler will align the entire struct to the size of the
basic type, so if you ACTUALLY want the struct to be 32 bits,
you should use unsigned int, if you want it to be 16 bits, use
unsigned short [or some other type that has a 16-bit size -
this is typically a case for using "uint32_t" or "uint16_t".
Is this what you meant by the compiler making "inefficient"
code, because to me it is "you get what you ask for" type
behaviour. There is no code accessing the bitfields in this
example, so there's no inefficiency in that respect.
Edit: I have no intention to edit Wikipedia, as at least the
part you quoted I have no disagrement with.
--
Mats