英文:
Emacs - ccls : no member named "filesystem" in namespace "std"
问题
Arch Linux用户在Emacs中使用C++ IDE,使用以下设置:company / flycheck / lsp-ui / ccls
我尝试在个人项目中使用C++17的filesystem
库,但无法在Emacs中摆脱这个错误:
ccls:在命名空间std中没有名为'filesystem'的成员
以下是我的问题的快速示例:
#include <iostream>
#include <filesystem>
int main(int argc, char** argv) {
std::filesystem::path filePath("./sample.cpp");
std::cout << filePath.filename() << std::endl;
return 0;
}
使用以下命令进行编译和运行完全正常:
clang++ -std=c++17 sample.cpp
输出:"sample.cpp"
但在Emacs中仍然存在"错误",这有点让人讨厌。我尝试添加了一个.ccls
文件,其中包含以下内容,但这并不能解决问题。
clang++
%cpp -std=c++17 ; 也尝试使用gnu++17
这是问题的屏幕截图。我猜cout
和filePath
的错误是第一个错误的结果,因为总体上一切都很好。
有人知道如何解决这个问题吗?
英文:
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
Does anybody know how to solve the problem ?
答案1
得分: 2
我遇到了一个类似的问题,使用 nvim + Ale + LanguageClient-neovim。我成功使用 clang++ 和 -std=c++20 标志编译了我的代码。然而,我无法摆脱 nvim 中的错误消息,指示它找不到导入的成员。我甚至构建了我的 .ccls 文件,但问题没有解决。
后来,我意识到虽然我已经配置了 LanguageClient,但我忽视了配置我的代码检查器(Ale)。所以,也许值得检查一下你的代码检查器是否也设置为使用 c++20。希望这个建议对你有帮助!
英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论