[CLN-list] [patch] do not use `exit' in tests
Bruno Haible
bruno at clisp.org
Wed Apr 19 18:15:03 CEST 2006
Ralf Wildenhues wrote:
> Upcoming Autoconf-2.60 will not provide a declaration for exit;
> it has turned out that tracking MSVC incompatibilites here is
> a lot of work. Instead, returning from main is suggested as a
> viable alternative (the systems where that was not portable are
> not likely to be used any more).
CLN is meant to run only on modern systems, where the <stdlib.h> file
is made compatible for C++. Therefore, and because 'return' is more
restricted than 'exit' (it can only be used in the main() function,
not in other functions invoked by main()), I'm changing CLN to simply
do a
#include <stdlib.h>
where needed. Thanks for reporting the problem.
Bruno
2006-04-19 Bruno Haible <bruno at clisp.org>
Prepare for autoconf-2.60.
* general.m4 (CL_CC_WORKS): Include <stdlib.h>, for exit() declaration.
* longdouble.m4 (CL_LONGDOUBLE): Likewise.
* longlong.m4 (CL_LONGLONG): Likewise.
* times.m4 (CL_TIMES_CLOCK): Likewise.
Reported by Ralf Wildenhues <Ralf.Wildenhues at gmx.de>.
diff -c -3 -r1.1 general.m4
*** m4/general.m4 29 Aug 2005 13:18:40 -0000 1.1
--- m4/general.m4 19 Apr 2006 16:09:53 -0000
***************
*** 93,99 ****
[AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
AC_LANG_SAVE()
AC_LANG_C()
! AC_TRY_RUN([int main() { exit(0); }],
cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
AC_LANG_RESTORE()
--- 93,102 ----
[AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
AC_LANG_SAVE()
AC_LANG_C()
! AC_TRY_RUN([
! #include <stdlib.h>
! int main() { exit(0); }
! ],
cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
AC_LANG_RESTORE()
diff -c -3 -r1.1 longdouble.m4
*** m4/longdouble.m4 29 Aug 2005 13:18:40 -0000 1.1
--- m4/longdouble.m4 19 Apr 2006 16:09:53 -0000
***************
*** 11,18 ****
AC_DEFUN([CL_LONGDOUBLE],
[AC_CACHE_CHECK(for long double type, cl_cv_c_longdouble, [
! AC_TRY_RUN([int main()
! { long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }],
cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no, [
dnl When cross-compiling, use the test from gnulib.
AC_TRY_COMPILE([
--- 11,21 ----
AC_DEFUN([CL_LONGDOUBLE],
[AC_CACHE_CHECK(for long double type, cl_cv_c_longdouble, [
! AC_TRY_RUN([
! #include <stdlib.h>
! int main()
! { long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }
! ],
cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no, [
dnl When cross-compiling, use the test from gnulib.
AC_TRY_COMPILE([
diff -c -3 -r1.1 longlong.m4
*** m4/longlong.m4 29 Aug 2005 13:18:40 -0000 1.1
--- m4/longlong.m4 19 Apr 2006 16:09:53 -0000
***************
*** 12,18 ****
AC_DEFUN([CL_LONGLONG],
[AC_CACHE_CHECK(for long long type, cl_cv_c_longlong, [
! AC_TRY_RUN([int main()
{
/* long longs don't work right with gcc-2.7.2 on m68k */
/* long longs don't work right with gcc-2.7.2 on rs6000: avcall/tests.c gets
--- 12,20 ----
AC_DEFUN([CL_LONGLONG],
[AC_CACHE_CHECK(for long long type, cl_cv_c_longlong, [
! AC_TRY_RUN([
! #include <stdlib.h>
! int main()
{
/* long longs don't work right with gcc-2.7.2 on m68k */
/* long longs don't work right with gcc-2.7.2 on rs6000: avcall/tests.c gets
diff -c -3 -r1.1 times.m4
*** m4/times.m4 29 Aug 2005 13:18:40 -0000 1.1
--- m4/times.m4 19 Apr 2006 16:09:53 -0000
***************
*** 17,22 ****
--- 17,23 ----
if test -z "$no_times"; then
AC_CACHE_CHECK(for times return value, cl_cv_func_times_return, [
AC_TRY_RUN([
+ #include <stdlib.h> /* needed for exit() */
#include <sys/types.h>
#include <time.h> /* needed for CLK_TCK */
#ifndef CLK_TCK
More information about the CLN-list
mailing list