On Cygwin 1.7.2, the C++ tests fail for ceill, floorl, roundl, truncl: ../gllib/math.h:478: error: 'ceill' was not declared in this scope ../gllib/math.h:478: error: invalid type in declaration before ';' token ../gllib/math.h:556: error: 'floorl' was not declared in this scope ../gllib/math.h:556: error: invalid type in declaration before ';' token ../gllib/math.h:703: error: 'roundl' was not declared in this scope ../gllib/math.h:703: error: invalid type in declaration before ';' token ../gllib/math.h:816: error: 'truncl' was not declared in this scope ../gllib/math.h:816: error: invalid type in declaration before ';' token
Again, it's because math.in.h is not distinguishing whether the function is being replaced or whether it is merely absent/undeclared. Similar problems also exist for ceilf etc. I'm committing this fix. It assumes that when the function exists, it is also declared. (When it is not declared, we will now define 'ceill' rather than 'rpl_ceill', which ought to not conflict with a libc or libm symbol.) But AFAIK there are no platforms on which this assumption is not true. 2010-04-04 Bruno Haible <br...@clisp.org> math: Fix some C++ test errors on Cygwin. * lib/math.in.h (ceilf, ceill, floorf, floorl, roundf, round, roundl, truncl): Provide declaration if the system does not have it. * m4/ceilf.m4 (gl_FUNC_CEILF): If the function is not declared, set HAVE_DECL_CEILF to 0, not REPLACE_CEILF to 1. * m4/ceill.m4 (gl_FUNC_CEILL): If the function is not declared, set HAVE_DECL_CEILL to 0, not REPLACE_CEILL to 1. * m4/floorf.m4 (gl_FUNC_FLOORF): If the function is not declared, set HAVE_DECL_FLOORF to 0, not REPLACE_FLOORF to 1. * m4/floorl.m4 (gl_FUNC_FLOORL): If the function is not declared, set HAVE_DECL_FLOORL to 0, not REPLACE_FLOORL to 1. * m4/round.m4 (gl_FUNC_ROUND): If the function is not declared, set HAVE_DECL_ROUND to 0, not REPLACE_ROUND to 1. * m4/roundf.m4 (gl_FUNC_ROUNDF): If the function is not declared, set HAVE_DECL_ROUNDF to 0, not REPLACE_ROUNDF to 1. * m4/roundl.m4 (gl_FUNC_ROUNDL): If the function is not declared, set HAVE_DECL_ROUNDL to 0, not REPLACE_ROUNDL to 1. * m4/truncl.m4 (gl_FUNC_TRUNCL): If the function is not declared, set HAVE_DECL_TRUNCL to 0, not REPLACE_TRUNCL to 1. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize HAVE_DECL_CEILF, HAVE_DECL_CEILL, HAVE_DECL_FLOORF, HAVE_DECL_FLOORL, HAVE_DECL_ROUND, HAVE_DECL_ROUNDF, HAVE_DECL_ROUNDL, HAVE_DECL_TRUNCL. * modules/math (Makefile.am): Substitute HAVE_DECL_CEILF, HAVE_DECL_CEILL, HAVE_DECL_FLOORF, HAVE_DECL_FLOORL, HAVE_DECL_ROUND, HAVE_DECL_ROUNDF, HAVE_DECL_ROUNDL, HAVE_DECL_TRUNCL. --- lib/math.in.h.orig Sun Apr 4 19:14:49 2010 +++ lib/math.in.h Sun Apr 4 18:59:16 2010 @@ -186,7 +186,10 @@ # endif _GL_FUNCDECL_RPL (ceilf, float, (float x)); _GL_CXXALIAS_RPL (ceilf, float, (float x)); -#else +# else +# if !...@have_decl_ceilf@ +_GL_FUNCDECL_SYS (ceilf, float, (float x)); +# endif _GL_CXXALIAS_SYS (ceilf, float, (float x)); # endif _GL_CXXALIASWARN (ceilf); @@ -206,6 +209,9 @@ _GL_FUNCDECL_RPL (ceill, long double, (long double x)); _GL_CXXALIAS_RPL (ceill, long double, (long double x)); # else +# if !...@have_decl_ceill@ +_GL_FUNCDECL_SYS (ceill, long double, (long double x)); +# endif _GL_CXXALIAS_SYS (ceill, long double, (long double x)); # endif _GL_CXXALIASWARN (ceill); @@ -265,6 +271,9 @@ _GL_FUNCDECL_RPL (floorf, float, (float x)); _GL_CXXALIAS_RPL (floorf, float, (float x)); #else +# if !...@have_decl_floorf@ +_GL_FUNCDECL_SYS (floorf, float, (float x)); +# endif _GL_CXXALIAS_SYS (floorf, float, (float x)); # endif _GL_CXXALIASWARN (floorf); @@ -284,6 +293,9 @@ _GL_FUNCDECL_RPL (floorl, long double, (long double x)); _GL_CXXALIAS_RPL (floorl, long double, (long double x)); # else +# if !...@have_decl_floorl@ +_GL_FUNCDECL_SYS (floorl, long double, (long double x)); +# endif _GL_CXXALIAS_SYS (floorl, long double, (long double x)); # endif _GL_CXXALIASWARN (floorl); @@ -391,6 +403,9 @@ _GL_FUNCDECL_RPL (roundf, float, (float x)); _GL_CXXALIAS_RPL (roundf, float, (float x)); # else +# if !...@have_decl_roundf@ +_GL_FUNCDECL_SYS (roundf, float, (float x)); +# endif _GL_CXXALIAS_SYS (roundf, float, (float x)); # endif _GL_CXXALIASWARN (roundf); @@ -411,6 +426,9 @@ _GL_FUNCDECL_RPL (round, double, (double x)); _GL_CXXALIAS_RPL (round, double, (double x)); # else +# if !...@have_decl_round@ +_GL_FUNCDECL_SYS (round, double, (double x)); +# endif _GL_CXXALIAS_SYS (round, double, (double x)); # endif _GL_CXXALIASWARN (round); @@ -431,6 +449,9 @@ _GL_FUNCDECL_RPL (roundl, long double, (long double x)); _GL_CXXALIAS_RPL (roundl, long double, (long double x)); # else +# if !...@have_decl_roundl@ +_GL_FUNCDECL_SYS (roundl, long double, (long double x)); +# endif _GL_CXXALIAS_SYS (roundl, long double, (long double x)); # endif _GL_CXXALIASWARN (roundl); @@ -544,6 +565,9 @@ _GL_FUNCDECL_RPL (truncl, long double, (long double x)); _GL_CXXALIAS_RPL (truncl, long double, (long double x)); # else +# if !...@have_decl_truncl@ +_GL_FUNCDECL_SYS (truncl, long double, (long double x)); +# endif _GL_CXXALIAS_SYS (truncl, long double, (long double x)); # endif _GL_CXXALIASWARN (truncl); --- m4/ceilf.m4.orig Sun Apr 4 19:14:49 2010 +++ m4/ceilf.m4 Sun Apr 4 18:29:52 2010 @@ -1,4 +1,4 @@ -# ceilf.m4 serial 5 +# ceilf.m4 serial 6 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,9 +20,9 @@ REPLACE_CEILF=1 fi else - REPLACE_CEILF=1 + HAVE_DECL_CEILF=0 fi - if test $REPLACE_CEILF = 1; then + if test $HAVE_DECL_CEILF = 0 || test $REPLACE_CEILF = 1; then AC_LIBOBJ([ceilf]) CEILF_LIBM= fi --- m4/ceill.m4.orig Sun Apr 4 19:14:49 2010 +++ m4/ceill.m4 Sun Apr 4 18:29:52 2010 @@ -1,4 +1,4 @@ -# ceill.m4 serial 5 +# ceill.m4 serial 6 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,9 +20,9 @@ REPLACE_CEILL=1 fi else - REPLACE_CEILL=1 + HAVE_DECL_CEILL=0 fi - if test $REPLACE_CEILL = 1; then + if test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; then AC_LIBOBJ([ceill]) CEILL_LIBM= fi --- m4/floorf.m4.orig Sun Apr 4 19:14:49 2010 +++ m4/floorf.m4 Sun Apr 4 18:29:53 2010 @@ -1,4 +1,4 @@ -# floorf.m4 serial 5 +# floorf.m4 serial 6 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,9 +20,9 @@ REPLACE_FLOORF=1 fi else - REPLACE_FLOORF=1 + HAVE_DECL_FLOORF=0 fi - if test $REPLACE_FLOORF = 1; then + if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then AC_LIBOBJ([floorf]) FLOORF_LIBM= fi --- m4/floorl.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/floorl.m4 Sun Apr 4 18:29:53 2010 @@ -1,4 +1,4 @@ -# floorl.m4 serial 5 +# floorl.m4 serial 6 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -20,9 +20,9 @@ REPLACE_FLOORL=1 fi else - REPLACE_FLOORL=1 + HAVE_DECL_FLOORL=0 fi - if test $REPLACE_FLOORL = 1; then + if test $HAVE_DECL_FLOORL = 0 || test $REPLACE_FLOORL = 1; then AC_LIBOBJ([floorl]) FLOORL_LIBM= fi --- m4/math_h.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/math_h.m4 Sun Apr 4 18:36:44 2010 @@ -1,4 +1,4 @@ -# math_h.m4 serial 20 +# math_h.m4 serial 21 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -100,17 +100,25 @@ HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) + HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) + HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) + HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) + HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) + HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) + HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) + HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) + HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) --- m4/round.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/round.m4 Sun Apr 4 18:40:04 2010 @@ -1,4 +1,4 @@ -# round.m4 serial 7 +# round.m4 serial 8 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,17 +12,16 @@ AC_CHECK_DECLS([round], , , [#include <math.h>]) if test "$ac_cv_have_decl_round" = yes; then gl_CHECK_MATH_LIB([ROUND_LIBM], [x = round (x);]) - fi - if test "$ac_cv_have_decl_round" = yes && test "$ROUND_LIBM" != missing; then - dnl Test whether round() produces correct results. On NetBSD 3.0, for - dnl x = 1/2 - 2^-54, the system's round() returns a wrong result. - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether round works], [gl_cv_func_round_works], - [ - save_LIBS="$LIBS" - LIBS="$LIBS $ROUND_LIBM" - AC_RUN_IFELSE([AC_LANG_SOURCE([[ + if test "$ROUND_LIBM" != missing; then + dnl Test whether round() produces correct results. On NetBSD 3.0, for + dnl x = 1/2 - 2^-54, the system's round() returns a wrong result. + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether round works], [gl_cv_func_round_works], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $ROUND_LIBM" + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <float.h> #include <math.h> int main() @@ -40,19 +39,24 @@ volatile double x = 0.5 - 0.5 / TWO_MANT_DIG; exit (x < 0.5 && round (x) != 0.0); }]])], [gl_cv_func_round_works=yes], [gl_cv_func_round_works=no], - [case "$host_os" in - netbsd*) gl_cv_func_round_works="guessing no";; - *) gl_cv_func_round_works="guessing yes";; - esac + [case "$host_os" in + netbsd*) gl_cv_func_round_works="guessing no";; + *) gl_cv_func_round_works="guessing yes";; + esac + ]) + LIBS="$save_LIBS" ]) - LIBS="$save_LIBS" - ]) - case "$gl_cv_func_round_works" in - *no) ROUND_LIBM=missing ;; - esac + case "$gl_cv_func_round_works" in + *no) ROUND_LIBM=missing ;; + esac + fi + if test "$ROUND_LIBM" = missing; then + REPLACE_ROUND=1 + fi + else + HAVE_DECL_ROUND=0 fi - if test "$ac_cv_have_decl_round" != yes || test "$ROUND_LIBM" = missing; then - REPLACE_ROUND=1 + if test $HAVE_DECL_ROUND = 0 || test $REPLACE_ROUND = 1; then AC_LIBOBJ([round]) gl_FUNC_FLOOR_LIBS gl_FUNC_CEIL_LIBS --- m4/roundf.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/roundf.m4 Sun Apr 4 19:02:19 2010 @@ -1,4 +1,4 @@ -# roundf.m4 serial 8 +# roundf.m4 serial 9 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,17 +12,16 @@ AC_CHECK_DECLS([roundf], , , [#include <math.h>]) if test "$ac_cv_have_decl_roundf" = yes; then gl_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);]) - fi - if test "$ac_cv_have_decl_roundf" = yes && test "$ROUNDF_LIBM" != missing; then - dnl Test whether roundf() produces correct results. On mingw, for - dnl x = 1/2 - 2^-25, the system's roundf() returns a wrong result. - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - AC_CACHE_CHECK([whether roundf works], [gl_cv_func_roundf_works], - [ - save_LIBS="$LIBS" - LIBS="$LIBS $ROUNDF_LIBM" - AC_RUN_IFELSE([AC_LANG_SOURCE([[ + if test "$ROUNDF_LIBM" != missing; then + dnl Test whether roundf() produces correct results. On mingw, for + dnl x = 1/2 - 2^-25, the system's roundf() returns a wrong result. + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether roundf works], [gl_cv_func_roundf_works], + [ + save_LIBS="$LIBS" + LIBS="$LIBS $ROUNDF_LIBM" + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <float.h> #include <math.h> int main() @@ -37,19 +36,24 @@ volatile float x = 0.5f - 0.5f / TWO_MANT_DIG; exit (x < 0.5f && roundf (x) != 0.0f); }]])], [gl_cv_func_roundf_works=yes], [gl_cv_func_roundf_works=no], - [case "$host_os" in - mingw*) gl_cv_func_roundf_works="guessing no";; - *) gl_cv_func_roundf_works="guessing yes";; - esac + [case "$host_os" in + mingw*) gl_cv_func_roundf_works="guessing no";; + *) gl_cv_func_roundf_works="guessing yes";; + esac + ]) + LIBS="$save_LIBS" ]) - LIBS="$save_LIBS" - ]) - case "$gl_cv_func_roundf_works" in - *no) ROUNDF_LIBM=missing ;; - esac + case "$gl_cv_func_roundf_works" in + *no) ROUNDF_LIBM=missing ;; + esac + fi + if test "$ROUNDF_LIBM" = missing; then + REPLACE_ROUNDF=1 + fi + else + HAVE_DECL_ROUNDF=0 fi - if test "$ac_cv_have_decl_roundf" != yes || test "$ROUNDF_LIBM" = missing; then - REPLACE_ROUNDF=1 + if test $HAVE_DECL_ROUNDF = 0 || test $REPLACE_ROUNDF = 1; then AC_LIBOBJ([roundf]) AC_CHECK_DECLS([ceilf, floorf], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorf" = yes \ --- m4/roundl.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/roundl.m4 Sun Apr 4 19:02:01 2010 @@ -1,4 +1,4 @@ -# roundl.m4 serial 6 +# roundl.m4 serial 7 dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,9 +12,13 @@ AC_CHECK_DECLS([roundl], , , [#include <math.h>]) if test "$ac_cv_have_decl_roundl" = yes; then gl_CHECK_MATH_LIB([ROUNDL_LIBM], [x = roundl (x);]) + if test "$ROUNDL_LIBM" = missing; then + REPLACE_ROUNDL=1 + fi + else + HAVE_DECL_ROUNDL=0 fi - if test "$ac_cv_have_decl_roundl" != yes || test "$ROUNDL_LIBM" = missing; then - REPLACE_ROUNDL=1 + if test $HAVE_DECL_ROUNDL = 0 || test $REPLACE_ROUNDL = 1; then AC_LIBOBJ([roundl]) AC_CHECK_DECLS([ceill, floorl], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorl" = yes \ --- m4/truncl.m4.orig Sun Apr 4 19:14:50 2010 +++ m4/truncl.m4 Sun Apr 4 18:29:54 2010 @@ -1,4 +1,4 @@ -# truncl.m4 serial 3 +# truncl.m4 serial 4 dnl Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -61,9 +61,9 @@ *) REPLACE_TRUNCL=1 ;; esac else - REPLACE_TRUNCL=1 + HAVE_DECL_TRUNCL=0 fi - if test $REPLACE_TRUNCL = 1; then + if test $HAVE_DECL_TRUNCL = 0 || test $REPLACE_TRUNCL = 1; then AC_LIBOBJ([truncl]) TRUNCL_LIBM= fi --- modules/math.orig Sun Apr 4 19:14:50 2010 +++ modules/math Sun Apr 4 18:36:13 2010 @@ -70,17 +70,25 @@ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ + -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ + -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ + -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ + -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ + -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ + -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \ + -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \ -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \ -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ + -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \