C bitfields guarantees
Timon Gehr
timon.gehr at gmx.ch
Wed Jul 10 01:57:45 UTC 2024
On 7/10/24 03:41, Steven Schveighoffer wrote:
> I stayed away from `extern(C)` specification because I *kinda* see the
> point that we have no precedent for `extern(C)` to adjust field layout.
Well, it does affect layout:
```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.
More information about the Digitalmars-d
mailing list