Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit d821633

Browse files
authored
Made portable use of __cplusplus
1 parent e803911 commit d821633

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

include/tinyutf8/tinyutf8.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@
5454
#endif
5555
#endif
5656

57+
//! Determine portable __cplusplus macro
58+
#if defined(_MSC_VER) && defined(_MSVC_LANG)
59+
#define TINY_UTF8_CPLUSPLUS _MSVC_LANG
60+
#endif
61+
#define TINY_UTF8_CPLUSPLUS __cplusplus
62+
#endif
63+
5764
//! Determine the way to inform about fallthrough behavior
58-
#if __cplusplus >= 201700L
65+
#if TINY_UTF8_CPLUSPLUS >= 201703L
5966
#define TINY_UTF8_FALLTHROUGH [[fallthrough]];
6067
#elif defined(__clang__)
6168
// Clang does not warn about implicit fallthrough
@@ -81,7 +88,7 @@
8188
#endif
8289

8390
//! Create macro that yields its arguments, if C++17 or later is present (used for "if constexpr")
84-
#if __cplusplus >= 201700L
91+
#if TINY_UTF8_CPLUSPLUS >= 201703L
8592
#define TINY_UTF8_CPP17( ... ) __VA_ARGS__
8693
#else
8794
#define TINY_UTF8_CPP17( ... )
@@ -117,12 +124,10 @@ namespace tiny_utf8
117124
using utf8_string = basic_string<char32_t, char>; // For backwards compatibility
118125

119126
//! Typedef of u8string (data type char8_t)
120-
#if __cplusplus > 201703L
121-
#if defined(__cpp_char8_t)
122-
using u8string = basic_string<char32_t, char8_t>;
123-
#else
124-
using u8string = utf8_string;
125-
#endif
127+
#if defined(__cpp_char8_t)
128+
using u8string = basic_string<char32_t, char8_t>;
129+
#else
130+
using u8string = utf8_string;
126131
#endif
127132

128133
//! Implementation Detail

0 commit comments

Comments
 (0)