我希望在代码中存在编译错误时不要启动调试器。这种情况发生在我成功构建时,然后我做了一些不编译的更改,当我启动调试器时,生成失败,但是调试器仍然用一个旧的可执行文件启动。
我知道Features -> Debug -> On task errors选项,但它不会改变这种行为。
我有最新版本的VS代码在Windows上,标准的C++扩展和混合。这是我的标准配置:
.code-workspace
{
"folders": [
{
"path": ".."
}
],
"settings": {
"debug.onTaskErrors": "abort"
}
}launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe debug build"
},
]
}tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe debug build",
"command": "D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": ["-std=c++17","-Wall","-Wextra","-D","LOCAL","-g","${file}","-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: \"D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe\""
},
]
}我还需要做什么?
发布于 2022-04-07 22:26:43
我创建了一个脚本,它首先删除二进制,然后运行编译。
如果生成失败,则不存在新的exe,调试器将无法启动。
https://stackoverflow.com/questions/70875803
复制相似问题