I am currently working on some microcontroller code in C, and one of the third-party libraries I am using has some structs and unions defined in the following manner:
typedef struct
{
...members of struct...
} somename;
typedef struct
{
...members of struct...
} somename2;
typedef union
{
somename somename;
somename2 somename2;
} anothername;
The code compiles in Atmel Studio 7 (not sure what underlying compiler it's using), but it fails to compile in the Arduino IDE (which is using some version of gcc/g++ I believe).
Is the above code valid C? Or is it valid C++? Or valid either/neither? It seems strange to me that the authors of this code would give the members of this union a variable name that is identical to the type name which happens to be a struct they defined just above in the file.
Anyway, the Arduino compiler is throwing errors when it reaches this code, so I'm trying to figure out whether it's valid code and how to make the Arduino compiler like it. Any suggestions? Thanks!