來源: 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)
|
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!”
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
