Enable a Single Warning in Visual Studio

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.

Code Analysis tab on the project properties page

Detailed instructions from MSDN:

  1. In Solution Explorer, right-click the project, and then click
    Properties.
  2. In the properties dialog box for the project, click Code
    Analysis
    .
  3. Specify the build type in Configuration and the target
    platform in Platform.
  4. 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



Leave a reply



Submit