From d25114159c26853cc6e49ee1764f0be0d510255e Mon Sep 17 00:00:00 2001 From: Diego Mateos Date: Thu, 26 Oct 2023 13:46:45 +0200 Subject: [PATCH 1/5] Fix using std::filesystem when not available --- include/cinder/Filesystem.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/cinder/Filesystem.h b/include/cinder/Filesystem.h index 9e08382a31..0cc000385e 100644 --- a/include/cinder/Filesystem.h +++ b/include/cinder/Filesystem.h @@ -24,12 +24,12 @@ #pragma once -#if ( (! defined(__APPLE__)) && defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include()) || defined( _MSC_VER ) - #define GHC_USE_STD_FS - #include - namespace cinder { - namespace fs = std::filesystem; - } +#if (! defined(__APPLE__)) && defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() + #define GHC_USE_STD_FS + #include + namespace cinder { + namespace fs = std::filesystem; + } #endif #ifndef GHC_USE_STD_FS From b96c179e41b66de19e6738aa1b7435303bb52e7d Mon Sep 17 00:00:00 2001 From: "diego.mateos" Date: Thu, 16 Nov 2023 09:33:10 +0100 Subject: [PATCH 2/5] Detecting proper c++ std version --- include/cinder/Filesystem.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/include/cinder/Filesystem.h b/include/cinder/Filesystem.h index 0cc000385e..644a4d677a 100644 --- a/include/cinder/Filesystem.h +++ b/include/cinder/Filesystem.h @@ -24,15 +24,30 @@ #pragma once -#if (! defined(__APPLE__)) && defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) && __has_include() - #define GHC_USE_STD_FS +/* + 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 + #endif +#endif + +#ifdef GHC_USE_STD_FS #include namespace cinder { namespace fs = std::filesystem; } -#endif - -#ifndef GHC_USE_STD_FS +#else #include namespace cinder { namespace fs = ghc::filesystem; From 61338ed5afcb295681b13fb7e382e63d2c211326 Mon Sep 17 00:00:00 2001 From: "diego.mateos" Date: Thu, 16 Nov 2023 10:00:38 +0100 Subject: [PATCH 3/5] redefine GHC_WIN_WSTRING_STRING_TYPE for c++<17 --- include/cinder/Filesystem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/cinder/Filesystem.h b/include/cinder/Filesystem.h index 644a4d677a..0187107338 100644 --- a/include/cinder/Filesystem.h +++ b/include/cinder/Filesystem.h @@ -48,6 +48,7 @@ namespace fs = std::filesystem; } #else + #define GHC_WIN_WSTRING_STRING_TYPE #include namespace cinder { namespace fs = ghc::filesystem; From 044d318093f51dc035251d1b7894d9c0a2871515 Mon Sep 17 00:00:00 2001 From: "diego.mateos" Date: Thu, 16 Nov 2023 11:15:39 +0100 Subject: [PATCH 4/5] updated .cpp + added missing GHC_WIN_WSTRING_STRING_TYPE too --- src/cinder/Filesystem.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 From 7836d4d8c7f8570bbd704d0ebb2db4132e358452 Mon Sep 17 00:00:00 2001 From: "diego.mateos" Date: Thu, 16 Nov 2023 11:17:40 +0100 Subject: [PATCH 5/5] added missing source to project to fix linker error --- proj/vc2019/cinder.vcxproj | 3 ++- proj/vc2019/cinder.vcxproj.filters | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 +