Thread overview
Bit fields in struct, why doesn't D support them?
May 20, 2009
Jeremie Pelletier
May 20, 2009
Lutger
May 20, 2009
Brad Roberts
May 20, 2009
I know this is an old subject, as this has been stated in the struct reference page ever since D1, but I'm really wondering why the bit fields aren't supported (or purposely not implemented?) in D.

Having this feature would greatly simplify a lot of code, and allow easier interfacing with C structs using it.

May 20, 2009
On Tue, May 19, 2009 at 11:17 PM, Jeremie Pelletier <jeremiep@gmail.com> wrote:
> I know this is an old subject, as this has been stated in the struct reference page ever since D1, but I'm really wondering why the bit fields aren't supported (or purposely not implemented?) in D.
>
> Having this feature would greatly simplify a lot of code, and allow easier interfacing with C structs using it.

It actually wouldn't, since C doesn't specify any order to packing bitfields, whether there should be padding etc.
May 20, 2009
Jeremie Pelletier wrote:

> I know this is an old subject, as this has been stated in the struct reference page ever since D1, but I'm really wondering why the bit fields aren't supported (or purposely not implemented?) in D.
> 
> Having this feature would greatly simplify a lot of code, and allow easier interfacing with C structs using it.

In D2 it is supported by phobos: http://www.digitalmars.com/d/2.0/phobos/std_bitmanip.html



May 20, 2009
Jeremie Pelletier wrote:
> I know this is an old subject, as this has been stated in the struct reference page ever since D1, but I'm really wondering why the bit fields aren't supported (or purposely not implemented?) in D.
> 
> Having this feature would greatly simplify a lot of code, and allow easier interfacing with C structs using it.

Google is your friend.  This thread has happened at least once in the past already.  Before rehashing it, might as well catch up on the past discussion:

http://www.digitalmars.com/d/archives/digitalmars/D/proper_bit_fields_in_the_D2_language_88506.html

Later,
Brad