| |
![claptrap's Gravatar profile Gravatar of claptrap](//www.gravatar.com/avatar/fbbc7d173f85f2cb2ce998e33d372189?d=identicon&s=32) | Posted by claptrap in reply to Mike Parker | Permalink Reply |
|
claptrap ![claptrap's Gravatar profile Gravatar of claptrap](//www.gravatar.com/avatar/fbbc7d173f85f2cb2ce998e33d372189?d=identicon&s=80)
Posted in reply to Mike Parker
| On Tuesday, 9 July 2024 at 11:58:14 UTC, Mike Parker wrote:
> On Tuesday, 9 July 2024 at 10:57:02 UTC, claptrap wrote:
>
>>
>> You have completely missed the point. Struct layout doesn't change, it's fixed, it doesn't depend on what C compiler is attached.
>
> The layout is fixed, but alignment and padding are implementation specific.
>
>>
>> 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...
>
> `extern(C)` does not affect the layout of anything, as far as I know. It only impacts name mangling and calling convention. Using it to change layout would be a new feature.
>
> When I worked on Derelict and BindBC, I would have loved to have had bitfields in D. And I would have expected them to line up with the associated C compiler out of the box, because that's what already happens with structs.
Apparently I'm an idiot who has no idea what he's talking about.
Sorry.
|