当std :: filesystem头文件添加到我的程序时,编译错误 [英] Compile error when std::filesystem header file is added to my program

查看:496
本文介绍了当std :: filesystem头文件添加到我的程序时,编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译一个包含std :: filesytem头文件的简单C ++程序!

I am trying to compile a simple C++ program with std::filesytem header file included!

#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}\CLionProjects\untitled3\main.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()))
                               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

我在使用MingW 8.1.0和Clion作为IDE的Windows操作系统上 并如 https://en.cppreference.com/w/cpp/compiler_support似乎GCC 8.1已经支持std:fileystem

I am on windows OS using MingW 8.1.0 and Clion as the IDE and as depicted on this https://en.cppreference.com/w/cpp/compiler_support seems like GCC 8.1 already supports std:fileystem

工具链配置

语言级别在我的CMakeList中设置,如下所示

Language level is set in my CMakeList as shown below

set(CMAKE_CXX_STANDARD 17)

推荐答案

我在使用MingW 8.1.0和Clion作为IDE的Windows操作系统上

I am on windows OS using MingW 8.1.0 and Clion as the IDE

我最近才实现了对std::filesystem的MinGW支持,它在GCC 8中不存在.目前仅在GCC转换主干中可用.

I only implemented the MinGW support for std::filesystem recently and it's not present in GCC 8. It's currently only available in the GCC subversion trunk.

,并在此 https://en.cppreference.com/w/cpp/编译器支持似乎GCC 8.1已经支持std:fileystem

and as depicted on this https://en.cppreference.com/w/cpp/compiler_support seems like GCC 8.1 already supports std:fileystem

仅适用于非Windows平台. Windows支持与POSIX支持非常不同,并且需要做很多额外的工作.

Only for non-Windows platforms. The Windows support is very different to the POSIX support and took a lot of extra work.

这篇关于当std :: filesystem头文件添加到我的程序时,编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