C bitfields guarantees
Walter Bright
newshound2 at digitalmars.com
Wed Jul 10 06:58:23 UTC 2024
On 7/9/2024 6:57 PM, Timon Gehr wrote:
> ```d
> extern(C) struct S{}
> pragma(msg, S.sizeof); // 0LU
> pragma(msg, (S[100]).sizeof); // 0LU
>
> struct T{}
> pragma(msg, T.sizeof); // 1LU
> pragma(msg, (T[100]).sizeof); // 100LU
> ```
>
> In any case, here, the usage is a bit different, in that the `extern(D)` version
> would just be a bit more restrictive, but still fully compatible.
C and C++ differ here, too. D defaults to the C++ route because they wanted
distinct objects to have distinct addresses, which made sense to me.
More information about the Digitalmars-d
mailing list