Wiki/Code/CPP/Visual-Studio-Settings.md

36 lines
2 KiB
Markdown
Raw Normal View History

2023-12-20 16:30:40 +01:00
# Visual Studio Dependencies
## Install dependencies
For developing C++ in Visual Studio 2022 on Windows 11 you have to install the _Desktop development with C++._ If you don't do this, the C++ capabilities will not be available.
![](/vsessentials.png)
## C++ Console Application
To create a C++ Console Application you have to create a new Project. In Visual Studio you select _Windows Desktop Wizard._ After naming the project the IDE opens the _Windows Desktop Project_ window. Make sure the Application type is on _Console Application (.exe)_ and that the _Precompiled Header_ option is unselected.
## Compiler Extensions
> **Best Practice**
>
> Disable compiler extensions to ensure your programs (and coding practice) remain compliant with C++ standards and will work on any System.
To do this you have to right click on your project name in the _Solution Explorer_ window, then choose _Properties_. First make sure the configuration is set to _All Configurations_. Then, click _C/C++ > Language tab,_ and set _Conformance mode _ to _Yes(/permissive-)._
## Warning and Error levels
> **Best Practice**
>
> Don't let warnings pile up. resolve them as you encounter them (as if they were errors). Otherwise a warning about a serious issue may be lost amongst warnings about non-serious issues.
You IDE can support you by handling the warnings. In the Solution Properties you can turn up your warning levels. To increase them, go to the _Properties_ of your solution and then you have to set for _All Configurations_ in _C/C++ > General _ then _Warning levels_ to _Level4 (/W4)_ and for more support the _Treat Warnings As Errors_ to _Yes (/WX)._
## Language standard
To select a language standard, open your solution properties, then open _C/C++ > Language._ Make sure the Configuration is set to _All Configurations._ From there, you can set the _C++ Language Standard_ to the version of C++ you wish to use.
> **Warning**
>
> With Visual Studio, you will need to reselect your language standard every time you create a new project.