tentative fix for #189

This commit is contained in:
Mark Gillard 2023-01-29 14:42:08 +02:00
parent d8bb7176d5
commit d00464a7bc
4 changed files with 83 additions and 32 deletions

View File

@ -34,8 +34,11 @@
//# COMPILER / OS //# COMPILER / OS
//#===================================================================================================================== //#=====================================================================================================================
#define TOML_MAKE_VERSION(major, minor, patch) (((major)*10000) + ((minor)*100) + ((patch)))
#ifdef __clang__ #ifdef __clang__
#define TOML_CLANG __clang_major__ #define TOML_CLANG __clang_major__
#define TOML_CLANG_VERSION TOML_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#else #else
#define TOML_CLANG 0 #define TOML_CLANG 0
#endif #endif
@ -76,6 +79,33 @@
#define TOML_INTELLISENSE 0 #define TOML_INTELLISENSE 0
#endif #endif
// special handling for apple clang; see:
// - https://github.com/marzer/tomlplusplus/issues/189
// - https://en.wikipedia.org/wiki/Xcode
// - https://stackoverflow.com/questions/19387043/how-can-i-reliably-detect-the-version-of-clang-at-preprocessing-time
#if TOML_CLANG && defined(__apple_build_version__)
#undef TOML_CLANG
#if TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 0, 0)
#define TOML_CLANG 14
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 1, 6)
#define TOML_CLANG 13
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 0, 0)
#define TOML_CLANG 12
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 5)
#define TOML_CLANG 11
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 0)
#define TOML_CLANG 10
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 3)
#define TOML_CLANG 9
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 0)
#define TOML_CLANG 8
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(10, 0, 1)
#define TOML_CLANG 7
#else
#define TOML_CLANG 6 // not strictly correct but doesn't matter below this
#endif
#endif
//#===================================================================================================================== //#=====================================================================================================================
//# ARCHITECTURE //# ARCHITECTURE
//#===================================================================================================================== //#=====================================================================================================================
@ -438,6 +468,7 @@
#define TOML_PUSH_WARNINGS \ #define TOML_PUSH_WARNINGS \
TOML_PRAGMA_CLANG(diagnostic push) \ TOML_PRAGMA_CLANG(diagnostic push) \
TOML_PRAGMA_CLANG(diagnostic ignored "-Wunknown-warning-option") \
static_assert(true) static_assert(true)
#define TOML_DISABLE_SWITCH_WARNINGS \ #define TOML_DISABLE_SWITCH_WARNINGS \
@ -938,8 +969,6 @@
/// \def TOML_SMALL_FLOAT_TYPE /// \def TOML_SMALL_FLOAT_TYPE
/// \brief If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it. /// \brief If your codebase has an additional 'small' float type (e.g. half-precision), this tells toml++ about it.
/// \detail Not defined by default. /// \detail Not defined by default.
/// \remark If you're building for a platform that has `_Float16` and/or `__fp16`, you don't
/// need to use this configuration option to make toml++ aware of them. The library comes with that built-in.
//# }} //# }}
#ifndef TOML_UNDEF_MACROS #ifndef TOML_UNDEF_MACROS
@ -998,6 +1027,15 @@ TOML_ENABLE_WARNINGS;
/// \detail Not defined by default. /// \detail Not defined by default.
//# }} //# }}
#ifndef TOML_ENABLE_FLOAT16
#define TOML_ENABLE_FLOAT16 0
#endif
//# {{
/// \def TOML_ENABLE_FLOAT16
/// \brief Enable support for the built-in `_Float16` type.
/// \detail Defaults to `0`.
//# }}
/// @} /// @}
//#==================================================================================================================== //#====================================================================================================================
//# CHARCONV SUPPORT //# CHARCONV SUPPORT
@ -1051,20 +1089,6 @@ TOML_ENABLE_WARNINGS;
#endif #endif
//# }} //# }}
//#=====================================================================================================================
//# FLOAT16
//#=====================================================================================================================
#ifndef TOML_ENABLE_FLOAT16
#define TOML_ENABLE_FLOAT16 0
#endif
//# {{
/// \def TOML_ENABLE_FLOAT16
/// \brief Enable support for the built-in `_Float16` type.
/// \detail Default behaviour is to try to determine support based on compiler, architecture and built-in defines, but
/// you can override it to force-enable/disable support.
//# }}
//#===================================================================================================================== //#=====================================================================================================================
//# FLOAT128 //# FLOAT128
//#===================================================================================================================== //#=====================================================================================================================
@ -1092,9 +1116,6 @@ TOML_ENABLE_WARNINGS;
#define TOML_LIB_SINGLE_HEADER 0 #define TOML_LIB_SINGLE_HEADER 0
#define TOML_MAKE_VERSION(major, minor, patch) \
((major) * 10000 + (minor) * 100 + (patch))
#if TOML_ENABLE_UNRELEASED_FEATURES #if TOML_ENABLE_UNRELEASED_FEATURES
#define TOML_LANG_EFFECTIVE_VERSION \ #define TOML_LANG_EFFECTIVE_VERSION \
TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1) TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1)

