Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clangd diagnostics can't include stl headers on Mac #159

Closed
maciejzj opened this issue Feb 14, 2020 · 1 comment · Fixed by #210
Closed

Clangd diagnostics can't include stl headers on Mac #159

maciejzj opened this issue Feb 14, 2020 · 1 comment · Fixed by #210

Comments

@maciejzj
Copy link

maciejzj commented Feb 14, 2020

I have installed clangd with :LspInstallServer but the diagnostic throws errors when I include any standard library files.
#include <string> results in:

main.cpp|1 col 10| clang:Error:pp_file_not_found:In included file: 'string.h' file not found /Users/maciej/.vim/bundle/vim-lsp-settings/servers/clangd/bin/../include/c++/v1/string.h:60:15: note: error     occurred here 

I took a look at the string in the .vim/bundle/vim-lsp-settings/servers/clangd/bin/../include/c++/v1/ and it fails at:

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#include_next <string.h>

with the diagnostics:

string.h|57 col 13| clang:Warning:-Wpragma-system-header-outside-header:#pragma system_header ignored in main file
string.h|57 col 13| clang:Warning:-Wpragma-system-header-outside-header:#pragma system_header ignored in main file
string.h|60 col 15| clang:Error:pp_including_mainfile_in_preamble:Main file cannot be included recursively when building a preamble

I am not sure whether it is my fault, something wrong with the vim-lip-settings or with the llvm code that is downloaded with the :LspInstallServer, but the c++ diagnostics doesn't work out of the box.

Also it results in very superficial autocompletion of stl, because the clangd can't parse the library and does not complete methods/members of classes.

@kjuq
Copy link
Contributor

kjuq commented Apr 3, 2020

It's caused by macos catalina removing /usr/include.
Clang 9.0 looks for header files in the path, but there is no such path.
Thus I updated clangd. The problem will be resolved after my PR: #210 accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants