This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Anonymous union members problem
- From: Mathieu Fluhr <mfluhr at nero dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 19 Apr 2004 15:08:33 +0200
- Subject: Anonymous union members problem
Hello
I am porting VC++ source code to Linux using g++ 3.3 and I am currently
getting some errors with C++ code like this sample program:
struct foo
{
struct
{
typedef int structType;
union
{
int test;
};
};
};
int main()
{
return 0;
}
When I try to compile this program, I get the following message:
mathieu@c-l-175:~/tests/bitfields$ g++-3.3 -Wall bitfields.cpp
bitfields.cpp:5: error: `typedef int foo::<anonymous
struct>::structType'
invalid; an anonymous union can only have non-static data members
Is this invalid C++ code ? If yes is there a way to make it valid and
compilable under Linux ?
Regards,
Mathieu