我当前的文件结构是:
├── 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