VSCODE C++ IntelliSense为替代定义找到不相关的Yocto Sysroots

vscode c++ intellisense finds unrelated yocto sysroots for alternative definitions

本文关键字:不相关 Yocto Sysroots 定义 IntelliSense C++ VSCODE      更新时间:2023-10-16

我正在使用VsCode附带的cpptools,这个项目是使用yocto为嵌入式ARM开发的。对于开发,我在本地 x64 计算机上开发和测试。然后我通过yocto构建和部署。

我的问题是,我收到很多包含错误,因为 cpptools 从我的 yocto 系统根中找到了很多不同的替代包含。我将cpptools配置为使用我的本地compile_commands.json,并且我的IncludePath设置中也没有与yocto sysroots相关的内容。

这是我的c_cpp_properties.json

{
"configurations": [
{
"name": "Linux",
"includePath": [
"/usr/include"
],
"defines": [],
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "/path_to/compile_commands.json",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/g++"
}
],
"version": 4
}

由于我的yocto sysroot也没有在compile_commands.json任何地方提及,我不知道它是如何找到这些的。过去,出于对智能感知的沮丧,我在某个时候将yocto sysroots添加到IncludePath,但正如你所看到的,它现在被删除了。在那之后,我多次重新创建了智能感知数据库,它早就应该忘记了yocto sysroots。

问题仍然存在,cpptools如何找到我的yocto sysroots,以包含这些设置?这是由于过去捕获的设置或数据库未正确删除吗?

我仍然不知道为什么 VsCode 能够看到所有这些 yocto 文件夹以获取可能的包含路径,但遵循为我解决了问题。

为了能够在 VsCode 中使用智能感知cpptoolscompile_commands.json,您需要在路径中安装clangd。我已经安装了clangd-9但它没有符号链接到/usr/bin/clangd,我想这就是 VsCode 寻找它的地方。因此,只要确保您有有效的clangd/usr/bin/clangd

相关文章: