nested unions and structs

Oskar Linde oskar.lindeREM at OVEgmail.com
Thu Apr 27 02:53:11 PDT 2006


Alberto Simon wrote:
> The union DWord below does not product the expected union, Data isn't at the
> same address as the union start address is... What should I do to correct that??
> 
> public union Word
> {
> // Atributos
> 
> struct
> {
> public ubyte Low;
> public ubyte High;
> }
> public ushort Data;
> }
> 
> public union DWord
> {
> // Atributos
> 
> public uint Data;
> struct
> {
> public Word HigherWord;
> public Word LowerWord;
> };
> }

On what platform & compiler? On Linux dmd 0.154 they are for me:

   Word w;
   DWord d;
   writefln("%s %s",&d,&(d.Data));
   writefln("%s %s",&w,&(w.Data));

Prints:

bfffed24 bfffed24
bfffed20 bfffed20

/Oskar



More information about the Digitalmars-d mailing list