Browse Source

features.h: add clang prerequisite macro

This can be used to guard features for specific clang versions.

Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
Marcus Haehnel 9 months ago
parent
commit
057913bc8c
1 changed files with 12 additions and 0 deletions
  1. 12 0
      include/features.h

+ 12 - 0
include/features.h

@@ -140,6 +140,18 @@
 # define __GNUC_PREREQ(maj, min) 0
 #endif
 
+/* Convenience macro to test the version of clang.
+   Use like this:
+   #if __CLANG_PREREQ(3,2)
+   ... code requiring clang 3.2 or later ...
+   #endif */
+#if defined __clang__
+# define __CLANG_PREREQ(maj, min) \
+	((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
+#else
+# define __CLANG_PREREQ(maj, min) 0
+#endif
+
 /* Whether to use feature set F.  */
 #define __GLIBC_USE(F)  __GLIBC_USE_ ## F