View File

@ -9,7 +9,7 @@ TOML_DISABLE_WARNINGS;
#include <new> #include <new>
TOML_ENABLE_WARNINGS; TOML_ENABLE_WARNINGS;
#if TOML_CLANG >= 8 || TOML_GCC >= 7 || TOML_ICC >= 1910 || TOML_MSVC >= 1914 #if (!defined(__apple_build_version__) && TOML_CLANG >= 8) || TOML_GCC >= 7 || TOML_ICC >= 1910 || TOML_MSVC >= 1914
#define TOML_LAUNDER(x) __builtin_launder(x) #define TOML_LAUNDER(x) __builtin_launder(x)
#elif defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606 #elif defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
#define TOML_LAUNDER(x) std::launder(x) #define TOML_LAUNDER(x) std::launder(x)

View File

@ -28,7 +28,7 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS;
#if TOML_CLANG >= 12 #if TOML_CLANG >= 12
#pragma clang diagnostic ignored "-Wc++20-extensions" #pragma clang diagnostic ignored "-Wc++20-extensions"
#endif #endif
#if (TOML_CLANG == 13) && !defined(__APPLE__) #if TOML_CLANG == 13 && !defined(__APPLE__)
#pragma clang diagnostic ignored "-Wreserved-identifier" #pragma clang diagnostic ignored "-Wreserved-identifier"
#endif #endif
#endif #endif
@ -102,6 +102,7 @@ TOML_POP_WARNINGS;
#undef TOML_ASYMMETRICAL_EQUALITY_OPS #undef TOML_ASYMMETRICAL_EQUALITY_OPS
#undef TOML_ATTR #undef TOML_ATTR
#undef TOML_CLANG #undef TOML_CLANG
#undef TOML_CLANG_VERSION
#undef TOML_CLOSED_ENUM #undef TOML_CLOSED_ENUM
#undef TOML_CLOSED_FLAGS_ENUM #undef TOML_CLOSED_FLAGS_ENUM
#undef TOML_COMPILER_HAS_EXCEPTIONS #undef TOML_COMPILER_HAS_EXCEPTIONS

View File

