summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.h b/util.h
index 1b52513..7b8b877 100644
--- a/util.h
+++ b/util.h
@@ -42,6 +42,12 @@
# define BFS_HAS_INCLUDE(header, fallback) fallback
#endif
+#ifdef __has_c_attribute
+# define BFS_HAS_C_ATTRIBUTE(attr) __has_c_attribute(attr)
+#else
+# define BFS_HAS_C_ATTRIBUTE(attr) false
+#endif
+
#ifndef BFS_HAS_MNTENT
# define BFS_HAS_MNTENT BFS_HAS_INCLUDE(<mntent.h>, __GLIBC__)
#endif
@@ -86,6 +92,14 @@
# define O_DIRECTORY 0
#endif
+#if BFS_HAS_C_ATTRIBUTE(fallthrough)
+# define fallthrough [[fallthrough]]
+#elif __GNUC__
+# define fallthrough __attribute__((fallthrough))
+#else
+# define fallthrough
+#endif
+
/**
* Adds compiler warnings for bad printf()-style function calls, if supported.
*/