bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Correct interaction between gl_ANSI_CXX and AC_PROG_CXX


From: Bruno Haible
Subject: Correct interaction between gl_ANSI_CXX and AC_PROG_CXX
Date: Mon, 07 Dec 2020 14:09:08 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-193-generic; KDE/5.18.0; x86_64; ; )

On 2020-08-18 I encountered a weird interaction between gl_ANSI_CXX
(used when the C++ compiler is optional) and AC_PROG_CXX (used when
the C++ compiler is mandatory). I scratched my head against it.
Zack Weinberg scratched his head against it. The difference is that
Zack found the solution :-)


2020-12-07  Bruno Haible  <bruno@clisp.org>

        Correct interaction between gl_ANSI_CXX and AC_PROG_CXX.
        Suggested by Zack Weinberg in
        <https://savannah.gnu.org/support/?110294>.
        * m4/ansi-c++.m4 (gl_ANSI_CXX): Mark AC_PROG_CXX as provided.
        * modules/uchar-c++-tests: Revert the workaround from 2020-08-18.

diff --git a/m4/ansi-c++.m4 b/m4/ansi-c++.m4
index f93c324..1b81996 100644
--- a/m4/ansi-c++.m4
+++ b/m4/ansi-c++.m4
@@ -1,4 +1,4 @@
-# ansi-c++.m4 serial 11
+# ansi-c++.m4 serial 12
 dnl Copyright (C) 2002-2003, 2005, 2010-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -145,4 +145,8 @@ EOF
 AC_DEFUN([gl_ANSI_CXX],
 [
   gl_PROG_ANSI_CXX([CXX], [ANSICXX])
+  dnl This line is needed in order to avoid trouble with Autoconf.  It makes
+  dnl sure that Autoconf does not insert expansions of AC_PROG_CXX at random
+  dnl places.  See <https://savannah.gnu.org/support/?110294>.
+  m4_provide([AC_PROG_CXX])
 ])
diff --git a/modules/uchar-c++-tests b/modules/uchar-c++-tests
index 351bdff..2cbc331 100644
--- a/modules/uchar-c++-tests
+++ b/modules/uchar-c++-tests
@@ -16,16 +16,15 @@ if test "$CXX" != no; then
   dnl have the <cuchar> header file from C++11.
   AC_CACHE_CHECK([whether the C++ compiler has <cuchar>],
     [gl_cv_cxxheader_cuchar],
-    [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
-     dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
-     echo '#include <cuchar>' > conftest.cpp
-     gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
-     if AC_TRY_EVAL([gl_command]); then
-       gl_cv_cxxheader_cuchar=yes
-     else
-       gl_cv_cxxheader_cuchar=no
-     fi
-     rm -fr conftest*
+    [AC_LANG_PUSH([C++])
+     AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <cuchar>]],
+          [[]])
+       ],
+       [gl_cv_cxxheader_cuchar=yes],
+       [gl_cv_cxxheader_cuchar=no])
+     AC_LANG_POP([C++])
     ])
 else
   gl_cv_cxxheader_cuchar=no




reply via email to

[Prev in Thread] Current Thread [Next in Thread]