问题描述
我正在尝试编译一个包含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 IDEand 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)
推荐答案
我最近才实现了对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.
仅适用于非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头文件添加到我的程序时,编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!