need_fslib.cxx 591 B

123456789101112131415161718192021
  1. // Check whether we need to link to the stdc++fs library.
  2. //
  3. // We assume that the presence of the <filesystem> header means that we have
  4. // support for the basics of std::filesystem. This check will succeed if
  5. // either there is no <filesystem> header, or there is one and it works without
  6. // any special options. If the link fails, we assume that -lstdc++fs will fix
  7. // it for us.
  8. #include <iostream>
  9. #if __has_include(<filesystem>)
  10. # include <filesystem>
  11. #endif
  12. int main()
  13. {
  14. #if __has_include(<filesystem>)
  15. std::cout << std::filesystem::path{"foo.bar"}.c_str() << '\n';
  16. #endif
  17. }