* [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
@ 2015-08-11 14:37 Tomi Ollila
2015-12-08 12:44 ` David Bremner
2015-12-29 11:52 ` Jani Nikula
0 siblings, 2 replies; 5+ messages in thread
From: Tomi Ollila @ 2015-08-11 14:37 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
2015-08-11 14:37 [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro Tomi Ollila
@ 2015-12-08 12:44 ` David Bremner
2015-12-08 13:15 ` Tomi Ollila
2015-12-29 11:52 ` Jani Nikula
1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2015-12-08 12:44 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Tomi Ollila <tomi.ollila@iki.fi> writes:
> 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.
Hi Tomi;
I keep coming back to review this patch, but I'm blocked by the fact
that clang++ is broken on Debian (and lots of other places, I guess) for
months.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797038
d
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
2015-12-08 12:44 ` David Bremner
@ 2015-12-08 13:15 ` Tomi Ollila
0 siblings, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2015-12-08 13:15 UTC (permalink / raw)
To: David Bremner, notmuch
On Tue, Dec 08 2015, David Bremner <david@tethera.net> wrote:
> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> 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.
>
> Hi Tomi;
>
> I keep coming back to review this patch, but I'm blocked by the fact
> that clang++ is broken on Debian (and lots of other places, I guess) for
> months.
>
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=797038
Personally I am not fond of the commit message but I don't want to
emphasize the change by sending an updated one. We could move it
to *moreinfo* to get it out of our ways for the time being -- and
see whether things stabilize (to one way or another) to decide
whether to push this further.
>
> d
Tomi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
2015-08-11 14:37 [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro Tomi Ollila
2015-12-08 12:44 ` David Bremner
@ 2015-12-29 11:52 ` Jani Nikula
2016-03-01 16:46 ` Justus Winter
1 sibling, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2015-12-29 11:52 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
On Tue, 11 Aug 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> 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
This file is included by the users of the library, and thus this
definition leaks to our users. It might cause problems if the users have
different expectations for handling ifndef __has_extension. I don't
think we should define things outside of our namespace in notmuch.h.
BR,
Jani.
> +
> +#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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro
2015-12-29 11:52 ` Jani Nikula
@ 2016-03-01 16:46 ` Justus Winter
0 siblings, 0 replies; 5+ messages in thread
From: Justus Winter @ 2016-03-01 16:46 UTC (permalink / raw)
To: Jani Nikula, Tomi Ollila, notmuch; +Cc: tomi.ollila
Quoting Jani Nikula (2015-12-29 12:52:20)
> > __has_extension() replacement was modeled after __has_attribute()
> > definition in compat/function-attributes.h. Thanks Justus.
Hum, I didn't even recall doing that.
> > +/* 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
>
> This file is included by the users of the library, and thus this
> definition leaks to our users. It might cause problems if the users have
> different expectations for handling ifndef __has_extension. I don't
> think we should define things outside of our namespace in notmuch.h.
Indeed, even more so since the __ namespace is reserved. But that
should be easy to fix, right? Simply pick a less problematic name for
the new macro.
I'd love to see this issue fixed.
Cheers,
Justus
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-03-01 16:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-11 14:37 [PATCH] lib: have two definitions of NOTMUCH_DEPRECATED macro Tomi Ollila
2015-12-08 12:44 ` David Bremner
2015-12-08 13:15 ` Tomi Ollila
2015-12-29 11:52 ` Jani Nikula
2016-03-01 16:46 ` Justus Winter
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).