diff --git a/include/rice/rice.hpp b/include/rice/rice.hpp index 74d8eb4f..5ca3cf6c 100644 --- a/include/rice/rice.hpp +++ b/include/rice/rice.hpp @@ -1205,9 +1205,18 @@ namespace Rice::detail // ========= cpp_protect.hpp ========= #include -#include #include +#if __has_include() + #include + namespace fs = std::filesystem; +#elif __has_include() + #include + namespace fs = std::experimental::filesystem; +#else + #error "no filesystem include found :'(" +#endif + namespace Rice::detail { @@ -1247,7 +1256,7 @@ namespace Rice::detail { rb_exc_raise(rb_exc_new2(rb_eArgError, ex.what())); } - catch (std::filesystem::filesystem_error const& ex) + catch (fs::filesystem_error const& ex) { rb_exc_raise(rb_exc_new2(rb_eIOError, ex.what())); } diff --git a/lib/mkmf-rice.rb b/lib/mkmf-rice.rb index 9473e101..952dbff1 100644 --- a/lib/mkmf-rice.rb +++ b/lib/mkmf-rice.rb @@ -126,5 +126,7 @@ def cpp_command(outfile, opt="") if IS_DARWIN have_library('c++') elsif !IS_MSWIN - have_library('stdc++') + if !have_library('stdc++fs') + have_library('stdc++') + end end \ No newline at end of file diff --git a/rice/detail/cpp_protect.hpp b/rice/detail/cpp_protect.hpp index 4ed0ec4d..4956acce 100644 --- a/rice/detail/cpp_protect.hpp +++ b/rice/detail/cpp_protect.hpp @@ -2,9 +2,18 @@ #define Rice__detail__cpp_protect__hpp_ #include -#include #include +#if __has_include() + #include + namespace fs = std::filesystem; +#elif __has_include() + #include + namespace fs = std::experimental::filesystem; +#else + #error "no filesystem include found :'(" +#endif + #include "Jump_Tag.hpp" #include "../Exception_defn.hpp" @@ -46,7 +55,7 @@ namespace Rice::detail { rb_exc_raise(rb_exc_new2(rb_eArgError, ex.what())); } - catch (std::filesystem::filesystem_error const& ex) + catch (fs::filesystem_error const& ex) { rb_exc_raise(rb_exc_new2(rb_eIOError, ex.what())); }