c_cpp_properties.json:
{
"version": 4,
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/library/developer/commandlinetools/library/frameworks" //(主要)
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools"
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - Build and debug active file", // 配置名称
"type": "lldb", // 配置类型
"request": "launch", // 请求配置类型,launch或者attach
"program": "${workspaceFolder}/build/ProjectName", // 进行调试程序的路径(主要)
"args": [], // 传递给程序的命令行参数,一般为空
"cwd": "${workspaceFolder}", // 项目目录
"preLaunchTask": "clang++ build active file" //每次调试前会自动编译
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build active file", //任务名
"command": "cd ./build ;cmake ../ ;make", //编译命令,更改(主要)
"args": [],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
本文详细介绍了如何使用VSCode进行C/C++项目的配置,包括c_cpp_properties.json文件中对编译器路径、标准及智能感知模式的设置;launch.json文件中的调试配置,如指定调试程序路径及预编译任务;以及tasks.json中的编译命令配置。
3720

被折叠的 条评论
为什么被折叠?



