From 5f38ae5ffca3213addc5b279a46d537792d031db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 28 Feb 2020 08:59:23 +0100 Subject: [PATCH] macros: Define G_GNUC_FALLTHROUGH for more compilers Some compilers have __GNUC__ defined as a value less than 6, but do support implicit-fallthrough via __attribute__((fallthrough)). Define G_GNUC_FALLTHROUGH for those that support __has_attribute. --- glib/gmacros.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glib/gmacros.h b/glib/gmacros.h index 1f4d779be..fb14aa81a 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -532,7 +532,7 @@ /** * G_GNUC_FALLTHROUGH: * - * Expands to the GNU C `fallthrough` statement attribute if the compiler is gcc. + * Expands to the GNU C `fallthrough` statement attribute if the compiler supports it. * This allows declaring case statement to explicitly fall through in switch * statements. To enable this feature, use `-Wimplicit-fallthrough` during * compilation. @@ -559,6 +559,8 @@ */ #if __GNUC__ > 6 #define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) +#elif g_macro__has_attribute (fallthrough) +#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) #else #define G_GNUC_FALLTHROUGH #endif /* __GNUC__ */