user10777785
user10777785

Reputation:

Which versions of GCC and clang support std::filesystem/std::experimental::filesystem?

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

Upvotes: 3

Views: 2239

Answers (1)

Dai
Dai

Reputation: 155708

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).

Upvotes: 1

Related Questions