1 安裝插件
C/C++
CODELLDB
2 配置插件
cmd+shift+p 輸入 C/C++: Edit Configurations (UI)
其中
Compiler path 選 /usr/bin/gcc (不選clang)
IntelliSense mode 選 macos-gcc-x64 (不選clang)
3 工程目錄.vscode文件夾中
task.json
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ 生成活動文件",
"command": "/usr/bin/g++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-fdiagnostics-color=always",
"-g",
"-Wall",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "調(diào)試器生成的任務(wù)。"
}
],
"version": "2.0.0"
}
launch.json
{
// 使用 IntelliSense 了解相關(guān)屬性僚祷。
// 懸停以查看現(xiàn)有屬性的描述你画。
// 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "C++ debug",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C/C++: g++ 生成活動文件"
}
]
}