5

I have

enum class ErrorLevel
    {
        VERBOSE,
        DEBUG_,
        INFORMATION,
        WARNING,
        ERROR
    };

This works:

assertDetectionParameters( parameterSet, ErrorLevel::WARNING );

This does not:

assertDetectionParameters( parameterSet, ErrorLevel::ERROR );

Error 1 error C2589: 'constant' : illegal token on right side of '::'
Error 2 error C2059: syntax error : '::'

Resharper says:

"ErrorLevel does not name a value"

I get this error for certain names in my enum.

9
  • 8
    ERROR is probably already a preprocessor macro somewhere. Try changing it to something else, e.g. ERROR_, in order to test this hypothesis, Commented Jun 8, 2015 at 7:02
  • 2
    Yes, that is it. Please add an answer. Thx. Commented Jun 8, 2015 at 7:08
  • 1
    A much better solution is to keep preprocessor macros and other code separate by always using UPPERCASE_NAMES for macros and only for macros. Commented Jun 8, 2015 at 7:33
  • I think ERROR is a perfectly legal name and must not be defined by any standard compliant compiler. Don't use rubbish compilers. Commented Jun 8, 2015 at 7:50
  • @Walter Is there a reason why you think this is a compiler issue? I just tried the same code in a vanilla vs2013 and ERROR isn't defined by the compiler or standard headers. Commented Jun 8, 2015 at 10:55

1 Answer 1

2

ERROR is probably already a preprocessor macro somewhere. Try changing it to something else, e.g. ERROR_, in order to test this hypothesis. Alternatively run your code through the preprocessor to see what substitutions are being made (gcc -E ... or whatever the equivalent is in Visual Studio).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.