2

I'm using GCC 7.4.0 and clang 6.0.0 and they both seem to have an implementation of filesystem in <experimental/filesystem>.

since the project that i'm working on requires std::filesystem, i want to know which versions (Major + Minor) of them support it, and in which versions is it implemented in <experimental/filesystem> and <filesystem>.

so that i can handle the #includes and namespaces correctly, and also throw in some #ifs to avoid trying to compile the project with an unsupported version of the compilers

4

1 回答 1

1

我注意到 GCC 是一个独立于标准库 ( https://gcc.gnu.org/onlinedocs/gcc/Standard-Libraries.html ) 的编译器系统。

也就是说,GCC 8.0 包含该std::filesystem库 - 但您的项目需要处于 C++17 模式才能使用它。

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_headers.html#manual.intro.using.headers.cheaders

表 3.9,“C++ 2020 库头文件”</p>

  • any
  • charconv
  • execution
  • filesystem
  • memory_resource
  • optional
  • string_view
  • variant

显示 C++17 包含文件。这些在 C++17 编译模式下可用,即-std=c++17-std=gnu++17. 在早期模式中包含这些头文件不会导致编译错误,但不会定义任何内容。除非下面另有说明,否则它们也可用于后续模式(C++20 等)。

wrt你的具体问题:

谢谢(你的)信息。但是呢std::experimental::filesystem(这是我现在正在使用的),它是什么时候引入的?

G++ 的发布历史说它包含在版本 8.x 中(粗体强调我的):

https://gcc.gnu.org/gcc-8/changes.html

改进了对 C++17 的实验性支持,包括以下功能:

  • 支持类模板参数推导的推导指南。
  • std::filesystem执行。
  • std::char_traits<char>并且std::char_traits<wchar_t>可用于常量表达式。
  • std::to_charsstd::from_chars(仅适用于整数,不适用于浮点类型)。
于 2019-12-22T14:52:27.407 回答