Wouldn't this be better with bitfields?

Walter Bright newshound2 at digitalmars.com
Fri Jul 5 16:48:29 UTC 2024


On 7/3/2024 6:47 PM, Steven Schveighoffer wrote:
> But... I'm thinking now, why not just specify that? If you use uint, this is the 
> explicit layout, and any C compiler that doesn't implement that mechanism, D 
> does not support bitfield compatibility.
> That would go a long way to alleviating any concerns that portability would be 
> based on the whim of some C compiler.
> 
> This should be fine, because, as you say, everyone already does it that way. D 
> has the opportunity to make this official.

AFAIK, no C compiler has bothered to document the details of their bit field layout.

As for D, it specifies that the layout will match that of the "associated C 
compiler".

We could add a "best practices" note in the spec.



More information about the Digitalmars-d mailing list