[PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
Tomi Ollila
tomi.ollila at iki.fi
Tue Aug 11 07:37:14 PDT 2015
Some compilers (older than gcc 4.5 and clang 2.9) do support
__attribute__ ((deprecated)) but not
__attribute__ ((deprecated("message"))).
Check (clang) and know (gcc) which versions support which variants
and make two definitions of define NOTMUCH_DEPRECATED macro;
one with and and one without the ("message") part.
__has_extension() replacement was modeled after __has_attribute()
definition in compat/function-attributes.h. Thanks Justus.
---
lib/notmuch.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/notmuch.h b/lib/notmuch.h
index b1f5bfa..3f4621b 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -59,8 +59,22 @@ NOTMUCH_BEGIN_DECLS
#define LIBNOTMUCH_MINOR_VERSION 3
#define LIBNOTMUCH_MICRO_VERSION 0
+/* clang provides this macro to test for support for language
+ * extensions. If it isn't defined, this provides a compatibility
+ * macro for other compilers.
+ */
+#ifndef __has_extension
+#define __has_extension(x) 0
+#endif
+
+#if __clang__ && __has_extension(attribute_deprecated_with_message) || \
+ __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5
#define NOTMUCH_DEPRECATED(major,minor) \
__attribute__ ((deprecated ("function deprecated as of libnotmuch " #major "." #minor)))
+#else
+#define NOTMUCH_DEPRECATED(major,minor) __attribute__ ((deprecated))
+#endif
+
#endif /* __DOXYGEN__ */
/**
--
2.4.3
More information about the notmuch
mailing list