[[deprecated]]枚举类型或枚举值没有警告 [英] No warning for [[deprecated]] enum type or enum value

查看:92
本文介绍了[[deprecated]]枚举类型或枚举值没有警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual C ++专家,


根据C ++标准和这个MSDN页面,C ++ 17关键字[[deprecated]应该为enum类型或枚举值发出警告,因为Visual Studio 2015及更高版本。


https://docs.microsoft。 com / zh-cn / cpp / cpp / attributes2


但是当我在Visual Studio 2015中编译以下代码时RTM / Update 3或Visual Studio 2017 Update 2,没有弃用的警告信息。


--------- --------------------------------------------------



#include
< span style ="font-size:9.5pt; font-family:Consolas; color:#A31515">" stdafx.h"





enum [[不赞成]]
E {



    foobar [[不赞成]],



    foobat



};





E e =
E :: foobat ;





int main()



{



    E a =
E :: foobar ;



   & a;



   



返回 0



}



解决方案

您好,


编译器将抛出C4996警告。也许您的编译器设置会隐藏此警告,例如,如果您已定义_CRT_SECURE_NO_WARNINGS。


看看这个:
https://msdn.microsoft.com/en-us/library/ttcz0bys.aspx


<问候,Guido


Hi Visual C++ expert,

According to C++ standard and this MSDN page, C++ 17 key word [[deprecated] should emit warning for enum type or enum value since Visual Studio 2015 and later.

https://docs.microsoft.com/en-us/cpp/cpp/attributes2

But when I compiled the following code in Visual Studio 2015 RTM/Update 3 or Visual Studio 2017 Update 2, there was no deprecated warning information.

-----------------------------------------------------------

#include "stdafx.h"

enum [[deprecated]] E {

    foobar [[deprecated]],

    foobat

};

E e = E::foobat;

int main()

{

    E a = E::foobar;

    &a;

   

return 0

}

解决方案

Hello,

the compiler will throw a C4996 warning. Maybe your compiler settings hide this warning, e.g. if you have defined _CRT_SECURE_NO_WARNINGS.

Have a look at this: https://msdn.microsoft.com/en-us/library/ttcz0bys.aspx

Regards, Guido


这篇关于[[deprecated]]枚举类型或枚举值没有警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