From c42376a8d16557d054e47fbe13039cbf8944a408 Mon Sep 17 00:00:00 2001 From: neargye Date: Wed, 3 Jun 2020 19:51:05 +0500 Subject: [PATCH] improve compiler check --- include/nameof.hpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/include/nameof.hpp b/include/nameof.hpp index 7e883a9..e347d9d 100644 --- a/include/nameof.hpp +++ b/include/nameof.hpp @@ -55,18 +55,31 @@ #endif // Checks nameof_type compiler compatibility. -#if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 7 || defined(_MSC_VER) && _MSC_VER >= 1910 # undef NAMEOF_TYPE_SUPPORTED # define NAMEOF_TYPE_SUPPORTED 1 #endif -#if defined(__cpp_rtti) || defined(_CPPRTTI) || defined(__GXX_RTTI) -# undef NAMEOF_TYPE_RTTI_SUPPORTED -# define NAMEOF_TYPE_RTTI_SUPPORTED 1 +// Checks nameof_type_rtti compiler compatibility. +#if defined(__clang__) +# if __has_feature(cxx_rtti) +# undef NAMEOF_TYPE_RTTI_SUPPORTED +# define NAMEOF_TYPE_RTTI_SUPPORTED 1 +# endif +#elif defined(__GNUC__) +# if defined(__GXX_RTTI) +# undef NAMEOF_TYPE_RTTI_SUPPORTED +# define NAMEOF_TYPE_RTTI_SUPPORTED 1 +# endif +#elif defined(_MSC_VER) +# if defined(_CPPRTTI) +# undef NAMEOF_TYPE_RTTI_SUPPORTED +# define NAMEOF_TYPE_RTTI_SUPPORTED 1 +# endif #endif // Checks nameof_enum compiler compatibility. -#if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1910 # undef NAMEOF_ENUM_SUPPORTED # define NAMEOF_ENUM_SUPPORTED 1 #endif