Optimal Visual Studio Settings
February 12, 2019The default Visual Studio settings when you create a new project are fairly asinine. A lot of noise is generated during compilation, and files that you really don’t need are always polluting critical folders that you often navigate.
Some of the options I immediately change are shown below. It’s almost best to create a single empty project with your preferred Visual Studio settings applied, and then merely copy that project folder over and over, manually changing the names of the project files thereafter.
The very first thing I do is create two folders in the solution directory:
- bin (as in *nix systems, where your compiled files will go)
- src (naturally, where your source files will go)
I then change the Solution Explorer to “Show All Files”, so I can see these folders. The default view VS shows is a “filters” view where it filters External/Header/Resource/Source files based on file extension.
I then hop to the General tab and change the Output Directory and Intermediate Directory as such:
- Output Directory : $(SolutionDir)bin$(Configuration)\
- Intermediate Directory : $(SolutionDir)bin$(Configuration)\intermediates\
Next I change the working folder (for test file input, output, etc). The VS default on this is what grinds my gears the most; as the default is a different folder than where executables are compiled. Here we fix that (notice it matches the output directory above, now). Microsoft has this under a tab “Debugging” which is bit of a misnomer as it applies in both Release or Debug configurations.
- Configuration Properties –> Debugging –> Working Directory : $(SolutionDir)bin$(Configuration)\
The other thing that I always do is add _CRT_SECURE_NO_WARNINGS to my preprocessor define. _s functions may be deprecated soon anyhow; and it’s not even a warning, it’s a flat out compilation error.
- C/C++ –> Preprocessor –> Preprocessor Definitions : _CRT_SECURE_NO_WARNINGS
Another option I change is the generation of the .pdb file in Release configuration. For some reason this is Yes by default in Release config.
- Linker –> Debugging –> Generate Debug Info : No
If programming in C only, I make sure the compiler is setup for C (and not C++). This will just add a constraint that I don’t cheat and use some C++ feature.
- General –> C Language Standard : ISO C17 (2018) Standard (/std:c17)
- C/C++ –> Advanced-> Compile As : Compile as C Code (/TC)
Other stuff I usually poke at and check, especially if having unusual issues.
- C/C++ –> Precompiled Headers : Not Using Precompiled Headers
- C/C++ –> Runtime Library: Multi-threaded (/MT) (whatever you want, I usually do /MT for static linkage).
- Linker –> System –> SubSystem : {Console,Windows} (depending on the program, of course).
Lastly you may want to turn off deprecated warnings by adding the below to your source:
1#if defined( _WIN32 )
2#pragma warning(disable:4996)
3#endif
Alternatively,
- C/C++ –> Advanced –> Disable Specific Warnings : 4996.