环境 mac m2
目标通过设置调试c++程序;
有关设置:
- task.json设置如下图所示:
```c++
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ 生成活动文件",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "调试器生成的任务。"
},
],
"version": "2.0.0"
}
- launch.json设置如下
{
"configurations": [
{
"name": "C/C++: clang++ 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ 生成活动文件"
}
],
"version": "2.0.0"
}
- c_cpp_properties.json 设置如下:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}
- 运行调试--输入过程中出现如下现象:
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/909725980586140.png "#left")