Unnamed structures inside a union and Sun Studio 11
I am curious why the following code snippet:
#include <stdio.h>
#include <inttypes.h>
typedef union foobar
{
struct
{
unsigned longuhigh;
unsigned longulow;
};
struct
{
long shigh;
long slow;
};
int64_t asint64;
uint64_t asuint64;
} FooBar_t;
int main(void)
{
return 0;
}
generates errors when compiled using Sun Studio 11 on Solaris 9:
"test.cpp", line 10: Error: A declaration does not specify a tag or an identifier.
"test.cpp", line 16: Error: A declaration does not specify a tag or an identifier.
2 Error(s) detected.
The same code snippet compiles without any errors/warnings on Linux with gcc 4.1.2, on AIX 5.3 with IBM's XL C/C++ v8.0 compiler, and on Windows with MS Visual Studio .NET 2003.
What part of the language specification, if any, is Sun Studio 11 trying to enforce?
I am really confused as to why Sun Studio is treating the unnamed structures inside the union as errors, when three other compilers have no issue with it.
Platform and compiler info is:
[~]$ uname -a
SunOS blade 5.9 Generic_118558-39 sun4u sparc SUNW,Sun-Blade-1500
[~]$ CC -V
CC: Sun C++ 5.8 2005/10/13
Thanks!

