How to handle nested structs when converting C headers?

Adam D. Ruppe destructionator at gmail.com
Wed Dec 11 15:43:42 PST 2013


On Wednesday, 11 December 2013 at 23:36:11 UTC, bearophile wrote:
> In D you can't define a struct/union and use it to define an 
> instance on the fly.

Well, you can if it is anonymous.

struct Foo {
     union {
         struct { ubyte a; ubyte b; }
         ubyte[2] arr;
     }
}

That works in D, and it makes foo.a == arr[0] and foo.b == arr[1];


More information about the Digitalmars-d-learn mailing list