vscode-clangd
vscode-clangd copied to clipboard
wrong pp_file_not_found
clangd hint me In included file: 'Eigen/Core' file not foundclang(pp_file_not_found)
but my compile_commands.json clear include the eigen package
"command": "/usr/bin/g++-8 -DFMT_HEADER_ONLY=1 -DPYTHON_API -DVERSION_INFO=1.6.8 -Dfnode_EXPORTS -I/home/wjp/fcxx/src -I/home/wjp/fcxx/3rd_part/json/include -I/home/wjp/fcxx/include -I/home/wjp/fcxx/3rd_part/flatbuffers/include -I/home/wjp/fcxx/3rd_part/fmt-9.1.0/include -isystem /home/wjp/anaconda3/envs/py38/include/python3.8 -isystem /home/wjp/fcxx/pybind11/include -isystem /home/wjp/.conan2/p/eigen3d88c0279cc26/p/include/eigen3 -isystem /home/wjp/.conan2/p/unordf3dbc8bb27345/p/include -Wall -Wno-sign-compare -m64 -O3 -DNDEBUG -std=gnu++17 -fPIC -fvisibility=hidden -fdiagnostics-color=always -march=x86-64 -flto -mavx2 -mfma -finline-limit=1000000 -ffp-contract=fast -fopenmp -fno-fat-lto-objects ",
simplify
-isystem /home/wjp/.conan2/p/eigen3d88c0279cc26/p/include/eigen3
Please attach clangd logs from a session in which you get this diagnostic.
similar question on windows, msvc 2022, this is the simple code
#include <boost/chrono.hpp> // always report not found, but compile is ok, and file jump is also ok
#include <iostream>
int main()
{
boost::chrono::nanoseconds ns;
return 0;
}
this is the output log
I[13:00:55.723] <-- textDocument/codeAction(672)
I[13:00:55.755] ASTWorker building file d:\WorkSpace\cpptest\c20\main.cpp version 138 with command
[d:\WorkSpace\cpptest]
"D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\Hostx64\\x64\\cl.exe" --driver-mode=cl /c /nologo /Zi /FS "/Fdbuild\\windows\\x64\\debug\\compile.Test.pdb" /Od /std:c++20 /MDd /EHsc /utf-8 "/IC:\\Users\\remy\\AppData\\Local\\.xmake\\packages\\b\\boost\\1.81.0\\3cb4c295f7064257892dadec1010aab1\\include" "/Fobuild\\.objs\\Test\\windows\\x64\\debug\\c20\\main.cpp.obj" "-resource-dir=D:\\env\\llvm\\lib\\clang\\17" -- "d:\\WorkSpace\\cpptest\\c20\\main.cpp"
V[13:00:55.782] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-msvc19.37.32824 -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_DEBUG -D_MT -D_DLL --dependent-lib=msvcrtd --dependent-lib=oldnames -stack-protector 2 -fcxx-exceptions -fexceptions -fexternc-nounwind -fms-volatile -fdiagnostics-format msvc -gno-column-info -gcodeview -debug-info-kind=constructor "-fcoverage-compilation-dir=d:\\WorkSpace\\cpptest" -resource-dir "D:\\env\\llvm\\lib\\clang\\17" -I "C:\\Users\\remy\\AppData\\Local\\.xmake\\packages\\b\\boost\\1.81.0\\3cb4c295f7064257892dadec1010aab1\\include" -internal-isystem "D:\\env\\llvm\\lib\\clang\\17\\include" -internal-isystem "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\include" -internal-isystem "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt" -O0 -fdeprecated-macro "-fdebug-compilation-dir=d:\\WorkSpace\\cpptest" -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.37.32824 -std=c++20 -fdelayed-template-parsing -fno-implicit-modules -no-round-trip-args -faddrsig -x c++ "d:\\WorkSpace\\cpptest\\c20\\main.cpp"
I[13:00:55.782] --> textDocument/clangd.fileStatus
V[13:00:55.782] >>> {
"jsonrpc": "2.0",
"method": "textDocument/clangd.fileStatus",
"params": {
"state": "parsing includes, parsing main file",
"uri": "file:///d:/WorkSpace/cpptest/c20/main.cpp"
}
}
V[13:00:55.784] Rebuilding invalidated preamble for d:\WorkSpace\cpptest\c20\main.cpp version 138 (previous was version 137)
V[13:00:55.819] <<< {
"id": 673,
"jsonrpc": "2.0",
"method": "textDocument/foldingRange",
"params": {
"textDocument": {
"uri": "file:///d%3A/WorkSpace/cpptest/c20/main.cpp"
}
}
}
I[13:00:55.819] <-- textDocument/foldingRange(673)
I[13:00:55.913] --> reply:textDocument/foldingRange(673) 93 ms
V[13:00:55.914] >>> {
"id": 673,
"jsonrpc": "2.0",
"result": [
{
"endLine": 6,
"kind": "region",
"startCharacter": 1,
"startLine": 4
}
]
}
E[13:00:56.016] IncludeCleaner: Failed to get an entry for resolved path : no such file or directory
I[13:00:56.024] --> textDocument/clangd.fileStatus
V[13:00:56.024] >>> {
"jsonrpc": "2.0",
"method": "textDocument/clangd.fileStatus",
"params": {
"state": "parsing includes, parsing main file",
"uri": "file:///d:/WorkSpace/cpptest/c20/main.cpp"
}
}
V[13:00:56.024] indexed file AST for d:\WorkSpace\cpptest\c20\main.cpp version 138:
symbol slab: 1 symbols, 4456 bytes
ref slab: 3 symbols, 3 refs, 4304 bytes
relations slab: 0 relations, 24 bytes
V[13:00:56.024] Build dynamic index for main-file symbols with estimated memory usage of 20624 bytes
I[13:00:56.024] --> textDocument/publishDiagnostics
V[13:00:56.024] >>> {
"jsonrpc": "2.0",
"method": "textDocument/publishDiagnostics",
"params": {
"diagnostics": [
{
"code": "pp_file_not_found",
"message": "'boost/chrono.hp' file not found",
"range": {
"end": {
"character": 26,
"line": 0
},
"start": {
"character": 9,
"line": 0
}
},
"relatedInformation": [],
"severity": 1,
"source": "clang"
},
{
"code": "unused-includes",
"codeDescription": {
"href": "https://clangd.llvm.org/guides/include-cleaner"
},
"message": "Included header iostream is not used directly (fix available)",
"range": {
"end": {
"character": 19,
"line": 1
},
"start": {
"character": 0,
"line": 1
}
},
"relatedInformation": [],
"severity": 2,
"source": "clangd",
"tags": [
1
]
}
],
"uri": "file:///d:/WorkSpace/cpptest/c20/main.cpp",
"version": 138
}
}
i'm sure compile is ok, but the intellisense always not found, the file jump is also ok.
I tried it by command line,
D:\WorkSpace\cpptest>clangd --check=c20/main.cpp
I[12:56:05.515] clangd version 17.0.1
I[12:56:05.518] Features: windows
I[12:56:05.518] PID: 34248
I[12:56:05.519] Working directory: D:\WorkSpace\cpptest
I[12:56:05.519] argv[0]: clangd
I[12:56:05.520] argv[1]: --check=c20/main.cpp
I[12:56:05.532] Entering check mode (no LSP server)
I[12:56:05.533] Testing on source file D:\WorkSpace\cpptest\c20\main.cpp
I[12:56:05.537] Loading compilation database...
I[12:56:05.544] Failed to find compilation database for D:\WorkSpace\cpptest\c20\main.cpp
I[12:56:05.545] Generic fallback command is: [D:\WorkSpace\cpptest\c20] "D:\\env\\llvm\\bin\\clang" "-IC:\\Users\\remy\\AppData\\Local\\.xmake\\packages\\b\\boost\\1.81.0\\3cb4c295f7064257892dadec1010aab1\\include" "-resource-dir=D:\\env\\llvm\\lib\\clang\\17" -- "D:\\WorkSpace\\cpptest\\c20\\main.cpp"
I[12:56:05.547] Parsing command...
I[12:56:05.576] internal (cc1) args are: -cc1 -triple x86_64-pc-windows-msvc19.37.32824 -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic "-fcoverage-compilation-dir=D:\\WorkSpace\\cpptest\\c20" -resource-dir "D:\\env\\llvm\\lib\\clang\\17" -I "C:\\Users\\remy\\AppData\\Local\\.xmake\\packages\\b\\boost\\1.81.0\\3cb4c295f7064257892dadec1010aab1\\include" -internal-isystem "D:\\env\\llvm\\lib\\clang\\17\\include" -internal-isystem "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\include" -internal-isystem "D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\cppwinrt" -fdeprecated-macro "-fdebug-compilation-dir=D:\\WorkSpace\\cpptest\\c20" -ferror-limit 19 -fmessage-length=228 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.37.32824 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -x c++ "D:\\WorkSpace\\cpptest\\c20\\main.cpp"
I[12:56:05.580] Building preamble...
I[12:56:06.634] Built preamble of size 10749568 for file D:\WorkSpace\cpptest\c20\main.cpp version null in 1.05 seconds
I[12:56:06.635] Indexing headers...
I[12:56:06.970] Building AST...
I[12:56:07.025] Indexing AST...
I[12:56:07.026] Building inlay hints
I[12:56:07.027] Building semantic highlighting
I[12:56:07.028] Testing features at each token (may be slow in large files)
I[12:56:07.037] All checks completed, 0 errors
looks like no problem.
and I have disabled C_Cpp tools, this is my vscode setting.json
// cpp
"C_Cpp.codeAnalysis.runAutomatically": false,
"C_Cpp.intelliSenseEngine": "disabled",
"C_Cpp.formatting": "disabled",
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.autocompleteAddParentheses": false,
"C_Cpp.autocomplete": "disabled",
"C_Cpp.errorSquiggles": "disabled",
// clangd
"clangd.path": "clangd",
"clangd.arguments": [
"--all-scopes-completion",
"--background-index",
"--clang-tidy",
"--all-scopes-completion",
"--completion-parse=auto",
"--completion-style=detailed",
"--header-insertion=iwyu",
"--pch-storage=disk",
"--log=verbose",
"--j=6",
"--fallback-style=Google",
"--compile-commands-dir=${workspaceFolder}/.vscode",
"--pretty"
],
any idea? thanks.
this is my compile_commands.json.
[
{
"directory": "d:\\WorkSpace\\cpptest",
"arguments": [
"D:\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\cl.exe",
"/c",
"/nologo",
"/Zi",
"/FS",
"/Fdbuild\\windows\\x64\\debug\\compile.Test.pdb",
"/Od",
"/std:c++20",
"/MDd",
"/EHsc",
"/utf-8",
"/IC:\\Users\\remy\\AppData\\Local\\.xmake\\packages\\b\\boost\\1.81.0\\3cb4c295f7064257892dadec1010aab1\\include",
"/Fobuild\\.objs\\Test\\windows\\x64\\debug\\c20\\main.cpp.obj",
"c20\\main.cpp"
],
"file": "c20\\main.cpp"
}
]
@shxygray Please file a new issue for further discussion of your Boost-related error. The OP's issue is about a different library (Eigen) on a different platform (Linux), and it just confuses things to be diagnosing different issues in the same thread.
In your logs:
"message": "'boost/chrono.hp' file not found",
suggests this diagnostic is from a state of the file where the last letter of chrono.hpp was not typed yet.
So, maybe it's a stale diagnostic? Is it still there if you restart clangd? If yes, please provide a new log that shows the diagnostic with the correct header spelling.
@HighCommander4 I resolved my problem, seem like the C/C++ Clang Command Adapter plugin cause it. I disabled the plugin, and now intellisense is fine.
otherwise, I tried it for wsl ubuntu, g++, the include hint is also "file not found", I don't know why, but now it works fine.