visual-studio-code - VSCode clangd 扩展找不到头文件
问题描述
我当前的文件结构是:
├── common
│ └── example.cc
├── compile_commands.json
├── include
└── common
└── example.hh
example.hh
: 留空
example.cc
:
#include "common/example.hh"
int main() {
return 0;
}
compile_commands.json
:
[
{
"directory": "/home/user/project",
"file": "/home/user/project/common/example.cc",
"arguments": [
"/usr/bin/clang++",
"-I /home/user/project/include",
"-o example",
"/home/user/project/common/example.cc"
],
"output": "example"
}
]
打开example.cc
时会报错:
'common/example.hh' file not found clang(pp_file_not_found)
我直接运行命令,它工作正常:
$ /usr/bin/clang++ -I /home/user/project/include -o example /home/user/project/common/example.cc
环境信息:
$ clang++ --version
clang version 10.0.0-4ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
VS代码:1.47.3
vscode-clangd:0.1.7
解决方案
推荐阅读
- java - 对象使用 lambda 调用自己,困惑
- android - 在 Android 中不调用 React Native getInitialURL()
- javascript - 为什么 Visuall Studio Code 会自动添加 {" "}?
- python - 如何使用 POST 请求数据通过 pymongo 查找数据
- javascript - 用 jQuery 删除括号
- android - 从异步任务访问 UI 数据
- php - 如何从 Doctrine 2 中的实体创建表
- pie-chart - 谷歌饼图中的自定义切片
- javascript - Angular CDK - 在嵌套的可滚动 div 内滚动和拖动元素的问题
- c# - 剃刀视图@Html.RadioButtonFor