C bitfields guarantees
Walter Bright
newshound2 at digitalmars.com
Fri Jul 5 23:33:34 UTC 2024
On 7/5/2024 12:35 PM, Steven Schveighoffer wrote:
> What if you need > 32 bits or want to pack into a `ulong`? Is the behavior sane
> across compilers?
Yes. The trouble happens when you mix different field types. There are also
differences when declaring "packed" bit fields - a C extension that ImportC does
not implement.
You can see which cases are different in:
ImportC:
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/bitfieldsms.c
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/bitfieldsposix32.c
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/bitfieldsposix64.c
D:
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/dbitfieldsms.c
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/dbitfieldsposix32.c
https://github.com/dlang/dmd/blob/master/compiler/test/runnable/dbitfieldsposix64.c
More information about the Digitalmars-d
mailing list