Some C++ compilers permit anonymous unions and structs as an extension to standard C++. It's a bit of syntactic sugar that's occasionally very helpful.
What's the rationale that prevents this from being part of the standard? Is there a technical roadblock? A philosophical one? Or just not enough of a need to justify it?
Here's a sample of what I'm talking about:
struct vector3 {
union {
struct {
float x;
float y;
float z;
};
float v[3];
};
};
My compiler will accept this, but it warns that "nameless struct/union" is a non-standard extension to C++.
struct { int i; } a; a.i = 0;
(the type has no name). The second is this one, which C++ does not support:struct { int i; }; i = 0;
(the type has no name, and it escapes into the surrounding scope). C++, however, does support both unnamed and anonymous unions.