I’m building an application that needs to compile on both Windows and Linux. The application is written in C, almost everything works except the MinGW compiler refuses this
typedef struct somestruct{
...snip...
enum {NODE, REAL} type;
};
somestruct* something;
switch (something->type){
case NODE:
...stuff...;
break;
case REAL:
...otherstuff...;
break;
}
It says NODE and REAL are not defined,
But if I supply a scope resolution
case somestruct::NODE
This compiles with MinGW 3.4.1, but fails to compile with gcc 4.1.2 on linux. Is this simply a compiler issue that needs to be resolved with preprocessors or is there some other explanation?
If you get rid of the nesting, it should work portably:
I have seen code very similar to this be ported to a large number of C and C++ compilers.
(I’m not saying this is the only way to do it; I’m just saying that this way works).