Union member positions?

Dennis dkorpel at gmail.com
Tue Aug 17 13:57:34 UTC 2021


On Tuesday, 17 August 2021 at 13:46:22 UTC, z wrote:
> Is it possible to set a "position" on a union member?

You can use anonymous `struct` and `union` blocks.

```D
union UnionExample{
     uint EAX;

     struct {
         //upper
         union {
             ushort EAHX;
             struct {
                 ubyte EAHH;
                 ubyte EAHL;
             }
         }
         //lower
         union {
             ushort EALX;
             struct {
                 ubyte EALH;
                 ubyte EALL;
             }
         }
     }
}
```


More information about the Digitalmars-d-learn mailing list