Bug 18829 - autoconf broken with c++ in AC_TRY_RUN
Summary: autoconf broken with c++ in AC_TRY_RUN
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: autoconf   
(Show other bugs)
Version: 7.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jens Petersen
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2000-10-10 16:35 UTC by Stefan Sorensen
Modified: 2007-04-18 16:29 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-07-10 11:02:46 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Stefan Sorensen 2000-10-10 16:35:25 UTC
AC_TRY_RUN tests that include stdlib.h and with the language set to c++
fails with the error:

In file included from configure:541:
/usr/include/stdlib.h:578: declaration of `void exit (int) throw ()' 
throws different exceptions
configure:538: than previous declaration `void exit (int)'
configure: failed program was:
#line 536 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);

#include <stdlib.h>

Reproduced by the following configure.in script:
AC_TRY_RUN([#include <stdlib.h>], , AC_MSG_ERROR(Aaaaargh))


--- autoconf-2.13/acgeneral.m4.orig     Sat Sep 23 12:00:12 2000
+++ autoconf-2.13/acgeneral.m4  Sat Sep 23 12:00:23 2000
@@ -1817,10 +1817,6 @@
 [cat > conftest.$ac_ext <<EOF
 [#]line __oline__ "configure"
 #include "confdefs.h"
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest;
exit) 2>/dev/null

Comment 1 Nakai 2000-11-15 11:19:21 UTC
This bug also cause a fatal error when we install the gtkmm and make new apps
that uses AM_PATH_GTKMM macro in its

But I think this is better patch for this.
Thank you.

--- autoconf-2.13/acgeneral.m4.orig	Tue Jan  5 22:27:37 1999
+++ autoconf-2.13/acgeneral.m4	Sun Nov 12 04:17:10 2000
@@ -1818,7 +1818,7 @@
 [#]line __oline__ "configure"
 #include "confdefs.h"
 ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
+extern "C" void exit(int) throw();

Comment 2 tanner 2001-02-01 22:46:19 UTC
Looks like there functional prototype is in more then just acgeneral.m4

# pwd

# grep -i 'extern "C" void exit(int)' *
acgeneral.m4:extern "C" void exit(int) throw();
autoconf.m4f:extern "C" void exit(int);
autoheader.m4f:extern "C" void exit(int);

Trying to compile gnomemm-1.1.14 on Redhat 7.0

I applied the above patch to acgeneral.m4

$ pwd
		Make sure to remove old configure and rebuild it
$ rm configure
$  automake ; autoconf
$ ./configure  --prefix=/usr --disable-maintainer-mode --disable-static
--enable-shared --enable-docs
 checking for GTK-- - version >= 1.2.3... no
*** Could not run GTK-- test program, checking why...
$ grep -i 'extern "C" void exit(int)' *
config.log:extern "C" void exit(int);
configure:extern "C" void exit(int);
configure:extern "C" void exit(int);

That patch is not pickedup by automake or autoconf. 

Comment 3 Murray Cumming 2001-03-06 20:20:27 UTC
So how wil this be resolved? Is it an autoconf bug, or a gcc bug?

Comment 4 Jens Petersen 2001-06-21 05:17:31 UTC
[Yukihiro Nakai's patch is in autoconf-2.13-10 (Red Hat 7.1).]
And I checked that
   AC_TRY_RUN([#include <stdlib.h>], , AC_MSG_ERROR(Aaaaargh))
autoconf'ed ok with autoconf-2.13-10.

Also configure of gnomemm runs ok (both 1.1.14 and 1.1.21).

So since all the above seems to have been fixed in 7.1,
I suggest that this bug can be closed.

Comment 5 Murray Cumming 2001-06-21 07:08:12 UTC
No, gnomemm configure works because we patched our own copies of aclocal, or
edited the generated configure scripts before distributing gnomemm.

Yukihiro Nakai's patch would not work because it would create configure scripts
that worked on Redhat but not on other platforms. Our solution was to remove the
void exit declaration line completely.

To test any solution, you would need to autogen.sh gnomemm on both Redhat and an
older distribution, then try to configure the resultant distributions on the
other distributions.

Comment 6 Jens Petersen 2001-06-26 08:28:49 UTC
Thanks for the comment.

So I back-ported _AC_PROG_CXX_EXIT_DECLARATION from autoconf-2.50, where this
problem has already be addressed. The patch below should hopefully allow
autoconf to generate configure files for C++ that will work on many platforms.
I hope this makes C++ users happy.

--- autoconf-2.13/acgeneral.m4~	Tue Jun 26 17:00:28 2001
+++ autoconf-2.13/acgeneral.m4	Tue Jun 26 17:00:28 2001
@@ -1817,10 +1817,6 @@
 [cat > conftest.$ac_ext <<EOF
 [#]line __oline__ "configure"
 #include "confdefs.h"
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest; exit)
--- autoconf-2.13/acspecific.m4~	Tue Jun 26 17:04:34 2001
+++ autoconf-2.13/acspecific.m4		Tue Jun 26 17:04:34 2001
@@ -152,8 +152,41 @@
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+[for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   '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);'
+  AC_TRY_COMPILE([#include <stdlib.h>
+                 [exit (42);],
+                 [],
+                 [continue])
+  AC_TRY_COMPILE([$ac_declaration],
+                 [exit (42);],
+                 [break])
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
 dnl Determine a Fortran 77 compiler to use.  If `F77' is not already set
 dnl in the environment, check for `g77', `f77' and `f2c', in that order.
 dnl Set the output variable `F77' to the name of the compiler found.

Note You need to log in before you can comment on or make changes to this bug.