]> Savannah Git Hosting - gnulib.git/commitdiff
tanhf: Avoid redefinition error on MSVC.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 19:51:33 +0000 (20:51 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 22:09:19 +0000 (23:09 +0100)
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANHF.
* m4/tanhf.m4 (gl_FUNC_TANHF): Set REPLACE_TANHF to 1 if the function
may be defined as an inline function.
* modules/math (Makefile.am): Substitute REPLACE_TANHF.
* lib/math.in.h (tanhf): Override if REPLACE_TANHF is 1.

ChangeLog
lib/math.in.h
m4/math_h.m4
m4/tanhf.m4
modules/math

index f16b24ec4f7039edd627708d241fc8aeee636240..7870489540314e54dce52b30cc479d104bf8dbe9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-12-17  Bruno Haible  <bruno@clisp.org>
+
+       tanhf: Avoid redefinition error on MSVC.
+       * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Define REPLACE_TANHF.
+       * m4/tanhf.m4 (gl_FUNC_TANHF): Set REPLACE_TANHF to 1 if the function
+       may be defined as an inline function.
+       * modules/math (Makefile.am): Substitute REPLACE_TANHF.
+       * lib/math.in.h (tanhf): Override if REPLACE_TANHF is 1.
+
 2016-12-17  Bruno Haible  <bruno@clisp.org>
 
        tanf: Avoid redefinition error on MSVC.
index 44b4e88dbfe95823377c3123dd2c8da8bd026c29..494432f9051284c786b09f75d645cc054ca81724 100644 (file)
@@ -2044,11 +2044,20 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
 
 
 #if @GNULIB_TANHF@
-# if !@HAVE_TANHF@
-#  undef tanhf
+# if @REPLACE_TANHF@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef tanhf
+#   define tanhf rpl_tanhf
+#  endif
+_GL_FUNCDECL_RPL (tanhf, float, (float x));
+_GL_CXXALIAS_RPL (tanhf, float, (float x));
+# else
+#  if !@HAVE_TANHF@
+#   undef tanhf
 _GL_FUNCDECL_SYS (tanhf, float, (float x));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (tanhf, float, (float x));
+# endif
 _GL_CXXALIASWARN (tanhf);
 #elif defined GNULIB_POSIXCHECK
 # undef tanhf
index 01e23ad857e1b25063468c358d6adb05655e5cb4..d427b9bd146d57fa45687dd94d1133139aca5d32 100644 (file)
@@ -327,6 +327,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
   REPLACE_SQRTF=0;             AC_SUBST([REPLACE_SQRTF])
   REPLACE_SQRTL=0;             AC_SUBST([REPLACE_SQRTL])
   REPLACE_TANF=0;              AC_SUBST([REPLACE_TANF])
+  REPLACE_TANHF=0;             AC_SUBST([REPLACE_TANHF])
   REPLACE_TRUNC=0;             AC_SUBST([REPLACE_TRUNC])
   REPLACE_TRUNCF=0;            AC_SUBST([REPLACE_TRUNCF])
   REPLACE_TRUNCL=0;            AC_SUBST([REPLACE_TRUNCL])
index 010e991bfacd2c9a6cf0c7c22622b77923328804..b591c410f42983139ce20df23b3625e996475615 100644 (file)
@@ -1,4 +1,4 @@
-# tanhf.m4 serial 2
+# tanhf.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_TANHF],
     TANHF_LIBM="$TANH_LIBM"
   else
     HAVE_TANHF=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_tanhf, not tanhf.
+    AC_CHECK_DECLS([tanhf], [REPLACE_TANHF=1], , [[#include <math.h>]])
     TANHF_LIBM="$TANH_LIBM"
   fi
   AC_SUBST([TANHF_LIBM])
index 317e68805a6eca89bde905e1d6efd4c3949e3690..2f553baf2d67bff8529970e15b3e8a8e08349c86 100644 (file)
@@ -297,6 +297,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \
              -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
              -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \
+             -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \
              -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
              -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
              -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \