Abstract:
How to catch more bugs with MSVC++.

Created by Peter Kankowski
Last changed
Filed under Win32 programming

Share on social sitesReddit Digg Delicious Buzz Facebook Twitter

Enabling additional compiler warnings

You certainly heard the recommendation to set your compiler warnings to the highest possible level, and you probably follow it. It is a good advice, but many users of MSVC++ are unaware of additional warnings, which are disabled by default even if you use warning level 4 (/W4). You can find the full list of disabled warnings in MSDN; here are the most useful ones:

#pragma warning(default:4619) // wrong warning number in pragma
#pragma warning(default:4061) // enum value was not handled in switch
#pragma warning(default:4263) // wrong parameters count in the overloaded function
#pragma warning(default:4265) // the class has a virtual function,
                              // but the destructor is non-virtual
#pragma warning(default:4287) // negative constant is assigned to unsigned variable
#pragma warning(default:4296) // an unsigned variable is compared with zero
#pragma warning(default:4555) // no operation
#pragma warning(default:4347) // template function is called instead of the function
                              // with the same name
#pragma warning(default:4545 4546 4547 4548 4549) // various errors with comma operator
#pragma warning(default:4557) // assume with side effects
#pragma warning(default:4710) // inline function was not inlined
#pragma warning(default:4836) // local or unnamed type is used as an template argument
#pragma warning(default:4905) // L"abc" was converted to CHAR*
#pragma warning(default:4906) // "abc" was converted to WCHAR*

Finally, double-check that you have set "warning level 4" in the project properties!

Peter Kankowski
Peter Kankowski

About the author

Peter is the developer of Aba Search and Replace, a tool for replacing text in multiple files. He likes to program in C with a bit of C++, also in x86 assembly language, Python, and PHP.

Created by Peter Kankowski
Last changed

Leave your comment

Your name:


Comment: