Disable single warning error

#pragma warning( push )
#pragma warning( disable : 4101)
// Your function
#pragma warning( pop ) 

If you only want to suppress a warning in a single line of code (after preprocessing)[1], you can use the suppress warning specifier:

#pragma warning(suppress: 4101)
// here goes your single line of code where the warning occurs

For a single line of code, this works the same as writing the following:

#pragma warning(push)
#pragma warning(disable: 4101)
// here goes your code where the warning occurs
#pragma warning(pop)

[1] Others have noted in comments below that if the following statement is an #include statement that the #pragma warning(suppress: 4101) statement would not effectively suppress the warning for every line in the header file. If one were intending to do that, one would need to utilize the push/disable/pop method instead.


#pragma push/pop are often a solution for this kind of problems, but in this case why don't you just remove the unreferenced variable?

try
{
    // ...
}
catch(const your_exception_type &) // type specified but no variable declared
{
    // ...
}

Use #pragma warning ( push ), then #pragma warning ( disable ), then put your code, then use #pragma warning ( pop ) as described here:

#pragma warning( push )
#pragma warning( disable : WarningCode)
// code with warning
#pragma warning( pop )