I recall this trick working some time in the past, but it doesn't seem to be working now.
Putting #pragma warning(push, 0)
around #include
statements doesn't actually prevent /Wall
warnings from being generated from those included files.
Changing /Wall
to /W4
gets around the issue, but using /Wall
seems to be broken.
#pragma warning(push, 0)
#include <iostream>
#pragma warning(pop)
int main() {
std::cout << "Hello, World!";
}
Build output:
Microsoft Visual Studio Community 2017 Version 15.5.3
Full command line switches (generated from cmake):
/GS /TP /analyze- /Wall /Zc:wchar_t /Gm- /O2 /Ob2 /Fd"main.dir\Release\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX /Zc:forScope /GR /Gd /Oy- /MD /std:c++14 /Fa"Release/" /EHsc /nologo /Fo"main.dir\Release\" /Fp"main.dir\Release\main.pch" /diagnostics:classic
I googled around and found a post that seems to describe the same issue, but no solution was suggested. Hopefully folks here on StackOverflow have a better idea?
C# provides a feature known as the #pragma feature to remove the warnings. Sometimes we declare a variable but do not use the variable anywhere in the entire program so when we debug our code the compiler gives a warning so using the #pragma we can disable these types of warnings.
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.
This appears to have been fixed for me in 15.9.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With