On 2026-10-18 13:06, Bruno Haible wrote:
I propose the additional attached patch.

Thanks, I installed that.

Would the attached work for MSVC? I am still trying to avoid fiddling with 
compilation flags; perhaps I am trying too hard.
From 1261c62f3a69901b6539c02aa1a734cefefc34cb Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sun, 18 Oct 2026 18:24:02 -0700
Subject: [PATCH] Fix AC_CHECK_FUNC for MSVC with a linker pragma
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)): For MSVC, use
‘#pragma comment (linker, "/include:_foo")’, not ‘char
foo(void);’, to check whether foo exists
---
 lib/autoconf/c.m4 | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 8d9cfe64..15f09720 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -169,13 +169,26 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 # pragma clang diagnostic ignored "-Wincompatible-library-redeclaration"
 #endif
 
+#ifdef _MSC_VER
+
+/* Tell MSVC to link the function without checking its type.  */
+# ifdef _M_IX86
+#  pragma comment (linker, "/include:_$1")
+# else
+#  pragma comment (linker, "/include:$1")
+# endif
+
+#else
+
 /* 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.  */
-#ifdef __cplusplus
+# ifdef __cplusplus
 extern "C"
-#endif
+# endif
 char $1 (void);
+#endif
+
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-- 
2.53.0

Reply via email to