[Bf-blender-cvs] [dbc485f] depsgraph_refactor: Hacky kludge fixes to get mingw64 to compile - "finite()" issues
Joshua Leung
noreply at git.blender.org
Mon Dec 1 12:29:33 CET 2014
Commit: dbc485fb8db840508dc334a53c0c22819f943736
Author: Joshua Leung
Date: Mon Dec 1 18:46:23 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rBdbc485fb8db840508dc334a53c0c22819f943736
Hacky kludge fixes to get mingw64 to compile - "finite()" issues
* finite() is not defined on mingw64 when using c++11
* isfinite() can be used instead, but, to use it, you need to
#include <cmath> and using std::isfinite;
to each offending file where finite() may get called,
which is basically every file that includes
BLI_math.h ==> math_vector_inline.c
* In this patch, we define our own wrapper for finite() (via the
C code in blenlib, which is free of all this C++ crapiness),
which the C++ code can then feast on.
The name though needs 2 underscores, as the single-underscore
version (_finite) causes conflicts with symbols from dll's
(i.e. most likely conflicting with the MSVC _finite(), which
mingw-C++11 *still* doesn't see either).
===================================================================
M source/blender/blenlib/BLI_math_base.h
M source/blender/blenlib/intern/math_base.c
===================================================================
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 13718e8..1535a46 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -146,6 +146,18 @@ static const int NAN_INT = 0x7FC00000;
#ifdef WIN32
# if defined(_MSC_VER)
# define finite(n) _finite(n)
+# elif defined(__MINGW64__)
+ /* finite(x) is not defined for mingw64 using C++11,
+ * so we have to use std::isfinite(x) instead.
+ *
+ * But, remapping all finite(x) calls to std::isfinite(x)
+ * is not so easy, as these headers are used in both C and C++ code.
+ */
+ int __finite(double n);
+
+# ifdef __cplusplus
+# define finite(n) __finite(n)
+# endif
# endif
#endif
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index 3ff1af3..d555512 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -99,3 +99,14 @@ double double_round(double x, int ndigits)
/* if computation resulted in overflow, raise OverflowError */
return z;
}
+
+/* Hack for problems with mingw64, C++11, and finite(x) not existing */
+#if defined(WIN32) && defined(__MINGW64__)
+int __finite(double x)
+{
+ /* just a wrapper around the version that's available in C,
+ * so that we have something our macro redef can expose to C++ code
+ */
+ return finite(x);
+}
+#endif
More information about the Bf-blender-cvs
mailing list