0%

VSCode 疑难杂症

MAC OSX VSCODE检测到 #INCLUDE 错误解决方法

终端输入:

1
g++ -v -E -x c++ -

CMD + Shift + P选择C/C++编辑配置(JSON) 把输出路径信息拷贝到c_cpp_properties.json

保存即可生效

(如果不小心点了禁用错误波形曲线 需按CMD + Shift + P搜索squiggles 点击C/C++:启用错误波形曲线)

MAC OSX VSCODE 调试设置(launch.json)

如果不想使用Mac系统自带的终端,可更改外部终端为iTerm2:在设置里搜索terminal.external.osxExec修改为iTerm.app

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"configurations": [
{
"name": "(lldb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ 生成活动文件"
}
]
}

MAC OSX VSCODE c_cpp_propertities.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"configurations": [
{
"name": "macos-clang-arm64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64",
"compilerArgs": [
""
]
}
],
"version": 4
}

MAC OSX VSCODE c_cpp_propertities.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ 生成活动文件",
"command": "/usr/bin/clang++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-std=c++17",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}

还是不能用集成终端或是iTerm运行、调试还是会被卡住(

抽空下载个Clion试试吧..