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

  • Thanks for the info. but what about ```std::experimental::filesystem``` (which is what i'm using now), when was it introduced? –  Dec 22 '19 at 14:52
  • Be warned that using `experimental/filesystem` is [a bit different](https://stackoverflow.com/q/40899267/8586227) from the C++17 version. – Davis Herring Dec 22 '19 at 16:36
  • That's interesting. i guess i'll have to invest some more time studying the implementation to avoid extra debugging sessions! –  Dec 22 '19 at 17:11

1 Answers1

1

I note that GCC is a compiler system that is separate and distinct from the Standard Library ( https://gcc.gnu.org/onlinedocs/gcc/Standard-Libraries.html ).

That said, GCC 8.0 includes the std::filesystem library - but your project needs to be in C++17 mode to use it.

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

Table 3.9, “C++ 2020 Library Headers”

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

shows the C++17 include files. These are available in C++17 compilation mode, i.e. -std=c++17 or -std=gnu++17. Including these headers in earlier modes will not result in compilation errors, but will not define anything. Unless specified otherwise below, they are also available in later modes (C++20 etc).

w.r.t. your specific question:

Thanks for the info. but what about std::experimental::filesystem (which is what i'm using now), when was it introduced?

The release history for G++ says it was included in version 8.x (bold emphasis mine):

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

Improved experimental support for C++17, including the following features:

  • Deduction guides to support class template argument deduction.
  • std::filesystem implementation.
  • std::char_traits<char> and std::char_traits<wchar_t> are usable in constant expressions.
  • std::to_chars and std::from_chars (for integers only, not for floating point types).
Dai
  • 141,631
  • 28
  • 261
  • 374