diff mbox series

[uclibc-ng-devel] features.h: add clang prerequisite macro

Message ID 20240705154410.14663-1-marcus.haehnel@kernkonzept.com
State Superseded
Headers show
Series [uclibc-ng-devel] features.h: add clang prerequisite macro | expand

Commit Message

Marcus Haehnel July 5, 2024, 3:44 p.m. UTC
This can be used to guard fatures for specific clang versions.
---
 include/features.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/include/features.h b/include/features.h
index b5d4e79f2..1a4efb9db 100644
--- a/include/features.h
+++ b/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