Wouldn't this be better with bitfields?
Walter Bright
newshound2 at digitalmars.com
Wed Jul 10 19:02:53 UTC 2024
On 7/9/2024 4:58 AM, Mike Parker wrote:
> `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.
There is a case where it does. A struct with no data members is zero size if
extern(C), otherwise it is size 1. The size 1 comes from C++, which (correctly)
decided that individual objects should have distinct addresses.
This does have the potential to be memory unsafe, and a struct with no data
members should probably be rejected in @safe mode.
https://issues.dlang.org/show_bug.cgi?id=24657
More information about the Digitalmars-d
mailing list