Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to disable MSVC warning C4482?

While qualifying an enumeration value with the name of the enumeration is not valid C++03, it is valid C++11, from what I understand. Despite this, MSVC 10 generates warning C4482 for the following:

enum E { A, B };

int i = E::A;  // warning C4482 (but valid C++11?)

Since much of our code uses C++11 features (especially lambdas), it seems safe to disable this warning. Am I right that the code is valid C++11?

Note: I did not write the code in question, and I would prefer to not go through and change every occurrence of this.

Edit: Added some relevant links.

  • MSDN page for the warning.
  • Another question about the warning. The question and answers all seem to reference C++03.
like image 789
jakar Avatar asked Oct 13 '11 17:10

jakar


1 Answers

Since much of our code uses C++11 features (especially lambdas), it seems safe to disable this warning.

If you're already relying on C++11 features, then yes. C++11 does allow you to use regular enums scoped by the enumeration's name. Microsoft had this as an extension for some time, so they issued a warning about the non-standard behavior.

So you can disable it.

like image 136
Nicol Bolas Avatar answered Nov 07 '22 22:11

Nicol Bolas