MacOS VSCode C++环境配置

环境要求

  • 软件:
    • Xcode
    • VSCode
  • 插件:
    • C/C++
    • Code Runner
    • CodeLLDB

配置文件

c_cpp_properties.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

launch.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

tasks.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"version": "2.0.0",
"tasks": [
{
"label": "Build with Clang",
"type": "shell",
"command": "clang++",
"args": [
"${file}",
"-std=c++11",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out",
"-g",
"--debug"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}