@@ -73,7 +73,7 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
73
73
#define SIMDJSON_DISABLE_VS_WARNING (WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
74
74
// Get rid of Intellisense-only warnings (Code Analysis)
75
75
// Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910).
76
- #if defined (_MSC_VER) && (_MSC_VER>= 1910 )
76
+ #ifdef __has_include
77
77
#if __has_include(<CppCoreCheck\Warnings.h>)
78
78
#include < CppCoreCheck\Warnings.h>
79
79
#define SIMDJSON_DISABLE_UNDESIRED_WARNINGS SIMDJSON_DISABLE_VS_WARNING (ALL_CPPCORECHECK_WARNINGS)
@@ -196,4 +196,53 @@ namespace std {
196
196
#endif // SIMDJSON_HAS_STRING_VIEW
197
197
#undef SIMDJSON_HAS_STRING_VIEW // We are not going to need this macro anymore.
198
198
199
+
200
+
201
+
202
+
203
+ /* *
204
+ * We may fall back on the system's number parsing, and we want
205
+ * to be able to call a locale-insensitive number parser. It unfortunately
206
+ * means that we need to load up locale headers.
207
+ * The locale.h header is generally available:
208
+ */
209
+ #include < locale.h>
210
+ /* *
211
+ * Determining whether we should import xlocale.h or not is
212
+ * a bit of a nightmare. Visual Studio and recent recent GLIBC (GCC) do not need it.
213
+ * However, FreeBSD and Apple platforms will need it.
214
+ * And we would want to cover as many platforms as possible.
215
+ */
216
+ #ifdef __has_include
217
+ // This is the easy case: we have __has_include and can check whether
218
+ // xlocale is available. If so, we load it up.
219
+ #if __has_include(<xlocale.h>)
220
+ #include < xlocale.h>
221
+ #endif // __has_include
222
+ #else // We do not have __has_include
223
+ // Here we do not have __has_include
224
+ // We first check for __GLIBC__
225
+ #ifdef __GLIBC__ // If we have __GLIBC__ then we should have features.h which should help.
226
+ // Note that having __GLIBC__ does not imply that we are compiling against glibc. But
227
+ // we hope that any platform that defines __GLIBC__ will mimick glibc.
228
+ #include < features.h>
229
+ // Check whether we have an old GLIBC.
230
+ #if !((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ > 25)))
231
+ #include < xlocale.h> // Old glibc needs xlocale, otherwise xlocale is unavailable.
232
+ #endif // !((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ > 25)))
233
+ #else // __GLIBC__
234
+ // Ok. So we do not have __GLIBC__
235
+ // We assume that everything that is not GLIBC and not on old freebsd or windows
236
+ // needs xlocale.
237
+ // It is likely that recent FreeBSD and Apple platforms load xlocale.h next:
238
+ #if !(defined(_WIN32) || (__FreeBSD_version < 1000010))
239
+ #include < xlocale.h> // Will always happen under apple.
240
+ #endif //
241
+ #endif // __GLIBC__
242
+ #endif // __has_include
243
+ /* *
244
+ * End of the crazy locale headers.
245
+ */
246
+
247
+
199
248
#endif // SIMDJSON_COMMON_DEFS_H
0 commit comments