On 2026-10-17 16:49, Bruno Haible via Discussion list for the autoconf build 
system wrote:
PS: An alternative fix of the problem is to change the body of AC_CHECK_FUNC,
instead of adding a compiler option.

Thanks, good idea. We can fix a similar glitch with recent Clang too. I 
installed the attached to Autoconf.

I assume we should propagate this into Gnulib, and use it instead of the recent 
Gnulib patch that changes compiler options? That would let us test this 
approach in Gnulib-using programs before the next Autoconf release comes out.
From 197e03ed151830cf44090d3f7540d1acb403809d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 17 Oct 2026 18:08:51 -0700
Subject: [PATCH] Fix AC_CHECK_FUNC with pedantic Clang, MSVC

From a suggestion by Bruno Haible in:
https://lists.gnu.org/r/autoconf/2026-10/msg00002.html
* lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)):
Pacify Clang and MSVC if their builtin decl disagrees.
---
 NEWS              |  5 +++++
 lib/autoconf/c.m4 | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 37b021e3..edcdc5e4 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,11 @@ GNU Autoconf NEWS - User visible changes.
 
 *** AC_C_RESTRICT no longer triggers -Wkeyword-macro warnings from GCC 16.
 
+*** AC_CHECK_FUNC and related macros now work better with Clang and MSVC.
+
+  Arguments like CFLAGS="-Wno-incompatible-library-redeclaration" are
+  no longer needed when configuring with Clang, and similarly with MSVC.
+
 * Noteworthy changes in release 2.73 (2026-03-20) [release]
 
 ** New features
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index b22df0df..9d264b2a 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -161,10 +161,20 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 
 /* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $1 (void); below.  */
-
 #include <limits.h>
 #undef $1
 
+/* Tell Clang to allow disagreement with declaration of builtin $1.  */
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wincompatible-library-redeclaration"
+#endif
+
+/* Tell MSVC to forget about builtin $1.  */
+#ifdef _MSC_VER
+__pragma (warning (disable : 4163))
+__pragma (function ($1))
+#endif
+
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
    builtin and then its argument prototype would still apply.  */
-- 
2.53.0

Reply via email to