Enable a single warning in Visual Studio
If you want to turn it on (or off) in the project setting, you have to go to:
Configuration Properties -> C/C++ -> Command Line
and then under Additional Options you can enter:
/w3####
to set your warning to level 3, and thus enable it; or you can enter /wd####
to disable a warning.
Current (2015,2017,2019,...) Visual Studio Versions also have a dedicated setting to disable warnings under:
Configuration Properties -> C/C++ -> Advanced : Disable Specific Warnings
... is equivalent to /wd####
.
Also useful in recent versions: C/C++ -> All Options
and then filter for e.g. "warn".
It would appear that enabling á la /w3####
is not yet exposed explicitly.
Treat specific warning as error for C++ project in Visual Studio
Enter the numbers only, i.e. 4390
. For multiple warnings, enter them semicolon separated: 4390;4391
.
If you don't see it in the command line, click the "Apply" button.
In the command line, they will appear as /We"..."
.
How to enable CAxxxx warnings?
Code Analysis warnings are separate from compiler warnings, and are enabled on the "Code Analysis" tab in project properties.
Detailed instructions from MSDN:
- In Solution Explorer, right-click the project, and then click
Properties.- In the properties dialog box for the project, click Code
Analysis.- Specify the build type in Configuration and the target
platform in Platform.- To enable or disable automatic code analysis,
select or clear the Enable Code Analysis on Build check box.
Disable single warning error
#pragma warning( push )
#pragma warning( disable : 4101)
// Your function
#pragma warning( pop )
Enable/disable warnings, visual studio comand prompt
It's actually not a warning, but an error (about the warning being treated as an error). So either you fix the original warning (should be printed a bit earlier in the build log) or you modify the compiler options to not treat warnings as errors: remove the /WX
flag, or if the project file is msbuild based then set TreatWarningAsError
to false.
edit this is nmake based, remove -WX
from line 26 in CPP\Build.mak
Related Topics
Should I Inherit from Std::Exception
C++ Terminate Called Without an Active Exception
Std::This_Thread::Sleep_For Sleeps for Too Long
Why Do You Use Typedef When Declaring an Enum in C++
General Use Cases for C++ Containers
Generic Member Function Pointer as a Template Parameter
Sizeof in C++ Showing String Size One Less
C++ Class with Template Member Variable
What Should Std::Vector::Data() Return If the Vector Is Empty
Problems with Move Constructor and Move Overloaded Assignment Operator
Hooking Directx Endscene from an Injected Dll
Calculate Rolling/Moving Average in C++
C++ Warning: Address of Local Variable
How to Create a Template Function Within a Class? (C++)
Do All Virtual Functions Need to Be Implemented in Derived Classes