C++配置c_cpp_properties.json
{
"env": {
"myIncludePath": [
"${workspaceFolder}/src/include",
"${workspaceFolder}/src",
"${workspaceFolder}",
"/home/xxx/include/"
],
"myDefines": [
"RELEASE",
"MY_FEATURE=1"
]
},
"configurations": [
{
"name": "arm-a40i-linux",
"compilerPath": "/home/xxx/linux/common/buildroot/host/usr//bin//arm-linux-gnueabihf-g++",
"compilerArgs": [
"--sysroot",
"/home/xxx/linux/common/buildroot/host/usr//arm-buildroot-linux-gnueabihf/sysroot/"
],
"intelliSenseMode": "linux-gcc-arm",
"includePath": [
"${myIncludePath}",
"/home/xxx/linux/common/buildroot/host/opt/ext-toolchain/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/include-fixed/",
"/home/xxx/linux/common/buildroot/host/opt/ext-toolchain/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/include",
"/home/xxx/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/",
"/home/xxx/linux/out/sun8iw11p1/linux/common/buildroot/host/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/Qt/"
],
"defines": [
"${myDefines}"
],
"cStandard": "c11",
"cppStandard": "c++11",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools",
"mergeConfigurations": true,
"browse": {
"path": ["${myIncludePath}", "${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db"
}
}
],
"version": 4,
"enableConfigurationSquiggles": true
}
C++跳转配置settings.json
{
"clangd.arguments": [
// 在后台自动分析文件(基于complie_commands)
"--background-index",
// 标记compelie_commands.json文件的目录位置
"--compile-commands-dir=build",
// 同时开启的任务数量
"-j=12",
// 告诉clangd用那个clang进行编译,路径参考which clang++的路径
"--query-driver=/usr/bin/clang++",
// clang-tidy功能
"--clang-tidy",
"--clang-tidy-checks=performance-*,bugprone-*",
// 全局补全(会自动补充头文件)
"--all-scopes-completion",
// 更详细的补全内容
"--completion-style=detailed",
// 补充头文件的形式
"--header-insertion=iwyu",
// pch优化的位置
"--pch-storage=disk"
],
"clangd.fallbackFlags": [
"-I${workspaceFolder}/include",
"-I/xxx/opt/ext-toolchain/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/include-fixed/",
"-I/xxx/opt/ext-toolchain/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/include",
"-I/xxx/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/",
"-I/xxx/usr/arm-buildroot-linux-gnueabihf/sysroot/usr/include/Qt/"
],
// "clangd.path": "the/path/to/clangd/executable/on/windows",
"clangd.detectExtensionConflicts": true,
"clangd.serverCompletionRanking": true,
"git.ignoreLimitWarning": true,
"clangd.path": "/usr/bin/clangd",
"files.associations": {
"qobject": "cpp"
},
}
参考文档
Ubuntu+Vscode使用Clangd进行项目代码跳转_ubuntu clangd-优快云博客