I’d like to define my own Enumerated type: ExitType. I wrote it like so:
enum ExitType{
EXIT_SUCCESS,
EXIT_FAILURE,
EXIT_OTHERTYPE
};
I have a function that returns an ExitType. On some conditions it returns EXIT_SUCCESS. But I get the error message that you can’t cast from an int to an ExitType. Can I undefine EXIT_SUCCESS for my IDE, or am I stuck using static_cast<int>(EXIT_SUCCESS)? It seems to introduce the possibility that their EXIT_SUCCESS will line up with my EXIT_OTHERTYPE, etc.
I’m using Eclipse Helios with the CDT, MinGW32 and SDL. All 32-bit, and the latest versions.
Edit: Tried undefining EXIT_SUCCESS with the preprocessor.
#undef EXIT_SUCCESS
#undef EXIT_FAILURE
enum ExitType{
EXIT_SUCCESS,
EXIT_FAILURE,
EXIT_OTHERTYPE,
EXIT_NOEXIT
};
Result:
..\src\EventManager.cpp:12:7: error: invalid conversion from ‘int’ to ‘ExitType’
Edit 2: When I moved my undefines AFTER the inclusion of <SDL/SDL.h>, the error went away. A GREP of the SDL code doesn’t turn up anything matching EXIT_SUCCESS, though.
#undef EXIT_SUCCESSshould undefine the preprocessor symbolEXIT_SUCCESS, which is what I assume is going on here. But only do that if you’re CERTAIN that you will not break anything by doing so!