GCC complains about this code even though I compile with -std=c++11
flag, and my gcc version supposedly supports Unrestricted unions (>4.6).
union
{
struct
{
float4 I,J,K,T;
};
struct
{
float4 m_lines[4];
};
struct
{
float m16f[16];
};
struct
{
float m44f[4][4];
};
};
Note that float4 has a non-default constructor that takes 0 parameters.
class float4
{
public:
float4();
....
};
Any idea of what I could do ? The error is :
<anonymous union>::<anonymous struct>::I’ with constructor not allowed in anonymous aggregate
float4
class. – Everrsfloats
inside nonstandard anonymousstructs
in the first place? I can't think of any benefit to this. However, of course, maybe I've just overlooked it. – Darnedobj
which type is the union of all those anonymous struct, I could do something likeb = obj.I
. However had I named the struct I would have had to dob = obj.foo.I
. I was porting a very large codebase to gcc, from a compiler which accepted this syntax and refactoring the whole code was too expensive. – Microwavestruct
declares multiplefloats
, so you couldn't just move all your struct.float members out into the top level of theunion
. It seems yourstructs
were achieving some purpose there, albeit a confusing one. ;) – Darned