Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.82k stars 253 forks source link

Lexical or Preprocessor Issue: '<filename>.h' file not found #1333

Open zkytony opened 5 years ago

zkytony commented 5 years ago

I'm using emacs 25.1. I just installed the most recent RTags, 2.33.128. I'm also using flycheck-rtags and company-rtags.

RTag Diagnostics complains that:

path/to/code.cpp:2:10: error:
Lexical or Preprocessor Issue: '<header>.h' file not found

and the line of code incode.cpp #include <header.h> is marked with error (red). The error message is precisely RTags Diagnostics's complaint. Screenshot below: screenshot

However, this appears to be a wrong diagnostics, because I can still jump to that header file via rtags-find-symbol-at-point, I can even hit TAB and the header file's name will auto-complete. Also the code compiles without a problem.

So, what is going on? I failed to find similar issues online related to the Emacs use of RTags. Most issues (like this) seem to be about Xcode.

I have tried restarting rdm, and also running rc -J for the newly generated compile_commands.json file right after cmake. What seemed to have worked was I restarted the computer and the diagnostics goes away. But the diagnostics appeared again after I returned to my computer several hours later. This seems to make little sense, but I failed to capture how this issue reasonably happens.

Andersbakken commented 4 years ago

Can you check with rc --sources that the include path is correct?

ThrashAbaddon commented 4 years ago

@zkytony is there any update on this?

cburn11 commented 3 years ago

I run into this problem if the file that flycheck complains about is opened via rtags' "find-symbol-at-point" or rtags' "find-references-at-point". And running flycheck's "flycheck-compile" shows that header includes aren't being passed to clang in an "-I" arguments.

If the same file is opened via emacs' "find-file", flycheck does not complain about the header not being found, and include directories are properly passed to clang from flycheck.