@ -70,8 +70,11 @@
#endif #endif
#endif #endif
#define TOML_MAKE_VERSION(major, minor, patch) (((major)*10000) + ((minor)*100) + ((patch)))
#ifdef __clang__ #ifdef __clang__
#define TOML_CLANG __clang_major__ #define TOML_CLANG __clang_major__
#define TOML_CLANG_VERSION TOML_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
#else #else
#define TOML_CLANG 0 #define TOML_CLANG 0
#endif #endif
@ -112,6 +115,33 @@
#define TOML_INTELLISENSE 0 #define TOML_INTELLISENSE 0
#endif #endif
// special handling for apple clang; see:
// - https://github.com/marzer/tomlplusplus/issues/189
// - https://en.wikipedia.org/wiki/Xcode
// - https://stackoverflow.com/questions/19387043/how-can-i-reliably-detect-the-version-of-clang-at-preprocessing-time
#if TOML_CLANG && defined(__apple_build_version__)
#undef TOML_CLANG
#if TOML_CLANG_VERSION >= TOML_MAKE_VERSION(14, 0, 0)
#define TOML_CLANG 14
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 1, 6)
#define TOML_CLANG 13
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(13, 0, 0)
#define TOML_CLANG 12
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 5)
#define TOML_CLANG 11
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(12, 0, 0)
#define TOML_CLANG 10
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 3)
#define TOML_CLANG 9
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(11, 0, 0)
#define TOML_CLANG 8
#elif TOML_CLANG_VERSION >= TOML_MAKE_VERSION(10, 0, 1)
#define TOML_CLANG 7
#else
#define TOML_CLANG 6 // not strictly correct but doesn't matter below this
#endif
#endif
// IA64 // IA64
#if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64) #if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
#define TOML_ARCH_ITANIUM 1 #define TOML_ARCH_ITANIUM 1
@ -464,6 +494,7 @@
#define TOML_PUSH_WARNINGS \ #define TOML_PUSH_WARNINGS \
TOML_PRAGMA_CLANG(diagnostic push) \ TOML_PRAGMA_CLANG(diagnostic push) \
TOML_PRAGMA_CLANG(diagnostic ignored "-Wunknown-warning-option") \
static_assert(true) static_assert(true)
#define TOML_DISABLE_SWITCH_WARNINGS \ #define TOML_DISABLE_SWITCH_WARNINGS \
@ -896,6 +927,10 @@ TOML_ENABLE_WARNINGS;
#define TOML_ASSERT_ASSUME(expr) TOML_ASSERT(expr) #define TOML_ASSERT_ASSUME(expr) TOML_ASSERT(expr)
#endif #endif
#ifndef TOML_ENABLE_FLOAT16
#define TOML_ENABLE_FLOAT16 0
#endif
#if !defined(TOML_FLOAT_CHARCONV) && (TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL)) #if !defined(TOML_FLOAT_CHARCONV) && (TOML_GCC || TOML_CLANG || (TOML_ICC && !TOML_ICC_CL))
// not supported by any version of GCC or Clang as of 26/11/2020 // not supported by any version of GCC or Clang as of 26/11/2020
// not supported by any version of ICC on Linux as of 11/01/2021 // not supported by any version of ICC on Linux as of 11/01/2021
@ -930,10 +965,6 @@ TOML_ENABLE_WARNINGS;
TOML_REQUIRES(condition) TOML_REQUIRES(condition)
#define TOML_HIDDEN_CONSTRAINT(condition, ...) TOML_CONSTRAINED_TEMPLATE(condition, __VA_ARGS__) #define TOML_HIDDEN_CONSTRAINT(condition, ...) TOML_CONSTRAINED_TEMPLATE(condition, __VA_ARGS__)
#ifndef TOML_ENABLE_FLOAT16
#define TOML_ENABLE_FLOAT16 0
#endif
#if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && defined(__LDBL_MANT_DIG__) \ #if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && defined(__LDBL_MANT_DIG__) \
&& __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__ && __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__
#define TOML_FLOAT128 __float128 #define TOML_FLOAT128 __float128
@ -960,9 +991,6 @@ TOML_ENABLE_WARNINGS;
#define TOML_LIB_SINGLE_HEADER 1 #define TOML_LIB_SINGLE_HEADER 1
#define TOML_MAKE_VERSION(major, minor, patch) \
((major) * 10000 + (minor) * 100 + (patch))
#if TOML_ENABLE_UNRELEASED_FEATURES #if TOML_ENABLE_UNRELEASED_FEATURES
#define TOML_LANG_EFFECTIVE_VERSION \ #define TOML_LANG_EFFECTIVE_VERSION \
TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1) TOML_MAKE_VERSION(TOML_LANG_MAJOR, TOML_LANG_MINOR, TOML_LANG_PATCH+1)
@ -1091,7 +1119,7 @@ TOML_DISABLE_SUGGEST_ATTR_WARNINGS;
#if TOML_CLANG >= 12 #if TOML_CLANG >= 12
#pragma clang diagnostic ignored "-Wc++20-extensions" #pragma clang diagnostic ignored "-Wc++20-extensions"
#endif #endif
#if (TOML_CLANG == 13) && !defined(__APPLE__) #if TOML_CLANG == 13 && !defined(__APPLE__)
#pragma clang diagnostic ignored "-Wreserved-identifier" #pragma clang diagnostic ignored "-Wreserved-identifier"
#endif #endif
#endif #endif
@ -1102,7 +1130,7 @@ TOML_DISABLE_WARNINGS;
#include <new> #include <new>
TOML_ENABLE_WARNINGS; TOML_ENABLE_WARNINGS;
#if TOML_CLANG >= 8 || TOML_GCC >= 7 || TOML_ICC >= 1910 || TOML_MSVC >= 1914 #if (!defined(__apple_build_version__) && TOML_CLANG >= 8) || TOML_GCC >= 7 || TOML_ICC >= 1910 || TOML_MSVC >= 1914
#define TOML_LAUNDER(x) __builtin_launder(x) #define TOML_LAUNDER(x) __builtin_launder(x)
#elif defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606 #elif defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
#define TOML_LAUNDER(x) std::launder(x) #define TOML_LAUNDER(x) std::launder(x)
@ -17094,6 +17122,7 @@ TOML_POP_WARNINGS;
#undef TOML_ASYMMETRICAL_EQUALITY_OPS #undef TOML_ASYMMETRICAL_EQUALITY_OPS
#undef TOML_ATTR #undef TOML_ATTR
#undef TOML_CLANG #undef TOML_CLANG
#undef TOML_CLANG_VERSION
#undef TOML_CLOSED_ENUM #undef TOML_CLOSED_ENUM
#undef TOML_CLOSED_FLAGS_ENUM #undef TOML_CLOSED_FLAGS_ENUM
#undef TOML_COMPILER_HAS_EXCEPTIONS #undef TOML_COMPILER_HAS_EXCEPTIONS