Emacs - ccls : no member named "filesystem" in namespace "std"
Asked Answered
C

1

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 ?

Caneghem answered 6/1, 2020 at 18:36 Comment(7)
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.Mcalpine
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.Caneghem
*It does not solve the problem with compile_commands.json file. My badCaneghem
any updates on this?Behm
Try this is your terminal. $ ccls -index=$PWD in the top level project path where .ccls exists. and as @Mcalpine 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.Macnair
invoke (lsp-describe-session) to see that every thing is OK.Macnair
we really do need an update on this one.Enlistment
C
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!

Commencement answered 16/7, 2023 at 2:13 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.