git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Oct 5, 2022, 13:14 UTC
Message-ID
<221005.86pmf6s978.gmgdl@evledraar.gmail.com>
In-Reply-To
<20221005090650.3172-1-jeremy.lin@gmail.com>
On Wed, Oct 05 2022, Jeremy Lin wrote:
Show 36 quoted lines
> 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/

Previous: Jeremy Lin
Message 2 of 2 in “git-compat-util.h: fix build on gcc 4.4.x and earlier”
  1. git-compat-util.h: fix build on gcc 4.4.x and earlierJeremy Lin, Oct 5, 2022
  2. Ævar Arnfjörð BjarmasonOct 5, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.