1.vscode下载c/c++插件
2.vscode配置
新建项目文件夹,新建.vscode文件夹,添加以下json文件
- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/exe/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
- tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args":["-g", "${file}", "-o", "${workspaceFolder}/exe/${fileBasenameNoExtension}"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}