From 37f1057c4ef8c21ccca9fb39069417b9db411e81 Mon Sep 17 00:00:00 2001 From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152> Date: Thu, 7 May 2009 08:50:59 +0000 Subject: [PATCH] trunk preprocessor: * change the way we check for success of strtod() in NumericalConstants::AddConstant, because of Windows compatibility problem * reverted r2660 changeset git-svn-id: https://www.dynare.org/svn/dynare/trunk@2661 ac1d8469-bf42-47a9-8791-bf33cf982152 --- Makefile.in | 2 +- NumericalConstants.cc | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index 3b8a4351..2fc4d8ec 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ CXX = @CXX@ CXXFLAGS = @CXXFLAGS@ -CPPFLAGS = -DNDEBUG @CPPFLAGS@ @DEFS@ +CPPFLAGS = @CPPFLAGS@ @DEFS@ LDFLAGS = @LDFLAGS@ FLEX = @FLEX@ diff --git a/NumericalConstants.cc b/NumericalConstants.cc index de53e4a0..e27ce1c1 100644 --- a/NumericalConstants.cc +++ b/NumericalConstants.cc @@ -19,6 +19,7 @@ #include <cstdlib> #include <cassert> +#include <cerrno> #include <cmath> #include <iostream> @@ -36,9 +37,9 @@ NumericalConstants::AddConstant(const string &iConst) mNumericalConstants.push_back(iConst); numConstantsIndex[iConst] = id; - char *endptr; - double val = strtod(iConst.c_str(), &endptr); - assert(endptr != iConst.c_str()); // Check that the conversion succeeded + errno = 0; + double val = strtod(iConst.c_str(), NULL); + assert(errno == 0); // Check that the conversion succeeded assert(val >= 0 || isnan(val)); // Check we have a positive constant or a NaN double_vals.push_back(val); -- GitLab