Bug#992981: autoconf: AC_CHECK_LIB no longer works with g++
Control: tags -1 patch
On 2021-08-26 00:09:07 +0200, Vincent Lefevre wrote:
> On 2021-08-25 23:56:45 +0200, Vincent Lefevre wrote:
> > I've found the cause. With Autoconf 2.69, there was
> >
> > #ifdef __cplusplus
> > extern "C"
> > #endif
> >
> > at the beginning of the test program generated by Autoconf.
> > This is no longer the case with Autoconf 2.71. A manual test
> > confirms that these 3 lines make the difference.
>
> It seems that upstream commit 326c9a547423d25c621bc5c0ef76edbf6eda8c92
> is the cause. I'm going to test with the 3 lines re-added and provide
> a patch if this works.
Patch attached. I tested it and solves the failure with GNU MPFR.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Description: Fix generation of C code for C++ compilers.
AC_CHECK_LIB fails with a C++ compiler (e.g., g++) because
#ifdef __cplusplus
extern "C"
#endif
is missing in the generated C code. There 3 lines were removed
in commit 326c9a547423d25c621bc5c0ef76edbf6eda8c92 on 2020-10-09
with the comment "(AC_LANG_CALL(C)): Remove #ifdef __cplusplus,
this macro is no longer used to generate C++ code." but this is
actually C code compiled with a C++ compiler, not C++ code.
Author: Vincent Lefevre <vincent@vinc17.net>
Bug-Debian: https://bugs.debian.org/992981
Last-Update: 2021-08-25
Index: b/lib/autoconf/c.m4
===================================================================
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -127,6 +127,9 @@ m4_if([$2], [main], ,
[/* 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
+extern "C"
+#endif
char $2 ();])], [return $2 ();])])
Reply to: