[PATCH 1/5] RFC: Provide a __has_attribute compatibility macro

Subject: [PATCH 1/5] RFC: Provide a __has_attribute compatibility macro

Date: Mon, 24 Sep 2012 12:31:53 +0200

To: notmuch@notmuchmail.org

Cc:

From: Justus Winter


__has_attribute is defined by clang and tests whether a given function
attribute is supported by clang.

Add a compatibility macro for other compilers.

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@informatik.uni-hamburg.de>
---
 util/error_util.h |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/util/error_util.h b/util/error_util.h
index bb15822..1b11047 100644
--- a/util/error_util.h
+++ b/util/error_util.h
@@ -23,6 +23,14 @@
 
 #include <talloc.h>
 
+/* clang provides this macro to test for support for function
+ * attributes. If it isn't defined, this provides a compatibility
+ * macro for other compilers.
+ */
+#ifndef __has_attribute
+#define __has_attribute(x) 0
+#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


Thread: