This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
anonymous structures within a union do not compile by c++ compiler
- From: Alex Babkin <ababkin at ati dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 02 Jun 2004 17:05:00 -0400
- Subject: anonymous structures within a union do not compile by c++ compiler
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