DIP: add Bit Fields
Timon Gehr
timon.gehr at gmx.ch
Sat Mar 16 21:32:47 UTC 2024
On 3/7/24 20:42, Walter Bright wrote:
>
> I.e. the layout is implementation-defined. That's correct. But in
> reality, it is fixed. There is no way that gcc on Linux is *ever* going
> to change the bit field layout, because it would break legions of
> existing code. It is cast in concrete, and is as immutable as it gets.
> The same for Microsoft C.
>
> Furthermore, if you use `int` as the base type for bit fields, the
> layouts are all the same in all the C compilers I've encountered. For
> practical purposes, it is defined.
>
> If you are still concerned about the layout, like you want a portable
> file format, don't use bit fields. Use std.bitmanip.
Well, that's kind of a foot gun. Portable by default is better.
More information about the dip.development
mailing list