I wanted to start learning C++, but I noticed that debugging it in VSCode is kind of annoying to set up. On the Tutorial-Page it said I should start it via the developer console. Since I didnt want to do that, I searched a little and ended up with this solution:
tasks.json:
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
}
}
},
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
}
}
},
"configurations": [
{
"name": "Debug",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"console": "integratedTerminal",
"preLaunchTask": "cl.exe build active file"
}
]
}
This does work, but only if there are no spaces in the path. If there are, it gives this error:
Der Befehl "C:/Program" ist entweder falsch geschrieben oder konnte nicht gefunden werden.
(Sorry about the german, heres the translation: The command "C:/Program" is either not typed correctly or does not exist.)
I have tried to fix this but I just didnt get the issue. Any help is appreciated!