autoconf-patches
[Top][All Lists]
Advanced

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

Re: 91-c++-exit-decl.patch


From: Akim Demaille
Subject: Re: 91-c++-exit-decl.patch
Date: 11 Jan 2001 16:12:17 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Crater Lake)

>>>>> "Alexandre" == Alexandre Oliva <address@hidden> writes:

Alexandre> I wouldn't worry about these.  The C++ Standard mandates
Alexandre> the presence of <stdlib.h>.  But, if you really care, we
Alexandre> should make sure the selected declaration of exit works
Alexandre> with *all* ac_include alternatives, not with just one of
Alexandre> them.  I suggest moving the ac_declaration loop out of that
Alexandre> of ac_include, and breaking out of the first loop in case
Alexandre> some test fails, and breaking out of the second loop if all
Alexandre> tests pass.  But I'd limit the ac_include loop to just
Alexandre> <stdlib.h> and no-includes.  Unless we test for cstdlib
Alexandre> first and #include it conditionally.  I don't feel a need
Alexandre> for that, though.

Here is what I applied.  I took the freedom to apply it directly to
ease testing, but as usual...

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * aclang.m4 (_AC_PROG_CXX_EXIT_DECLARATION): New.
        (AC_PROG_CC, AC_PROG_CXX): Use it.
        (AC_PROG_CC_STDC): Be sure to remove tmp files.
        * tests/compile.at (AC_TRY_LINK_FUNC): Don't use exit to test it,
        since it produces a prototype which conflicts with the one
        computed by _AC_PROG_CXX_EXIT_DECLARATION.
        * tests/semantics.at (AC_CHECK_FUNCS, AC_HAVE_FUNCS): Likewise.
        (AC_HAVE_FUNCS): Test AC_HAVE_FUNCS!

Index: TODO
===================================================================
RCS file: /cvs/autoconf/TODO,v
retrieving revision 1.99
diff -u -u -r1.99 TODO
--- TODO 2000/11/14 13:25:36 1.99
+++ TODO 2001/01/11 15:14:17
@@ -40,6 +40,12 @@
 Chose a means to declare patterns to catch, means to escape the
 control, and document it.
 
+** AC_CHECK_FUNCS and AC_TRY_LINK_FUNC
+I have still not understood what's the difference  between the two
+which requires to have two different sources: AC_LANG_CALL and
+AC_LANG_FUNC_LINK_TRY (which names seem to be inappropriate).
+Wouldn't one be enough?
+
 * Autoconf 2.51 or so
 
 ** AC_FUNC_GETLOADAVG
Index: aclang.m4
===================================================================
RCS file: /cvs/autoconf/aclang.m4,v
retrieving revision 1.105
diff -u -u -r1.105 aclang.m4
--- aclang.m4 2001/01/11 14:14:00 1.105
+++ aclang.m4 2001/01/11 15:14:22
@@ -405,7 +405,7 @@
 # We need `stdio.h' to open a `FILE', so the prologue defaults to the
 # inclusion of `stdio.h'.
 m4_define([AC_LANG_INT_SAVE(C)],
-[AC_LANG_PROGRAM([m4_default([$1], address@hidden:@include "stdio.h"])],
+[AC_LANG_PROGRAM([m4_default([$1], address@hidden:@include <stdio.h>])],
 [FILE *f = fopen ("conftestval", "w");
 if (!f)
   exit (1);
@@ -419,42 +419,31 @@
 
 # AC_LANG_SOURCE(C++)(BODY)
 # -------------------------
-m4_define([AC_LANG_SOURCE(C++)],
-[#line __oline__ "configure"
-#include "confdefs.h"
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-$1])
+m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
 
 
 # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
 # ----------------------------------------
-# Same as C.
 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
 
 
 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
 # -------------------------------------
-# Same as C.
 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
 
 
 # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
 # ------------------------------------
-# Same as C.
 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
 
 
 # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
 # ---------------------------------------------------
-# Same as C.
 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
 
 
 # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
 # -------------------------------------------
-# Same as C.
 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
 
 
@@ -879,6 +868,14 @@
 AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
 AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
 _AC_PROG_CC_G
+# Some people use a C++ compiler to compile C.  Since we use `exit',
+# in C++ we need to declare it.  In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+_AC_COMPILE_IFELSE(address@hidden:@ifndef __cplusplus
+  choke me
address@hidden:@endif],
+                   [_AC_PROG_CXX_EXIT_DECLARATION])
 AC_LANG_POP
 ])# AC_PROG_CC
 
