How to Set VC++ Warning Level 4 in Visual Studio

A few small extra steps at the beginning, that will save you lots of time and headaches during C++ project development!

One of the very first things I do after creating a new C++ project in Visual Studio is setting the Visual C++ compiler warning level 4. I consider this a best practice when writing C++ code compiled with the Microsoft Visual C++ compiler. In fact, I prefer having the VC++ compiler speak out more frequently, as it helps finding bugs (and fixing them) earlier in the development cycle.

To do so, in the Solution Explorer view in Visual Studio, right click on your C++ project name, and select Properties from the menu.

Project name in Solution Explorer inside Visual Studio.
Right-click on the project name in Solution Explorer in Visual Studio…

Select the Properties menu item to show the project's properties dialog box.
…then select the project Properties menu item.

The dialog box showing the project’s properties will appear.

In Configuration Properties on the left, select C/C++. Then change the Warning Level property from the default Level3 (/W3) to Level4 (/w4). Confirm clicking the OK button.

Setting the Warning Level property in the project properties dialog box in Visual Studio to Level4 (/W4).
Setting the Warning Level property to Level4 (/W4).

Enjoy your C++ project development!

I wish the warning level 4 was the default setting in Visual Studio for C++ projects! For me, this would adhere to the philosophy of having good defaults.