anonymous structures within a union do not compile by c++ compiler

Alex Babkin ababkin@ati.com
Wed Jun 2 21:09:00 GMT 2004


Hi

the following code compiles if the source file uses .c extension with 
the usual "gcc -o out source.c" command but would not compie if i rename 
the file to .cpp extension.
Reason I bother with this is that i am porting some code originally 
written for windows which uses anonymous structures and all source are 
.cpp files. (i cannot change that)

So how can i get it to compile when using .cpp extension (ie using the 
g++ (?) compiler)
The gcc version i use is 3.3.3

Here is the code:

 typedef union
{
   //Point in 3D space
   struct { float x, y, z; };
   struct { float v[3]; };
} Vertex3, Vector3;

typedef union
{
   //Point in 2D space
   struct { float u, v; };
   struct { float t[2]; };
} TexCoord2D;

typedef struct
{
   Vertex3 vertex;
   TexCoord2D tex010;
} VertexTex;


static VertexTex gTexVerts[4] = { {0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
                                  {1.0f, 0.0f, 0.0f, 1.0f, 0.0f},
                                  {0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
                                  {1.0f, 1.0f, 0.0f, 1.0f, 1.0f} };
                                 
int main(int argc, char** argv){

return 0;}




Thanks
Alex
ATI Linux team



More information about the Gcc mailing list