acces to nested struc/unit member

novice2 sorry at noem.ail
Fri Dec 29 06:52:59 PST 2006


Hello. Could please anybody explain me syntax to access to nested
structure/union members? In Windows API translated headers thearis
situation - anonimous union nested in structure. This is minimal
trivial extracted example:

//dmd\html\d\struct.html: "anonymous structs/unions are allowed as
members of other structs/unions"

struct Stru
{
  int a;
  union Uni
  {
    int b;
    int c;
  };
}


void main()
{
  Stru s;

  //s.Uni.b = 2; // Error: need 'this' to access member b

  //s.b = 2;     // Error: no property 'b' for type 'Stru'
                 // Error: constant (s).b is not an lvalue
}


How i can access to s.Uni.b ?
Thanks for any advises.


More information about the Digitalmars-d-learn mailing list