From f10a85adccccb3efccfc84a7d4ca12cc66c7fb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= Date: Fri, 21 Jul 2017 11:37:32 +0200 Subject: Add cmath and printf wrappers for Windows Needed for compiling with MSVC 2010. --- generic/tkbltGrAxis.C | 1 + generic/tkbltGrAxisOp.C | 1 + generic/tkbltGrAxisOption.C | 1 + generic/tkbltGrElem.C | 1 + generic/tkbltGrElemBar.C | 1 + generic/tkbltGrElemLine.C | 1 + generic/tkbltGraph.C | 4 ++- generic/tkbltInt.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ generic/tkbltVecMath.C | 8 +++-- generic/tkbltVector.C | 1 + 10 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 generic/tkbltInt.h 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 +#include +#include #include @@ -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 + +#if !defined(NAN) +#define NAN (std::numeric_limits::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 //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 #include #include +#include +#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 +#include "tkbltInt.h" #include "tkbltVecInt.h" #include "tkbltNsUtil.h" #include "tkbltSwitch.h" -- cgit v0.12