开发者

What is the Win compile switch to turn off #pragma deprecated warning?

开发者 https://www.devze.com 2022-12-22 18:47 出处:网络
Using Visual Studio .NET 2003 C++ and the wininet.dll Am se开发者_运维问答eing many C4995 warnings

Using Visual Studio .NET 2003 C++ and the wininet.dll Am se开发者_运维问答eing many C4995 warnings

More info

Any help is appreciated.

Thanks.


In addition to the answer above, it's worth mentioning that it's often good practice to only disable a warning within a limited scope (this is especially important if you're placing these pragmas in header files):

#pragma warning (disable : 4121) // alignment of a member was sensitive to packing

#include <third-party-header.h>

#pragma warning (default : 4121) // Restore default handling of warning

Another way to do this is using a push/pop mechanism. This can be handy if you need to disable a bunch of warnings in 3rd-party header files:

#pragma warning(push)
#pragma warning(disable: 4018)  // signed/unsigned mismatch
#pragma warning(disable: 4100)  // unreferenced formal parameter
#pragma warning(disable: 4512)  // 'class' : assignment operator could not be generated
#pragma warning(disable: 4710)  // 'function' : function not inlined
#pragma warning(disable: 4503)  // decorated name length exceeded, name was truncated

#include <third-party-header1.h>
#include <third-party-header2.h>
#include <third-party-header3.h>
#include <third-party-header4.h>

#pragma warning(pop)


You can use #pragma warning as shown on that MSDN page:

#pragma warning(disable: 4995)

Or, you can turn the warning off for the whole project in the project's properties (right click project -> Properties -> C/C++ -> Advanced -> Disable Specific Warnings). On the command line, you can achieve the same effect using /wd4995.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号