]> Savannah Git Hosting - gnulib.git/commitdiff
tanf: Avoid redefinition error on MSVC.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 19:48:34 +0000 (20:48 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 22:09:18 +0000 (23:09 +0100)
* 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.

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

index a6593b18c329bcbc4d9ee119dcfa9c70027644a9..f16b24ec4f7039edd627708d241fc8aeee636240 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-12-17  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        sqrtf: Avoid redefinition error on MSVC.
index 842a6369b22a218deb03a99d61558f18fbffc7af..44b4e88dbfe95823377c3123dd2c8da8bd026c29 100644 (file)
@@ -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
index cb415936e841154e436330cf0a919ef66f88d7a8..01e23ad857e1b25063468c358d6adb05655e5cb4 100644 (file)
@@ -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])
index fe48da51127d353e8a0b1f6f5b31aa5c4363981f..92a5f233e3a1a94868d7a813f119be58581c6fdf 100644 (file)
@@ -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 <math.h>]])
     TANF_LIBM="$TAN_LIBM"
   fi
   AC_SUBST([TANF_LIBM])
index a22d369fa82f1dfce76b9747d015a95b5d119b97..317e68805a6eca89bde905e1d6efd4c3949e3690 100644 (file)
@@ -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' \