{"thread":{"id":"58567","subject":"[PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier","startedAt":"2022-10-05T09:06:57Z","lastAt":"2022-10-05T13:15:40Z","messageCount":2,"participants":["Jeremy Lin","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"464219","messageId":"20221005090650.3172-1-jeremy.lin@gmail.com","threadId":"58567","inReplyTo":null,"subject":"[PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier","fromName":"Jeremy Lin","fromEmail":"jeremy.lin@gmail.com","sentAt":"2022-10-05T09:06:50Z","receivedAt":"2022-10-05T09:06:57Z","isPatch":true,"sender":{"key":"jeremy.lin@gmail.com","avatar":null},"body":"Commit 9ff7eb8c88 uses the `deprecated` attribute to display a warning\nmessage when something that is supposed to be unused is actually used.\nHowever, `deprecated` only supports messages starting in gcc 4.5.0, so\nearlier versions of gcc end up bailing out with a message like\n\n  error: wrong number of arguments specified for ‘deprecated’ attribute\n\nThis commit removes the use of the `deprecated` attribute for gcc 4.4.x\nand earlier. As this is just a diagnostic feature for developers, and\npresumably very few people are developing on such old systems anyway,\nthis change shouldn't really impact anyone.\n\nSigned-off-by: Jeremy Lin <jeremy.lin@gmail.com>\n---\n git-compat-util.h | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex b90b64718e..9e2969edd6 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -190,8 +190,13 @@ struct strbuf;\n #define _SGI_SOURCE 1\n \n #if defined(__GNUC__)\n-#define UNUSED __attribute__((unused)) \\\n+/* The `deprecated` attribute only accepts a message starting in gcc 4.5.0. */\n+# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500\n+#  define UNUSED __attribute__((unused)) \\\n \t__attribute__((deprecated (\"parameter declared as UNUSED\")))\n+# else\n+#  define UNUSED __attribute__((unused))\n+# endif\n #else\n #define UNUSED\n #endif\n-- \n2.34.1\n\n"},{"id":"464228","messageId":"221005.86pmf6s978.gmgdl@evledraar.gmail.com","threadId":"58567","inReplyTo":"20221005090650.3172-1-jeremy.lin@gmail.com","subject":"Re: [PATCH] git-compat-util.h: fix build on gcc 4.4.x and earlier","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-10-05T13:14:51Z","receivedAt":"2022-10-05T13:15:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Oct 05 2022, Jeremy Lin wrote:\n\n> Commit 9ff7eb8c88 uses the `deprecated` attribute to display a warning\n> message when something that is supposed to be unused is actually used.\n> However, `deprecated` only supports messages starting in gcc 4.5.0, so\n> earlier versions of gcc end up bailing out with a message like\n>\n>   error: wrong number of arguments specified for ‘deprecated’ attribute\n>\n> This commit removes the use of the `deprecated` attribute for gcc 4.4.x\n> and earlier. As this is just a diagnostic feature for developers, and\n> presumably very few people are developing on such old systems anyway,\n> this change shouldn't really impact anyone.\n>\n> Signed-off-by: Jeremy Lin <jeremy.lin@gmail.com>\n> ---\n>  git-compat-util.h | 7 ++++++-\n>  1 file changed, 6 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index b90b64718e..9e2969edd6 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -190,8 +190,13 @@ struct strbuf;\n>  #define _SGI_SOURCE 1\n>  \n>  #if defined(__GNUC__)\n> -#define UNUSED __attribute__((unused)) \\\n> +/* The `deprecated` attribute only accepts a message starting in gcc 4.5.0. */\n> +# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40500\n> +#  define UNUSED __attribute__((unused)) \\\n>  \t__attribute__((deprecated (\"parameter declared as UNUSED\")))\n> +# else\n> +#  define UNUSED __attribute__((unused))\n> +# endif\n>  #else\n>  #define UNUSED\n>  #endif\n\nThere's an earlier discussion & patch at\nhttps://lore.kernel.org/git/20221003212318.3092010-1-asedeno@google.com/\n"}]}