summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 09:37:32 (GMT)
committerAdrián Medraño Calvo <adrian@medranocalvo.com>2017-07-21 11:40:49 (GMT)
commitf10a85adccccb3efccfc84a7d4ca12cc66c7fb1c (patch)
tree8769ca4130b57ade60673f72aa70439e335d7d3e /generic
parent75db3cd1d501700e657da43148197665f71d7a70 (diff)
downloadblt-f10a85adccccb3efccfc84a7d4ca12cc66c7fb1c.zip
blt-f10a85adccccb3efccfc84a7d4ca12cc66c7fb1c.tar.gz
blt-f10a85adccccb3efccfc84a7d4ca12cc66c7fb1c.tar.bz2
Add cmath and printf wrappers for Windows
Needed for compiling with MSVC 2010.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkbltGrAxis.C1
-rw-r--r--generic/tkbltGrAxisOp.C1
-rw-r--r--generic/tkbltGrAxisOption.C1
-rw-r--r--generic/tkbltGrElem.C1
-rw-r--r--generic/tkbltGrElemBar.C1
-rw-r--r--generic/tkbltGrElemLine.C1
-rw-r--r--generic/tkbltGraph.C4
-rw-r--r--generic/tkbltInt.h72
-rw-r--r--generic/tkbltVecMath.C8
-rw-r--r--generic/tkbltVector.C1
10 files changed, 87 insertions, 4 deletions
diff --git a/generic/tkbltGrAxis.C b/generic/tkbltGrAxis.C
index 145f380..bad7124 100644
--- a/generic/tkbltGrAxis.C
+++ b/generic/tkbltGrAxis.C
@@ -42,6 +42,7 @@
#include "tkbltGrDef.h"
#include "tkbltConfig.h"
#include "tkbltGrPSOutput.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGrAxisOp.C b/generic/tkbltGrAxisOp.C
index 89b2be9..196d29a 100644
--- a/generic/tkbltGrAxisOp.C
+++ b/generic/tkbltGrAxisOp.C
@@ -36,6 +36,7 @@
#include "tkbltGrAxis.h"
#include "tkbltGrAxisOp.h"
#include "tkbltGrMisc.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGrAxisOption.C b/generic/tkbltGrAxisOption.C
index e8b1f30..cec594d 100644
--- a/generic/tkbltGrAxisOption.C
+++ b/generic/tkbltGrAxisOption.C
@@ -35,6 +35,7 @@
#include "tkbltGrAxis.h"
#include "tkbltGrAxisOption.h"
#include "tkbltConfig.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGrElem.C b/generic/tkbltGrElem.C
index c80cbc1..394fa57 100644
--- a/generic/tkbltGrElem.C
+++ b/generic/tkbltGrElem.C
@@ -37,6 +37,7 @@
#include "tkbltGrBind.h"
#include "tkbltGrElem.h"
#include "tkbltGrPen.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGrElemBar.C b/generic/tkbltGrElemBar.C
index bdd36d8..a5efc7f 100644
--- a/generic/tkbltGrElemBar.C
+++ b/generic/tkbltGrElemBar.C
@@ -41,6 +41,7 @@
#include "tkbltGrDef.h"
#include "tkbltConfig.h"
#include "tkbltGrPSOutput.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGrElemLine.C b/generic/tkbltGrElemLine.C
index bf81d69..caea48e 100644
--- a/generic/tkbltGrElemLine.C
+++ b/generic/tkbltGrElemLine.C
@@ -41,6 +41,7 @@
#include "tkbltGrDef.h"
#include "tkbltConfig.h"
#include "tkbltGrPSOutput.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltGraph.C b/generic/tkbltGraph.C
index 13e0e9a..9607f54 100644
--- a/generic/tkbltGraph.C
+++ b/generic/tkbltGraph.C
@@ -27,7 +27,8 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <float.h>
+#include <cfloat>
+#include <cmath>
#include <tkInt.h>
@@ -50,6 +51,7 @@
#include "tkbltGrDef.h"
#include "tkbltGrPostscript.h"
#include "tkbltGrPSOutput.h"
+#include "tkbltInt.h"
using namespace Blt;
diff --git a/generic/tkbltInt.h b/generic/tkbltInt.h
new file mode 100644
index 0000000..f13603a
--- /dev/null
+++ b/generic/tkbltInt.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2017 Patzschke+Rasp Software GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __TKBLT_INT_H__
+
+#if defined(_MSC_VER)
+
+#include <limits>
+
+#if !defined(NAN)
+#define NAN (std::numeric_limits<double>::quiet_NaN())
+#endif
+
+#if !defined(isnan)
+#define isnan(x) _isnan(x)
+#endif
+
+#if !defined(isfinite)
+#define isfinite(x) _finite(x)
+#endif
+
+#if !defined(isinf)
+#define isinf(x) !_finite(x)
+#endif
+
+#if !defined(numeric_limits)
+#define numeric_limits(x) _numeric_limits(x)
+#endif
+
+#if _MSC_VER < 1900
+#define snprintf _snprintf
+#else
+#include <stdio.h> //sprintf
+#endif
+
+#endif /* _MSC_VER */
+
+/*
+ * Silence warnings about unused parameters while keeping the parameter name.
+ */
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__MSC_VER__)
+# define UNUSED(x) __pragma(warning(suppress:4100)) x
+#elif defined(__cplusplus)
+# define UNUSED(x)
+#else
+# define UNUSED(x) x
+#endif
+
+#endif /* __TKBLT_INT_H__ */
diff --git a/generic/tkbltVecMath.C b/generic/tkbltVecMath.C
index 6e8a86e..d749add 100644
--- a/generic/tkbltVecMath.C
+++ b/generic/tkbltVecMath.C
@@ -36,7 +36,9 @@
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
+#include <cmath>
+#include "tkbltInt.h"
#include "tkbltVecInt.h"
#include "tkbltNsUtil.h"
#include "tkbltParse.h"
@@ -531,7 +533,7 @@ static void MathError(Tcl_Interp* interp, double value)
Tcl_SetErrorCode(interp, "ARITH", "DOMAIN",
Tcl_GetStringResult(interp), (char *)NULL);
}
- else if ((errno == ERANGE) || std::isinf(value)) {
+ else if ((errno == ERANGE) || isinf(value)) {
if (value == 0.0) {
Tcl_AppendResult(interp,
"floating-point value too small to represent",
@@ -1416,7 +1418,7 @@ static int EvaluateExpression(Tcl_Interp* interp, char *string,
/* Check for NaN's and overflows. */
for (vp = vPtr->valueArr, vend = vp + vPtr->length; vp < vend; vp++) {
- if (!std::isfinite(*vp)) {
+ if (!isfinite(*vp)) {
/*
* IEEE floating-point error.
*/
@@ -1441,7 +1443,7 @@ static int ComponentFunc(ClientData clientData, Tcl_Interp* interp,
MathError(interp, *vp);
return TCL_ERROR;
}
- if (!std::isfinite(*vp)) {
+ if (!isfinite(*vp)) {
/*
* IEEE floating-point error.
*/
diff --git a/generic/tkbltVector.C b/generic/tkbltVector.C
index f355c96..b773ad8 100644
--- a/generic/tkbltVector.C
+++ b/generic/tkbltVector.C
@@ -52,6 +52,7 @@
#include <cmath>
+#include "tkbltInt.h"
#include "tkbltVecInt.h"
#include "tkbltNsUtil.h"
#include "tkbltSwitch.h"