Wouldn't this be better with bitfields?

claptrap clap at trap.com
Tue Jul 9 10:57:02 UTC 2024


On Monday, 8 July 2024 at 23:29:15 UTC, Walter Bright wrote:
> On 7/7/2024 3:21 AM, claptrap wrote:
>> D should not be adding language features that change their 
>> specification depending on what external C compiler happens to 
>> be attached to the project.
>
> It always has - from its inception the struct member layout and 
> alignment matches what C does. D needs to be a useful 
> programming language, and effortless compatibility with C data 
> layout makes it much more useful.

You have completely missed the point. Struct layout doesn't 
change, it's fixed, it doesn't depend on what C compiler is 
attached.

It's not C-compatibility, but letting the under specification of 
C bitfields basically infect D. Its the tail wagging the dog. Or 
leaky implementation. If I have a D program that links a dll or 
static lib also written in D, they could have incompatible 
bitfield layouts.

You could fix this by specifying the layout for D bitfields, and 
using extern(C) when compatibility with the relevant C compiler 
is required. D already does that for classes and functions...








More information about the Digitalmars-d mailing list