Is there a way to disable just a single warning line in a cpp file with Visual Studio?
For example, if I catch an exception and don't handle it, I get error 4101 (unreferenced local variable). Is there a way to ignore this just in that function, but otherwise report it in the compilation unit? At the moment, I put #pragma warning (disable : 4101)
at the top of the file, but that obviously just turns it off for the whole unit.
To disable the warning in a region of code with the warning
pragma:
#pragma warning( push )
#pragma warning( disable : 4101 )
// Your function
#pragma warning( pop )
To disable it in the entire compilation unit with a command line option use:
/wd4101