DIP: add Bit Fields
Daniel N
no at public.email
Sat Mar 9 08:38:59 UTC 2024
On Saturday, 9 March 2024 at 07:51:08 UTC, Walter Bright wrote:
> Sometimes, too many options is not helpful. This is one of
> those situations. The problem with implementation-defined
> layout is much more of a pedantic one than a pragmatic one, as
> I've explained elsewhere in this thread.
>
> If one sticks with `int` bit fields, they behave the same
> across C compilers that I've seen. Just like ints are 32 bits.
>
> We don't have an attribute to switch endianess. It's just not
> worth the added complexity.
>
> If anyone is worried about exactly specifying the layout, using
> masking and shifting will guarantee it (absent endianess
> issues!).
>
> We do not need to solve every detail, just go for the critical
> ones.
Fully agree. There's nothing wrong with implementation-defined.
I guess it might be possible to make an even stronger guarantee,
specifying that the current behavior is how it must work on
windows and unix in order to be compliant with the D language
spec. The same way we decided to define the common practise for
integer wrapping and two's complement.
More information about the dip.development
mailing list