diff --git a/doc/limitations.md b/doc/limitations.md index c682bca..253c6c8 100644 --- a/doc/limitations.md +++ b/doc/limitations.md @@ -82,6 +82,8 @@ On some compiler enum-aliases not supported, [for example Visual Studio 2017](https://github.com/Neargye/magic_enum/issues/36). + It is possible to check whether enum-aliases supported using a macro `MAGIC_ENUM_SUPPORTED_ALIASES`. + * If you hit a message like this: ```text diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index e9ae434..02db031 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -62,6 +62,12 @@ # define MAGIC_ENUM_SUPPORTED 1 #endif +// Checks magic_enum compiler aliases compatibility. +#if defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 || defined(_MSC_VER) && _MSC_VER >= 1920 +# undef MAGIC_ENUM_SUPPORTED_ALIASES +# define MAGIC_ENUM_SUPPORTED_ALIASES 1 +#endif + // Enum value must be greater or equals than MAGIC_ENUM_RANGE_MIN. By default MAGIC_ENUM_RANGE_MIN = -128. // If need another min range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MIN. #if !defined(MAGIC_ENUM_RANGE_MIN) diff --git a/test/test.cpp b/test/test.cpp index cbad4cf..5cdddf4 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -27,10 +27,6 @@ #define MAGIC_ENUM_RANGE_MAX 120 #include -#if defined(_MSC_VER) && _MSC_VER >= 1920 || defined(__clang__) && __clang_major__ >= 5 || defined(__GNUC__) && __GNUC__ >= 9 -# define MAGIC_ENUM_SUPPORTED_ALIASES -#endif - #include #include #include