6

Archlinux user using Emacs as a C++ IDE with the following setup : company / flycheck / lsp-ui / ccls

I'm trying to use filesystem library from c++17 for personal use but I can't get rid of this error in Emacs

ccls : no member named 'filesystem' in namespace 'std'

A quick sample of my problem

#include <iostream>
#include <filesystem>

int main(int argc, char** argv) {
   std::filesystem::path filePath("./sample.cpp");
   std::cout << filePath.filename() < std::endl;
   return 0;
}

Compilation and runtime are totally fine using this command :

clang++ -std=c++17 sample.cpp

Output : "sample.cpp"

But the "error" is still present inside Emacs which is kind of annoying. I tried to add .ccls file with the following content but that doesn't solve the problem.

clang++
%cpp -std=c++17        ; Also tried with gnu++17

Here a screenshot of the problem. Error with cout and filePath are consequences of the first one I guess because everything is good in general

Screenshot

Does anybody know how to solve the problem ?

Cerclique
  • 61
  • 1
  • 6
  • For me, your `.ccls` file works. If you check out the buffer `*ccls::stderr*`, do you see a line like `22:14:20 ccls project.cc:284 I use /home/geza/st/.ccls: clang++ %cpp -std=c++17`? Btw., you can try the `compile_commands.json` way, it is easy to use, if you use `bear` to generate it. – geza Jan 06 '20 at 21:16
  • It seems I have no ouput in *ccls::stderr* buffer. The only information I found is this log before the error come `clang failed with error 1: /usr/bin/clang -fsyntax-only -Xclang -code-completion-macros -x c++ -Xclang -code-completion-at=-:8:6 -` I tried to generate `compile_commands.json` file with `bear` and the `makefile` i'm using but it does solve the problem. – Cerclique Jan 07 '20 at 20:54
  • *It does not solve the problem with compile_commands.json file. My bad – Cerclique Jan 07 '20 at 21:02
  • 1
    any updates on this? – Tooniis May 12 '20 at 01:44
  • Try this is your `terminal`. `$ ccls -index=$PWD` in the top level project path where `.ccls` exists. and as @geza wrote, you should read `... I use */.ccls ...`. I think your project setup isn't correct, so .ccls is in the wrong place or you selected another project path. – I.Omar Dec 26 '20 at 23:32
  • invoke `(lsp-describe-session)` to see that every thing is OK. – I.Omar Dec 26 '20 at 23:36
  • we really do need an update on this one. – Dragster Sep 11 '22 at 12:43

1 Answers1

2

I encountered a similar issue to the one you're facing, using nvim + Ale + LanguageClient-neovim. I managed to compile my code successfully using clang++ with the -std=c++20 flag. However, I couldn't get rid of the error message in nvim indicating that it couldn't find the imported member. I even built my .ccls file, but it didn't resolve the problem.

Later, I realized that while I had configured LanguageClient, I had overlooked configuring my linter (Ale). So, it might be worth checking if your linter is also set up to use c++20. Hopefully, this suggestion proves helpful to you!

André Augusto
  • 1,345
  • 1
  • 7
  • 10