我正在尝试编译一个包含 std::filesytem 头文件的简单 C++ 程序!
#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
编辑:语言级别在我的 CMakeList 中设置,如下所示
set(CMAKE_CXX_STANDARD 17)