From: Bruno Haible Date: Sat, 17 Dec 2016 19:48:34 +0000 (+0100) Subject: tanf: Avoid redefinition error on MSVC. X-Git-Tag: v1.0~6462 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9ef2e6d2053ea4d0068ecc1761f2ec81d4971790;p=gnulib.git tanf: Avoid redefinition error on MSVC. * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANF. * m4/tanf.m4 (gl_FUNC_TANF): Set REPLACE_TANF to 1 if the function may be defined as an inline function. * modules/math (Makefile.am): Substitute REPLACE_TANF. * lib/math.in.h (tanf): Override if REPLACE_TANF is 1. --- diff --git a/ChangeLog b/ChangeLog index a6593b18c3..f16b24ec4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016-12-17 Bruno Haible + + tanf: Avoid redefinition error on MSVC. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANF. + * m4/tanf.m4 (gl_FUNC_TANF): Set REPLACE_TANF to 1 if the function + may be defined as an inline function. + * modules/math (Makefile.am): Substitute REPLACE_TANF. + * lib/math.in.h (tanf): Override if REPLACE_TANF is 1. + 2016-12-17 Bruno Haible sqrtf: Avoid redefinition error on MSVC. diff --git a/lib/math.in.h b/lib/math.in.h index 842a6369b2..44b4e88dbf 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -2004,11 +2004,20 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " #if @GNULIB_TANF@ -# if !@HAVE_TANF@ -# undef tanf +# if @REPLACE_TANF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tanf +# define tanf rpl_tanf +# endif +_GL_FUNCDECL_RPL (tanf, float, (float x)); +_GL_CXXALIAS_RPL (tanf, float, (float x)); +# else +# if !@HAVE_TANF@ +# undef tanf _GL_FUNCDECL_SYS (tanf, float, (float x)); -# endif +# endif _GL_CXXALIAS_SYS (tanf, float, (float x)); +# endif _GL_CXXALIASWARN (tanf); #elif defined GNULIB_POSIXCHECK # undef tanf diff --git a/m4/math_h.m4 b/m4/math_h.m4 index cb415936e8..01e23ad857 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -326,6 +326,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF]) REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF]) REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) + REPLACE_TANF=0; AC_SUBST([REPLACE_TANF]) REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) diff --git a/m4/tanf.m4 b/m4/tanf.m4 index fe48da5112..92a5f233e3 100644 --- a/m4/tanf.m4 +++ b/m4/tanf.m4 @@ -1,4 +1,4 @@ -# tanf.m4 serial 2 +# tanf.m4 serial 3 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,6 +22,10 @@ AC_DEFUN([gl_FUNC_TANF], TANF_LIBM="$TAN_LIBM" else HAVE_TANF=0 + dnl If the function is declared but does not appear to exist, it may be + dnl defined as an inline function. In order to avoid a conflict, we have + dnl to define rpl_tanf, not tanf. + AC_CHECK_DECLS([tanf], [REPLACE_TANF=1], , [[#include ]]) TANF_LIBM="$TAN_LIBM" fi AC_SUBST([TANF_LIBM]) diff --git a/modules/math b/modules/math index a22d369fa8..317e68805a 100644 --- a/modules/math +++ b/modules/math @@ -296,6 +296,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \ -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \ -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ + -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \ -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \