diff --git a/include/cinder/Filesystem.h b/include/cinder/Filesystem.h index 9e08382a31..0187107338 100644 --- a/include/cinder/Filesystem.h +++ b/include/cinder/Filesystem.h @@ -24,15 +24,31 @@ #pragma once -#if ( (! defined(__APPLE__)) && defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include()) || defined( _MSC_VER ) +/* + Seems like MSVC does not define `__cplusplus` according to the picked `std=c++XX` prior to 2017. + Moreover, due to legacy code expecting it to still be `199711L` this is disabled by default and requires `/Zc:__cplusplus`. + > ref : https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ + + Instead, we can additionally check `_MSVC_LANG` which always reports the c++ std version + Basically, when `/Zc:__cplusplus` is enabled: `__cplusplus == _MSVC_LANG` + > ref: https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 +*/ + +#ifndef __APPLE__ + #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() + #define GHC_USE_STD_FS + #elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L && defined(__has_include) && __has_include() #define GHC_USE_STD_FS - #include - namespace cinder { - namespace fs = std::filesystem; - } + #endif #endif -#ifndef GHC_USE_STD_FS +#ifdef GHC_USE_STD_FS + #include + namespace cinder { + namespace fs = std::filesystem; + } +#else + #define GHC_WIN_WSTRING_STRING_TYPE #include namespace cinder { namespace fs = ghc::filesystem; diff --git a/proj/vc2019/cinder.vcxproj b/proj/vc2019/cinder.vcxproj index e1cba7652e..9e5deb5d0f 100644 --- a/proj/vc2019/cinder.vcxproj +++ b/proj/vc2019/cinder.vcxproj @@ -1,4 +1,4 @@ - + @@ -765,6 +765,7 @@ + diff --git a/proj/vc2019/cinder.vcxproj.filters b/proj/vc2019/cinder.vcxproj.filters index 3796a18e27..18c634664a 100644 --- a/proj/vc2019/cinder.vcxproj.filters +++ b/proj/vc2019/cinder.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -1083,6 +1083,9 @@ Source Files + + Source Files + diff --git a/src/cinder/Filesystem.cpp b/src/cinder/Filesystem.cpp index 18502b9a42..4d87567245 100644 --- a/src/cinder/Filesystem.cpp +++ b/src/cinder/Filesystem.cpp @@ -21,13 +21,16 @@ POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) - #if (! defined(__APPLE__)) && __has_include() +#ifndef __APPLE__ + #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() + #define GHC_USE_STD_FS + #elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L && defined(__has_include) && __has_include() #define GHC_USE_STD_FS #endif #endif -#if ! defined( GHC_USE_STD_FS ) +#ifndef GHC_USE_STD_FS #undef GHC_FILESYSTEM_H + #define GHC_WIN_WSTRING_STRING_TYPE #include #endif