www.digitalmars.com         C & C++   DMDScript  

D - Bug or syntax error: struct definitions in anonymous struct/union?

reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
I have been converting my program, which previously used unnamed types,
to use only named struct types.  However, you can't do that inside an
anonymous struct or union:

    union {    // anonymous
        struct _a { ... }
        _a a;    // syntax error, "identifier '_a'  is not defined"
    }

I have to hackishly move the struct definition out of the union:
    struct _a { ... }
    union {
        _a a;
    }

Maybe we need a new keyword for "unnamed struct variable" that can work
more like the old C++ style?

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]
Sep 20 2002
parent "Walter" <walter digitalmars.com> writes:
It looks like a compiler bug. -Walter

"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D8BA059.8D4DF2A8 deming-os.org...
 I have been converting my program, which previously used unnamed types,
 to use only named struct types.  However, you can't do that inside an
 anonymous struct or union:

     union {    // anonymous
         struct _a { ... }
         _a a;    // syntax error, "identifier '_a'  is not defined"
     }

 I have to hackishly move the struct definition out of the union:
     struct _a { ... }
     union {
         _a a;
     }

 Maybe we need a new keyword for "unnamed struct variable" that can work
 more like the old C++ style?

 --
 The Villagers are Online! villagersonline.com

 .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
 .[ (a version.of(English).(precise.more)) is(possible) ]
 ?[ you want.to(help(develop(it))) ]

Sep 22 2002