Chinaunix首页 | 论坛 | 博客
  • 博客访问: 629341
  • 博文数量: 138
  • 博客积分: 3067
  • 博客等级: 中校
  • 技术积分: 1565
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 12:44
文章分类

全部博文(138)

文章存档

2016年(5)

2014年(4)

2012年(1)

2011年(2)

2010年(10)

2009年(19)

2008年(97)

我的朋友

分类: C/C++

2008-06-17 12:24:10

MSDN:
compiler warning (level 1) C4482
warning description:

使用了非标准扩展: 限定名中使用了枚举“enum”
当引用类型内的枚举时,无需指定枚举的名称。
文件范围的枚举定义相当于常量,也不需要限定名。

example: C4482(MS Visual Studio)

// C4482.cpp

// compile with: /c /W1

struct S {
   enum E { a };
};

int i = S::E::a; // C4482

int j = S::a; // OK

 

NOTE:
warring C4482:  nonstandard extension used: enum **** used in qualified name

enumeration:
1. Standard C++ does not allow enumeration names to be used as scopes  (GCC: error)
   Visual C++  is half-hearted on the matter. (warrning)
2. C# support enumeration names as scopes.

Workaround: (for MS Visual Stdio)
if you want to get rid of those obnoxious error message and you're using MS Visual Studio, encompass your statement in #pragma directives. For example,

#progma warning(push)
#progma warning(disable : 4482)
... (your statement here) ...
#progma warning(pop)

That tells the compiler not to report the C4482 warning for the code within the block.
You are essentially saying to the compiler, "Yes, I'm doing this intentionally. I know it's not comply with the standard, but I want it done anyway. So build my project and quit your whining!"

 

阅读(1929) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~