Emacs – ccls:在命名空间“std”中没有名为“filesystem”的成员。

huangapple go评论78阅读模式
英文:

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

这是问题的屏幕截图。我猜coutfilePath的错误是第一个错误的结果,因为总体上一切都很好。

屏幕截图

有人知道如何解决这个问题吗?

英文:

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 &#39;filesystem&#39; in namespace &#39;std&#39;

A quick sample of my problem

#include &lt;iostream&gt;
#include &lt;filesystem&gt;

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

Compilation and runtime are totally fine using this command :

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

Output : &quot;sample.cpp&quot;

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 ?

答案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!

huangapple
  • 本文由 发表于 2020年1月7日 02:36:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/59617237.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定