保姆级别VsCode C/C++配置指南: step-by-step教程,紧跟官方文档 -详解launch.json设置
最编程
2024-08-01 12:54:41
...
接下来,我们进一步进行配置。该配置是针对于程序运行的,点击Run(运行)->Add Configuration(添加配置),这样会在.vscode文件夹中生成launch.json文件,我们打开并输入如下代码:
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
注意:其中"miDebuggerPath": 后的内容需要根据自己电脑中的实际路径修改,其中"externalConsole": false 表明程序运行时的输入和输出的窗口将在界面下方的终端,将其false改为true将在黑框中输入和输出