From 4f7f3f2147827715e685321874081a0a6683b0af Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 30 Jun 2021 16:22:27 -0400 Subject: [PATCH] Use __has_cpp_attribute for NOWIDE_FALLTHROUGH --- include/nowide/config.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nowide/config.hpp b/include/nowide/config.hpp index 26b8287..e190d0f 100644 --- a/include/nowide/config.hpp +++ b/include/nowide/config.hpp @@ -58,8 +58,14 @@ #define NOWIDE_USE_FILEBUF_REPLACEMENT 0 #endif -#if defined(__GNUC__) && __GNUC__ >= 7 -#define NOWIDE_FALLTHROUGH __attribute__((fallthrough)) +#if defined(__has_cpp_attribute) +#define NOWIDE_HAS_CPP_ATTRIBUTE(attr) __has_cpp_attribute(attr) +#else +#define NOWIDE_HAS_CPP_ATTRIBUTE(attr) (0) +#endif + +#if NOWIDE_HAS_CPP_ATTRIBUTE(fallthrough) +#define NOWIDE_FALLTHROUGH [[fallthrough]] #else #define NOWIDE_FALLTHROUGH #endif