There are several ways to disable the warning:
Project Properties->C/C++->General->Warning Level->select level
Here is the Warning Level
:
- Turn off all warnings (/W0): Turn off the display of all warning
messages. Level 1 (/W1): Display serious warning messages. Level 2
(/W2): Display level 1 warnings and some less serious warnings, such
as warnings about hidden class members. This is the default warning
level on the command line. Level 3 (/W3): Display level 2 warnings
and some less serious warnings, such as warnings about expressions
that always evaluate to true or false. Level 4 (/W4): Display all
level 3 warnings and informational warnings.
Or you could choose to disable specific warnings in Project Properties->C/C++->Advanced->Disable Specific Warnings
- You could use warning pragma.
Syntax:
#pragma warning(
warning-specifier : warning-number-list
[; warning-specifier : warning-number-list ... ] )
#pragma warning( push [ , n ] )
#pragma warning( pop )
Also, you could refer to Microsoft about How to: Enable and Disable Code Analysis for Specific C/C++ Warnings.
To enable or disable a code analysis warning
2.1.Create a header file that lists all the code analysis warnings and their initial state, as shown in the following code:
// WarningState.h
#pragma warning ( default : 6001 )
#pragma warning ( disable : 6011 )
// more warnings here
// end of file
2.2.Include WarningState.h in the application header file. In this case, MyApplication.h represents the header file.
// MyApplication.h file
#include "WarningState.h"
// ...
// end of file
2.3.Include MyApplication.h file in the source code file. In this case, MyApplication.cpp represents the source file.
// MyApplication.cpp file
#include "MyApplication.h"
2.4.To modify the warning state, use the pragma warning-specifier in a .cpp file, as shown in the following code:
// MyApplication.cpp file
#include "MyApplication.h"
#pragma warning ( disable: 6001 )
#pragma warning ( default : 6001 )
To disable all code analysis warnings for included third-party files
Add the following code to your header file.
#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
#include <third-party include files here>
#pragma warning( pop )