【C/C++】M1 Arm64 MacBook Pro VScode配置C/C++

本文最后更新于:2022年1月3日上午9点14分

配置环境

机器:MacBook Pro 2021 M1pro

架构:Arm64

软件:vscode

插件:C/C++

安装clang

一般Mac是自带的

这个用Mac的homebrew一键安装即可

用下方命令检查即可:

1
clang --version

image-20220103091126416

launch.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - 生成和调试活动文件",
"type": "lldb",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "C/C++: clang++ 生成活动文件"
}
]
}

c_cpp_properties.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"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": "macos-clang-arm"
}
],
"version": 4
}

task.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"tasks": [
{
"type": "shell",
"label": "C/C++: clang++ 生成活动文件",
"command": "/usr/bin/clang++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
],
"version": "2.0.0"
}

配置结果

image-20220103091316392