Conflict between a namespace and a define
c++, c-preprocessor, namespaces
Solution
Generally, you should avoid using all-caps identifiers as they are used for macros. In this case, I'd rename the namespace.
(As a side note, `<windows.h>` `#define`s other stuff like `GetPrinter` and indeed it gets annoying. I usually go with `#undef` then. It also helps to only include `<windows.h>` in .cpp files and make sure the scope affected by the header is as small as possible.)
Problem
I have this serious problem. I have an enumeration within 2 namespaces like this: ``` namespace FANLib { namespace ERROR { enum TYPE { /// FSL error codes FSL_PARSER_FILE_IERROR,... ``` and somewhere else in my code, I use it like this: ``` FANLib::Log::internalLog(FSLParser::FILE_IERROR, file_ierror, true, FANLib::ERROR::FSL_PARSER_FILE_IERROR); ``` All compiles fine and well, but if I happen to include "windows.h", I get errors! The problem is in "WinGDI.h" which has this line: ``` #define ERROR 0 ``` and makes the compiler think that, after FANLib::..., there is a zero! The error I get is : Error 1 error C2589: 'constant' : illegal token on right side of '::' Error 2 error C2059: syntax error : '::' Error 3 error C2039: 'FSL_PARSER_FILE_IERROR' : is not a member of '`global namespace'' Is there anything I can do about this, without having to change my namespaces due to some thoughtless `#define`? I have read in another post that I could #undef ERROR, but how safe is that?