Does D support anonymous structs?

Sean Kelly sean at f4.ca
Wed Feb 22 20:58:35 PST 2006


C:\code\d>type test.d
void main()
{
     struct { int i; } s;
     s.i = 1;
}


C:\code\d>dmd test
test.d(3): anonymous struct can only be a part of an aggregate
test.d(3): undefined identifier s
test.d(3): TOK117 has no effect in expression (s)
test.d(4): undefined identifier s
test.d(4): no property 'i' for type 'int'
test.d(4): constant s.i is not an lvalue

C:\code\d>

------------------------------------

C:\code\d>type test.d
void main()
{
     struct S
     {
         union
         {
             struct
             {
                 int i1;
             } s1;
         } u;
     }

     S s;
}


C:\code\d>dmd test
test.d(10): no identifier for declarator s1
test.d(11): no identifier for declarator u

C:\code\d>



More information about the Digitalmars-d mailing list