mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
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.
This commit is contained in:
@@ -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__ */
|
||||
|
Reference in New Issue
Block a user