All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Cc: git@vger.kernel.org, "Alejandro R Sedeño" <asedeno@google.com>,
	"Alejandro R. Sedeño" <asedeno@MIT.EDU>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH] compat/posix.h: enable UNUSED warning messages for Clang
Date: Mon, 04 May 2026 10:41:16 +0900	[thread overview]
Message-ID: <xmqqqznsossj.fsf@gitster.g> (raw)
In-Reply-To: <xmqq1pfsq8sd.fsf@gitster.g> (Junio C. Hamano's message of "Mon, 04 May 2026 10:10:26 +0900")

Junio C Hamano <gitster@pobox.com> writes:

>> I am not familiar with git's minimum compiler version but this patch
>> drops support for Clang < 2.9 from 2011.
>
> Does this "drop support" because you force _all_ versions of Clang
> to use the "deprecated" attribute, even though you _know_ some older
> versions do not understand it?  Don't these versions identify
> themselves so that you can do
>
> 	#if defined(__clang__) && CLANG_VERSION >= 2.9
>
> I do not know if the userbase of GCC and Clang upgrade with a
> similar cadence, or we seem to say that we care about GCC 4.5
> (2010), so giving  a similar version detection for Clang and exclude
> ones older than 2.9 sounds more appropriate.

IOW, something like this, perhaps?

 compat/posix.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git c/compat/posix.h w/compat/posix.h
index faaae1b655..0dd0637fc9 100644
--- c/compat/posix.h
+++ w/compat/posix.h
@@ -22,6 +22,17 @@
  #define GIT_GNUC_PREREQ(maj, min) 0
 #endif
 
+/*
+ * Similar for clang 
+ */
+#if defined(__clang__) && defined(__clang_minor__) && defined(__clang_major__)
+# define GIT_CLANG_PREREQ(maj, min) \
+	((__clang_major__ > (maj)) || \
+	 (__clang_major__ == (maj) && (__clang_minor__ >= (min))))
+#else
+# define GIT_CLANG_PREREQ(maj, min) 0
+#endif
+
 /*
  * UNUSED marks a function parameter that is always unused.  It also
  * can be used to annotate a function, a variable, or a type that is
@@ -35,7 +46,7 @@
  * When a parameter may be used or unused, depending on conditional
  * compilation, consider using MAYBE_UNUSED instead.
  */
-#if GIT_GNUC_PREREQ(4, 5)
+#if GIT_GNUC_PREREQ(4, 5) || GIT_CLANG_PREREQ(2, 9)
 #define UNUSED __attribute__((unused)) \
 	__attribute__((deprecated ("parameter declared as UNUSED")))
 #elif defined(__GNUC__)

  reply	other threads:[~2026-05-04  1:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-03 15:12 [PATCH] compat/posix.h: enable UNUSED warning messages for Clang Dominik Loidolt
2026-05-04  1:10 ` Junio C Hamano
2026-05-04  1:41   ` Junio C Hamano [this message]
2026-06-05  8:44     ` Dominik Loidolt
2026-06-05  9:46 ` [PATCH v2] " Dominik Loidolt
2026-06-05 10:40   ` Patrick Steinhardt
2026-06-05 11:50     ` Dominik Loidolt
2026-06-05 13:22       ` Patrick Steinhardt
2026-06-05 15:53         ` Dominik Loidolt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqqznsossj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=asedeno@MIT.EDU \
    --cc=asedeno@google.com \
    --cc=avarab@gmail.com \
    --cc=dominik.loidolt@univie.ac.at \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.