]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-compat-util.h: GCC deprecated message arg only in GCC 4.5+
authorAlejandro R. Sedeño <asedeno@mit.edu>
Wed, 5 Oct 2022 22:19:28 +0000 (18:19 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Oct 2022 02:09:59 +0000 (19:09 -0700)
https://gcc.gnu.org/gcc-4.5/changes.html says

  The deprecated attribute now takes an optional string argument, for
  example, __attribute__((deprecated("text string"))), that will be
  printed together with the deprecation warning.

While GCC 4.5 is already 12 years old, git checks for even older
versions in places. Let's not needlessly break older compilers when
a small and simple fix is readily available.

Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h

index 71a004be40966ea8e152f4cff6b774efd86583f7..06e647ee494d74a2cf8ac473037b36595f5b4069 100644 (file)
@@ -189,9 +189,12 @@ struct strbuf;
 #define _NETBSD_SOURCE 1
 #define _SGI_SOURCE 1
 
-#if defined(__GNUC__)
+#if GIT_GNUC_PREREQ(4, 5)
 #define UNUSED __attribute__((unused)) \
        __attribute__((deprecated ("parameter declared as UNUSED")))
+#elif defined(__GNUC__)
+#define UNUSED __attribute__((unused)) \
+       __attribute__((deprecated))
 #else
 #define UNUSED
 #endif