How do I find something that the C++ compiler thinks is defined as a constant?
If your compiler is unwilling to produce helpful messages (usually it prints where term has been defined previously) or if you suspect that you fell victim of macro voodoo in WinAPI headers...
Selectively comment out lines of code and recompile to pinpoint the problem.
If you comment out one line and your program compiles after that, that line is source of your problem. If your code block is big, do "binary search" - comment out a whole block, then half of it, so you narrow down the problem quickly.
In IDEs you often can mouse over the item to see where it is defined or press a key or use context menus to "jump to definition".
In addition to that you can investigate preprocessor output.
and can't selectively comment out headers to test when it changes - since the new list of compiler warnings would be too onerous to work through
Make a blank *.cpp file and copy the problematic definitions into it till you break it. That would allow you to pinpoint the problem.
It is a good practice to always include only the minimal set of necessary headers into your own *.h files, preferably completely avoiding OS-specific headers, although that is not really possible in this case.
In your particular scenario another good option is to change your naming style for enum values. Normally ALL_UPPERCASE
is reserved for macros only (macros definition and macro constants). A notable exception to this rule is the min
and max
macros defined within Windows headers (they can be disabled). Because you used it in an enum
, you clashed with OS-specific definition. I would use the same naming convention for enums as for constant and local variables.