@@ -987,7 +984,6 @@
 ])# AC_PROG_CC_C_O
 
 
-
 # ---------------------- #
 # 3c. The C++ compiler.  #
 # ---------------------- #
@@ -1076,6 +1072,7 @@
 AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
 AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
 _AC_PROG_CXX_G
+_AC_PROG_CXX_EXIT_DECLARATION
 AC_LANG_POP
 ])# AC_PROG_CXX
 
@@ -1111,7 +1108,33 @@
 ])# _AC_PROG_CXX_G
 
 
+# _AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
+[for ac_declaration in \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);' \
+   ''
+do
+  _AC_COMPILE_IFELSE([AC_LANG_PROGRAM(address@hidden:@include <stdlib.h>
+$ac_declaration],
+                                      [exit (42);])],
+                     [],
+                     [continue])
+  _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
+                                      [exit (42);])],
+                     [break])
+done
+echo '#ifdef __cplusplus' >>confdefs.h
+echo $ac_declaration      >>confdefs.h
+echo '#endif'             >>confdefs.h
+])# _AC_PROG_CXX_EXIT_DECLARATION
 
+
 # ----------------------------- #
 # 3d. The Fortran 77 compiler.  #
 # ----------------------------- #
@@ -1317,9 +1340,9 @@
   CC="$ac_save_CC $ac_arg"
   AC_COMPILE_IFELSE([],
                     [ac_cv_prog_cc_stdc=$ac_arg
-rm -f conftest.$ac_ext conftest.$ac_objext
 break])
 done
+rm -f conftest.$ac_ext conftest.$ac_objext
 CC=$ac_save_CC
 ])
 case "x$ac_cv_prog_cc_stdc" in
Index: tests/compile.at
===================================================================
RCS file: /cvs/autoconf/tests/compile.at,v
retrieving revision 1.11
diff -u -u -r1.11 compile.at
--- tests/compile.at 2000/12/20 13:48:08 1.11
+++ tests/compile.at 2001/01/11 15:14:24
@@ -109,8 +109,8 @@
 ## ------------------ ##
 
 AT_CHECK_MACRO([AC_TRY_LINK_FUNC],
-[AC_TRY_LINK_FUNC(exit,,
-                  [AC_MSG_ERROR([cannot find `exit'])])
+[AC_TRY_LINK_FUNC(printf,,
+                  [AC_MSG_ERROR([cannot find `printf'])])
 AC_TRY_LINK_FUNC(Be_doomed_if_your_libc_has_a_function_named_like_this,
                  [AC_MSG_ERROR([found a nonexistent function])])])
 
Index: tests/semantics.at
===================================================================
RCS file: /cvs/autoconf/tests/semantics.at,v
retrieving revision 1.13
diff -u -u -r1.13 semantics.at
--- tests/semantics.at 2000/12/23 10:11:59 1.13
+++ tests/semantics.at 2001/01/11 15:14:24
@@ -38,12 +38,12 @@
 # AC_CHECK_FUNCS
 # --------------
 # Check that it performs the correct actions:
-# Must define HAVE_EXIT, but not HAVE_AUTOCONF_TIXE
+# Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
 AT_CHECK_MACRO([AC_CHECK_FUNCS],
-[AC_CHECK_FUNCS(exit autoconf_tixe)],
+[AC_CHECK_FUNCS(printf autoconf_ftnirp)],
 [AT_CHECK_DEFINES(
-[/* #undef HAVE_AUTOCONF_TIXE */
-#define HAVE_EXIT 1
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+#define HAVE_PRINTF 1
 ])])
 
 
@@ -52,10 +52,10 @@
 # This macro is an obsolete version of AC_CHECK_FUNCS.  Running this
 # test allows to check that AU_ALIAS'ed macros work properly.
 AT_CHECK_MACRO([AC_HAVE_FUNCS],
-[AC_CHECK_FUNCS(exit autoconf_tixe)],
+[AC_HAVE_FUNCS(printf autoconf_ftnirp)],
 [AT_CHECK_DEFINES(
-[/* #undef HAVE_AUTOCONF_TIXE */
-#define HAVE_EXIT 1
+[/* #undef HAVE_AUTOCONF_FTNIRP */
+#define HAVE_PRINTF 1
 ])])
 
 



reply via email to

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