proper bit fields in the D2 language?

Mattias Holm mattias.holm at openorbit.REMOVE.THIS.org
Mon Apr 27 11:41:58 PDT 2009


> 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.

/ Mattias



More information about the Digitalmars-d mailing list