Mattias Holm wrote:
Except that bitfields don't appear to be a widely used feature.
You clearly have not written systems code in Ada... :)
C-bitfields are problematic because the bit-ordering is implementation
defined, GCC have the bits appear in the order of definition on
big-endian machines and the reverse order on little endian machines. The
appropriate way is to have them as the big-endian fields in GCC, this is
also what most Ada-compilers seem to be doing.
They are incredibly useful for any systems and protocol programming, and
this is why they are nice to have in a language like D.
Bitfields are not used in C because they are not platform neutral, a
proper definition in D would mean that people would use them, at least
in the mentioned domains.
Bitfields in Phobos are defined portably: always populated from lsb to
msb, the total size must be 8, 16, 32, or 64, and there is no hidden
padding (you obtain padding with anonymous fields).
Andrei