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

Re: [PATCH] compat/posix.h: enable UNUSED warning messages for Clang

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2026, 01:41 UTC
Message-ID
<xmqqqznsossj.fsf@gitster.g>
In-Reply-To
<xmqq1pfsq8sd.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
>> 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__)
Previous: Junio C HamanoNext: Dominik Loidolt
Message 3 of 20 in “compat/posix.h: enable UNUSED warning messages for Clang”
  1. compat/posix.h: enable UNUSED warning messages for ClangDominik Loidolt, May 3, 2026
  2. Junio C HamanoMay 4, 2026
  3. Junio C HamanoMay 4, 2026
  4. Dominik LoidoltJun 5, 2026
  5. compat/posix.h: enable UNUSED warning messages for ClangDominik Loidolt, Jun 5, 2026
  6. Patrick SteinhardtJun 5, 2026
  7. Dominik LoidoltJun 5, 2026
  8. Patrick SteinhardtJun 5, 2026
  9. Dominik LoidoltJun 5, 2026
  10. Patrick SteinhardtJun 8, 2026
  11. 1/2 compat/posix.h: enable UNUSED warning messages for ClangDominik Loidolt, Jun 8, 2026
  12. 2/2 compat/posix.h: simplify GIT_GNUC_PREREQ() comparisonDominik Loidolt, Jun 8, 2026
  13. Patrick SteinhardtJun 12, 2026
  14. Dominik LoidoltJun 12, 2026
  15. 0/3 compat/posix.h: enable UNUSED warning messages for ClangDominik Loidolt, Jun 13, 2026
  16. 2/3 compat/posix.h: clean up GIT_GNUC_PREREQ() and UNUSEDDominik Loidolt, Jun 13, 2026
  17. 1/3 compat/posix.h: enable UNUSED warning messages for ClangDominik Loidolt, Jun 13, 2026
  18. 3/3 compat/posix.h: simplify GIT_GNUC_PREREQ() comparisonDominik Loidolt, Jun 13, 2026
  19. Junio C HamanoJun 13, 2026
  20. Patrick SteinhardtJun 15, 2026

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.