launch.json
用于在Visual Studio Code中配置调试器
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "E:\\MinGW\\mingw-w64\\mingw64\\bin\\gdb.exe",#修改自己的 gdb地址
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
launch 官方文档:https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
task.json
VS Code 中的任务可以配置为运行脚本和启动进程
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "E:\\MinGW\\mingw-w64\\mingw64\\bin\\g++.exe",#修改自己的g++地址
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Task 官方文档:https://code.visualstudio.com/docs/editor/tasks#vscode
C++ vs code 官方文档:
https://code.visualstudio.com/docs/cpp/introvideos-cpp