我在使用make构建我的c++应用程序时遇到了一些问题。我有这样的c++代码:
#include <string>
#include <iostream>
#include <filesystem>
using namespace std;
namespace fs = std::filesystem;
int main()
{
auto iter = fs::directory_iterator(fs::current_path());
while(iter._At_end())
{
cout << iter->path() << endl;
}
return 0;
}我尝试使用命令:g++-9 -std=c++17 -Wall -Wextra -pthread -lstdc++fs -c -o main.o main.cpp编译目标文件,但出现以下错误:
main.cpp:12:16: error: ‘class std::filesystem::__cxx11::directory_iterator’ has no member named ‘_At_end’
12 | while(iter._At_end())
| ^~~~~~~所以,我不能使用std::filesystem命名空间的类的成员,但是如果我只想使用class(例如std::filesystem::path),那么一切都是可以的。
软件的版本:
g++-9 (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
GNU Make 4.2.1希望你能帮我。
发布于 2021-05-01 14:58:28
只要不使用_At_end(),一切都会好起来的。
https://stackoverflow.com/questions/67343574
复制相似问题