淡朴若水

死胖子

[转载]warning C4482: 使用了非标准扩展: 限定名中使

来源: http://dev.firnow.com/course/3_program/c++/cppsl/2008619/126863.html

 虽然只是一个warning,但是看起来很不爽。。。。

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,

#pragma warning(push)
#pragma warning(disable : 4482)
... (your statement here) ...
#pragma 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!”

作者: 龖哥 发表于 2011-11-16 11:00 原文链接

评论: 0 查看评论 发表评论


最新新闻:
· 苹果感恩节促销方案曝光:iPad降价61美元(2011-11-24 08:16)
· 欧盟有条件批准西部数据收购日立硬盘业务(2011-11-24 08:15)
· iPad从1300英尺坠落依然毫发无伤 保护套立功(2011-11-24 08:15)
· Eclipse Xtend对Java说:我帮你瘦身(2011-11-24 07:47)
· 传微软已与雅虎签保密协议开始进行收购前审查(2011-11-24 07:43)

编辑推荐:用JavaScript编写一个Java虚拟机?谈谈哗众取宠的BicaVM

网站导航:博客园首页  我的园子  新闻  闪存  博问  知识库

posted on 2011-11-16 11:00 龖哥 阅读(1281) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