git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier
@ 2022-10-05  9:06 Jeremy Lin
  2022-10-05 13:14 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 2+ messages in thread
From: Jeremy Lin @ 2022-10-05  9:06 UTC (permalink / raw)
  To: git

Commit 9ff7eb8c88 uses the `deprecated` attribute to display a warning
message when something that is supposed to be unused is actually used.
However, `deprecated` only supports messages starting in gcc 4.5.0, so
earlier versions of gcc end up bailing out with a message like

  error: wrong number of arguments specified for ‘deprecated’ attribute

This commit removes the use of the `deprecated` attribute for gcc 4.4.x
and earlier. As this is just a diagnostic feature for developers, and
presumably very few people are developing on such old systems anyway,
this change shouldn't really impact anyone.

Signed-off-by: Jeremy Lin <jeremy.lin@gmail.com>
---
 git-compat-util.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index b90b64718e..9e2969edd6 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -190,8 +190,13 @@ struct strbuf;
 #define _SGI_SOURCE 1
 
 #if defined(__GNUC__)
-#define UNUSED __attribute__((unused)) \
+/* The `deprecated` attribute only accepts a message starting in gcc 4.5.0. */
+# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500
+#  define UNUSED __attribute__((unused)) \
 	__attribute__((deprecated ("parameter declared as UNUSED")))
+# else
+#  define UNUSED __attribute__((unused))
+# endif
 #else
 #define UNUSED
 #endif
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier
  2022-10-05  9:06 [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier Jeremy Lin
@ 2022-10-05 13:14 ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 2+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-10-05 13:14 UTC (permalink / raw)
  To: Jeremy Lin; +Cc: git


On Wed, Oct 05 2022, Jeremy Lin wrote:

> Commit 9ff7eb8c88 uses the `deprecated` attribute to display a warning
> message when something that is supposed to be unused is actually used.
> However, `deprecated` only supports messages starting in gcc 4.5.0, so
> earlier versions of gcc end up bailing out with a message like
>
>   error: wrong number of arguments specified for ‘deprecated’ attribute
>
> This commit removes the use of the `deprecated` attribute for gcc 4.4.x
> and earlier. As this is just a diagnostic feature for developers, and
> presumably very few people are developing on such old systems anyway,
> this change shouldn't really impact anyone.
>
> Signed-off-by: Jeremy Lin <jeremy.lin@gmail.com>
> ---
>  git-compat-util.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index b90b64718e..9e2969edd6 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -190,8 +190,13 @@ struct strbuf;
>  #define _SGI_SOURCE 1
>  
>  #if defined(__GNUC__)
> -#define UNUSED __attribute__((unused)) \
> +/* The `deprecated` attribute only accepts a message starting in gcc 4.5.0. */
> +# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500
> +#  define UNUSED __attribute__((unused)) \
>  	__attribute__((deprecated ("parameter declared as UNUSED")))
> +# else
> +#  define UNUSED __attribute__((unused))
> +# endif
>  #else
>  #define UNUSED
>  #endif

There's an earlier discussion & patch at
https://lore.kernel.org/git/20221003212318.3092010-1-asedeno@google.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-05 13:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05  9:06 [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier Jeremy Lin
2022-10-05 13:14 ` Ævar Arnfjörð Bjarmason

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 NNTP newsgroup(s).