Skip to content

Commit 157feb3

Browse files
authored
Merge pull request #190 from dpogue/wundef-fix
Check macros are defined before use
2 parents b1982f0 + f08e8b0 commit 157feb3

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

include/ghc/fs_std.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#ifndef GHC_FILESYSTEM_STD_H
3333
#define GHC_FILESYSTEM_STD_H
3434

35-
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
35+
#if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
3636
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
3737
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
3838
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@@ -46,12 +46,12 @@
4646
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
4747
// released after std::filesystem, where std::filesystem is always available.
4848
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
49-
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
50-
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
51-
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
52-
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
49+
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
50+
|| defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
51+
|| defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
52+
|| defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
5353
#undef GHC_USE_STD_FS
54-
#endif
54+
#endif
5555
#endif
5656
#endif
5757
#endif

include/ghc/fs_std_fwd.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#ifndef GHC_FILESYSTEM_STD_FWD_H
3535
#define GHC_FILESYSTEM_STD_FWD_H
3636

37-
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
37+
#if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
3838
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
3939
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
4040
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@@ -48,12 +48,12 @@
4848
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
4949
// released after std::filesystem, where std::filesystem is always available.
5050
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
51-
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
52-
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
53-
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
54-
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
51+
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
52+
|| defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
53+
|| defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
54+
|| defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
5555
#undef GHC_USE_STD_FS
56-
#endif
56+
#endif
5757
#endif
5858
#endif
5959
#endif

include/ghc/fs_std_impl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different
3232
// header to work.
3333
//---------------------------------------------------------------------------------------
34-
#if _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
34+
#if defined(_MSVC_LANG) && _MSVC_LANG >= 201703L || __cplusplus >= 201703L && defined(__has_include)
3535
// ^ Supports MSVC prior to 15.7 without setting /Zc:__cplusplus to fix __cplusplus
3636
// _MSVC_LANG works regardless. But without the switch, the compiler always reported 199711L: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/
3737
#if __has_include(<filesystem>) // Two stage __has_include needed for MSVC 2015 and per https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
@@ -45,12 +45,12 @@
4545
// Note: This intentionally uses std::filesystem on any new Apple OS, like visionOS
4646
// released after std::filesystem, where std::filesystem is always available.
4747
// (All other __<platform>_VERSION_MIN_REQUIREDs will be undefined and thus 0.)
48-
#if __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
49-
|| __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
50-
|| __TV_OS_VERSION_MIN_REQUIRED && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
51-
|| __WATCH_OS_VERSION_MAX_ALLOWED && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
48+
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 \
49+
|| defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 \
50+
|| defined(__TV_OS_VERSION_MIN_REQUIRED) && __TV_OS_VERSION_MIN_REQUIRED < 130000 \
51+
|| defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED < 60000
5252
#undef GHC_USE_STD_FS
53-
#endif
53+
#endif
5454
#endif
5555
#endif
5656
#endif

0 commit comments

Comments
 (0)