views:

113

answers:

2

Using Visual Studio .NET 2003 C++ and the wininet.dll Am seeing many C4995 warnings

More info

Any help is appreciated.

Thanks.

+3  A: 

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.

James McNellis
Any other way around these without disabling from the code or settings? thank you.
Tommy
@Tommy: The compiler gets two inputs: a set of command line arguments and your source files. If you want to tell it to do something, you have to do so in one of those two places.
James McNellis
+3  A: 

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)
Scott Smith
thank you......
Tommy
Just to note that you can also disable multiple warnings in one preprocessor directive: `#pragma warning(disable: 4018 4100)`. That having been said, I _really_ like how you put the reason for disabling each warning next to it.
James McNellis