When I create a project in CodeLite 13.0.0 with clangd as the language server and add a foo.h and a foo.cpp, and add some C++ specific code in the header file, I'm getting errors in the border of the header file indicating there's something wrong with the code. The only sense I can make of these errors is that whatever is analyzing the file (I think it's clangd, but I can't really find a way to make sure other than that the errors disappear when I turn the LSP off) thinks the header file contains C code.
The LLVM version I'm using is 7.1. Here's how I configured the Language Server plugin:
and here's the errors I get in the header:
The other two errros on line 6 and 12 are
6: expected ';' after top level declarator
12: expected identifier or '('
foo.cpp only contains
Code: Select all
#include "foo.h"
void bar()
{
}
Code completion also does not work in the header file. Some other observations that may help:
Code completion in foo.cpp does work; I can include <memory> and if I type "std::u" a pop up with unique_ptr appears. No errors either. (I also noticed that including foo.h, which includes <memory>, does not cause unique_ptr to show up in the autocomplete pop up)
Here are the contents of the compile_commands.json and compile_flags.txt CodeLite generated in the workspace directory:
Code: Select all
[{
"file": "D:\\codelite_test_workspace_2\\main.cpp",
"directory": "D:\\codelite_test_workspace_2",
"command": "clang -c D:\\codelite_test_workspace_2\\main.cpp -o D:\\codelite_test_workspace_2\\main.cpp.o -target x86_64-pc-windows-gnu -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++ -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\x86_64-w64-mingw32 -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\backward -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include-fixed -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\x86_64-w64-mingw32\\include -DNDEBUG -I. -I. -O2 -Wall --std=c++14"
}, {
"file": "D:\\codelite_test_workspace_2\\foo.h",
"directory": "D:\\codelite_test_workspace_2",
"command": "clang -c D:\\codelite_test_workspace_2\\foo.h -o D:\\codelite_test_workspace_2\\foo.h.o -target x86_64-pc-windows-gnu -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++ -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\x86_64-w64-mingw32 -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\backward -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include-fixed -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\x86_64-w64-mingw32\\include -DNDEBUG -I. -I. -O2 -Wall --std=c++14"
}, {
"file": "D:\\codelite_test_workspace_2\\foo.cpp",
"directory": "D:\\codelite_test_workspace_2",
"command": "clang -c D:\\codelite_test_workspace_2\\foo.cpp -o D:\\codelite_test_workspace_2\\foo.cpp.o -target x86_64-pc-windows-gnu -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++ -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\x86_64-w64-mingw32 -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include\\c++\\backward -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\lib\\gcc\\x86_64-w64-mingw32\\6.1.0\\include-fixed -IC:\\Program Files\\mingw-w64\\x86_64-6.1.0-win32-seh-rt_v5-rev0\\mingw64\\x86_64-w64-mingw32\\include -DNDEBUG -I. -I. -O2 -Wall --std=c++14"
}]
Code: Select all
-IC:\Program
-ID:\codelite_test_workspace_2
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include\c++"
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include\c++\x86_64-w64-mingw32"
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include\c++\backward"
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include"
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include-fixed"
-I"C:\Program Files\mingw-w64\x86_64-6.1.0-win32-seh-rt_v5-rev0\mingw64\x86_64-w64-mingw32\include"
-DNDEBUG
-target
x86_64-pc-windows-gnu
Any idea how I can get C++ code completion to work for my headers?
Is there any other information I could provide that could help resolve this?
Thanks!