按下F5键,选择C++(GDB/LLDB)作为调试环境。
在出现的选项中选择“创建 tasks.json 文件”并配置编译任务。
在.vscode文件夹中创建launch.json文件,并配置调试启动设置。
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe"
],
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
若要调试则选择debug C/C++ File
调式的时候会自动生成demo文件