I want to keep any other checks -Wpedantic
does but lose the warning about unnamed structs error: ISO C++ prohibits anonymous structs [-Wpedantic]
.
I want to be able to do the following:
union
{
struct
{
float x, y, z, w;
};
struct
{
float r, g, b, a;
};
float v[4];
};
What I've found so far
I'm using C++11 and compiling with the -std=c++11
flag. I've read that C11 supports this feature, but I haven't seen any mention of it being supported in C++11.
I've come across mention of -fms-extensions
:
In this SO question about C for which it is the accepted answer
In the GCC documentation for the flag's use when compiling C++ which doesn't give very many details
I tried the flag and it doesn't appear to have any effect (no matter the permutation of ordering between -fms-extensions
and -Wpedantic
).
EDIT - More details
Thanks to the comments I've found the following:
Details about why unnamed classes/structs are not fully conformant with the standard
A post that claims my example code relies on undefined behavior
I'd still like to know if there is a method of enabling this gcc extension (which all compilers I know of have) that will disable the warning. Or is -Wpedantic
all or nothing?