0 votes
in D Programming by
How Do I Do Anonymous Struct/unions In D?

1 Answer

0 votes
by

import std.stdio;

struct Foo

{

    union { int a; int b; }

    struct { int c; int d; }

}

void main()

{

    writefln(

        "Foo.sizeof = %d, a.offset = %d, b.offset = %d, c.offset = %d, d.offset = %d",

        Foo.sizeof,

        Foo.a.offsetof,

        Foo.b.offsetof,

        Foo.c.offsetof,

        Foo.d.offsetof);

}

Related questions

+1 vote
asked Mar 5, 2021 in D Programming by SakshiSharma
0 votes
asked Mar 5, 2021 in D Programming by SakshiSharma
...