Re: Disable Compiler Waring

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



HI Ulrich,
I don't have to worry about compiling my code in other compiler. But I like your idea of putting/enclosing the enum declaration in a namespace.

Thanks & Regards,
Ashutosh

Ulrich Eckhardt wrote:
Ashutosh Bhawasinka wrote:
I want to disable compiler warning C4482 (nonstandard extension used:
enum 'enum' used in qualified name)

Fix the code:

enum foo { bar };
// wrong
foo f = foo::bar;
// correct
foo f = bar;

Enumeration constants 'leak' into the surrounding namespace. If you don't
want that, enclose the enumeration itself in a namespace:

namespace foo {
enum type { bar };
}
foo::type f = foo::bar;

Secondly, will this have any effect on the project?

Disabling or ignoring warning doesn't directly affect the outcome, but in
general warnings are a sign of low code quality. Your code above is simply
not portable to other compilers that don't support this extension.

Fix it, it's broken.

Uli

.



Relevant Pages

  • Re: What scope is best for defining Enum type?
    ... > public Class Product ... > Public Enum Status ... > 'Use the enumerated type within the class like this: ... Did you mean to type "in the rest of the namespace"? ...
    (microsoft.public.dotnet.languages.vb)
  • Help with Grammar Specification
    ... oneenum: enum '' ... namespace, default and handlerclasses can all reduce to nothing so ... only the values component of the production is required. ...
    (comp.compilers)
  • Multiple Type Definition Causes Resource Failure
    ... why a particular form was failing to load and instead generating an error ... about a lack of available resources for that locale. ... to the project option dialog namespace. ... Public Enum MyEnum ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Type casting from one namespace to the other.
    ... e1getSet() ... in e1 namespace, ... I have two enum definitions from two different namespaces: ... Let say in ns1 I have created a array such that ...
    (microsoft.public.dotnet.languages.csharp)
  • Serializing Enum type is non CLS-Compliant.
    ... One of the members of this 'Common' class is ... public enum thingsAsEnums ... public class DoThings ... namespace, the error goes away. ...
    (microsoft.public.dotnet.languages.csharp)