将 std::文件系统头文件添加到我的程序时出现编译错误
Compile error when std::filesystem header file is added to my program
我正在尝试编译一个简单的C++程序,其中包含std::filesytem头文件!
#include <iostream>
#include <filesystem>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
编译时出现以下错误
In file included from C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/filesystem:37,
from C:Users{User}CLionProjectsuntitled3main.cpp:2:
C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
C:/PROGRA~1/MINGW-~1/X86_64~2.0-W/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:237:47: error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')
|| (__p.has_root_name() && __p.root_name() != root_name()))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
我在Windows操作系统上使用MingW 8.1.0和Clion作为IDE。 正如这个 https://en.cppreference.com/w/cpp/compiler_support 所描述的,GCC 8.1似乎已经支持std:fileystem
工具链配置
编辑: 语言级别在我的CMakeList中设置,如下所示
set(CMAKE_CXX_STANDARD 17)
我在Windows操作系统上使用MingW 8.1.0和Clion作为IDE的Windows OS中
我最近才实现了对std::filesystem
的 MinGW 支持,它在 GCC 8 中不存在。它目前仅在 GCC Subversion 中继中可用。
正如这 https://en.cppreference.com/w/cpp/compiler_support 所描述的,GCC 8.1似乎已经支持std:fileystem
仅适用于非 Windows 平台。Windows支持与POSIX支持非常不同,并且需要大量额外的工作。
相关文章:
- 这是使用回溯的 nqueen 问题,但我使用了动态 2d 数组,我的程序编译良好,但不返回任何输出
- C ++程序编译错误,找不到/访问文件
- C++程序编译没有问题,但无法运行
- Mongdb C++ 驱动程序编译错误 for document{}.
- 添加类型名会导致程序编译失败
- 将 C 程序更改为 C++ 程序 - 编译错误
- 程序编译,但当分解为函数时实际上不会移动电机
- 如何链接 glib-2.0 库进行 c/c++ 程序编译
- 为什么 gcc 和 clang 为我的程序编译为不同的"const"结果?
- 复数程序编译时的计算方法错误
- qt 命令行应用程序编译
- 程序编译和运行,但一段时间后,它停止使用Typedef关键字在CPP上工作
- QML应用程序编译一个 *form.ui.qml文件,但忽略了关联的.qml文件
- 为什么该程序编译但不显示任何输出
- 分割故障程序编译为共享库,但不静态
- 程序编译,但我认为开关被忽略
- 程序编译后崩溃
- 什么是程序编译中的PIC级别
- 尽管使用不存在的成员,但程序编译
- C++程序编译在 Ubuntu 中失败,但在 MacOSX 中工作