[PATCH 2/6] Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE

Justus Winter 4winter at informatik.uni-hamburg.de
Mon Sep 24 08:21:16 PDT 2012


This attribute is understood by gcc since version 2.5. clang provides
support for testing for function attributes using __has_attribute. For
other compilers this macro evaluates to the empty string.

Signed-off-by: Justus Winter <4winter at informatik.uni-hamburg.de>
---
 compat/function-attributes.h |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/compat/function-attributes.h b/compat/function-attributes.h
index 18f9090..8450a17 100644
--- a/compat/function-attributes.h
+++ b/compat/function-attributes.h
@@ -28,4 +28,20 @@
 #define __has_attribute(x) 0
 #endif
 
+/* Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE from
+ * talloc.
+ *
+ * This attribute is understood by gcc since version 2.5. clang
+ * provides support for testing for function attributes.
+ */
+#ifndef NORETURN_ATTRIBUTE
+#if (__GNUC__ >= 3 ||				\
+     (__GNUC__ == 2 && __GNUC_MINOR__ >= 5) ||	\
+     __has_attribute (noreturn))
+#define NORETURN_ATTRIBUTE __attribute__ ((noreturn))
+#else
+#define NORETURN_ATTRIBUTE
+#endif
+#endif
+
 #endif
-- 
1.7.10.4



More information about the notmuch mailing list