C ++ 17 Support Eclipse Neon

I read here that C ++ 17 is completely augmented, although the specifications are not yet completely ready. How to use C ++ 17 functions in my code, especially in Eclipse CDT (Neon)?

In particular, I would like to use filesystem to be able to easily iterate over directories.

+5
source share
2 answers

Both lib ++ and libstd ++ have std::experimental::filesystem in recent versions. I do not know that I have std::filesystem ; C ++ 17 has not yet been released, which seems reasonable.

boost has boost::filesystem , which differs in several ways, but is structured almost identically. Code written to use boost::filesystem can be relatively easily ported to std::filesystem .

As an example of incompatibility, boost has an exclusive flag jumper, and std has a multiple field listing a multiple flag with additional settings.

You may need to pass -std=c++1z to the compiler, check the version of libc++ or libstdc++ , switch the one you are using, install a new one, etc. Or install boost and use your file system library, which C ++ 17s was based on.

+7
source

Although std::filesystem planned for C ++ 17, current compiler implementations do not yet send official support for C ++ 17. Since Yakk is already indicated in the answer, the latest versions of the compiler and standard version of the C ++ library have std::experimental::filesystem .

At least for the GNU g++ I can say that you don’t even need to install a dialect of C ++ 17, just use C ++ 14! However, you need to link the (static) libstdc++fs.a additionally.

In addition, it is then quite convenient to define the namespace std::filesystem , so you can use the headers (almost) as if they were already completed:

 // ... #include <experimental/filesystem> namespace std { namespace filesystem = std::experimental::filesystem; } // now use std::filesystem ... 

In short:

  • Let eclipse use the C ++ 1y dialogs (C ++ 14), that's enough
  • Link libstdc++fs.a
  • Enable <experimental/filesystem>
+1
source

All Articles