Advertisement
linuxlizard

Using __has_include to solve <filesystem>

Jan 6th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. // https://en.cppreference.com/w/cpp/feature_test
  2. #ifdef __has_include
  3. #  if __has_include(<filesystem>)
  4. #    include <filesystem>  // gcc8 (Fedora29+)
  5.      namespace fs = std::filesystem;
  6. #  elif __has_include(<experimental/filesystem>)
  7. #    include <experimental/filesystem> // gcc7 (Ubuntu 18.04)
  8.      namespace fs = std::experimental::filesystem;
  9. #  endif
  10. #else
  11. #error no __has_include
  12. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement