[PATCH 2/5] RFC: Provide a NORETURN_ATTRIBUTE macro similar to PRINTF_ATTRIBUTE

Justus Winter 4winter at informatik.uni-hamburg.de
Mon Sep 24 03:31:54 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.

Note: This is work in progress, please don't merge this patch. The
question that needs to be discussed is where this kind of macro should
be defined.

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

diff --git a/util/error_util.h b/util/error_util.h
index 1b11047..27e119f 100644
--- a/util/error_util.h
+++ b/util/error_util.h
@@ -31,6 +31,22 @@
 #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
+
 /* There's no point in continuing when we've detected that we've done
  * something wrong internally (as opposed to the user passing in a
  * bogus value).
-- 
1.7.10.4



More information about the notmuch mailing list