From b2963ae55806af28618ea1caa86866d55f832f9e Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Mon, 17 Oct 2016 14:59:07 +0200
Subject: [PATCH] preprocessor: define var for normcdf + msvc. #1259

---
 DynamicModel.cc | 30 ++++++++++++++++++++++++++++++
 StaticModel.cc  |  5 +++++
 2 files changed, 35 insertions(+)

diff --git a/DynamicModel.cc b/DynamicModel.cc
index f86c9006..f926d32e 100644
--- a/DynamicModel.cc
+++ b/DynamicModel.cc
@@ -1607,6 +1607,11 @@ DynamicModel::writeDynamicCFile(const string &dynamic_basename, const int order)
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model file (.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   if (external_functions_table.get_total_number_of_unique_model_block_external_functions())
@@ -4799,6 +4804,11 @@ DynamicModel::writeResidualsC(const string &basename, bool cuda) const
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model " << basename << "(.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   mDynamicModelFile << "#include <stdlib.h>" << endl;
@@ -4850,6 +4860,11 @@ DynamicModel::writeFirstDerivativesC(const string &basename, bool cuda) const
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model " << basename << "(.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   mDynamicModelFile << "#include <stdlib.h>" << endl;
@@ -4908,6 +4923,11 @@ DynamicModel::writeFirstDerivativesC_csr(const string &basename, bool cuda) cons
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model " << basename << "(.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   mDynamicModelFile << "#include <stdlib.h>" << endl;
@@ -5010,6 +5030,11 @@ DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) con
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model " << basename << "(.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   mDynamicModelFile << "#include <stdlib.h>" << endl;
@@ -5104,6 +5129,11 @@ DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) cons
                     << " * Warning : this file is generated automatically by Dynare" << endl
                     << " *           from model " << basename << "(.mod)" << endl
                     << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+                    << "#ifdef _MSC_VER" << endl
+                    << "#define _USE_MATH_DEFINES" << endl
+                    << "#endif" << endl
+#endif
                     << "#include <math.h>" << endl;
 
   mDynamicModelFile << "#include <stdlib.h>" << endl;
diff --git a/StaticModel.cc b/StaticModel.cc
index 251cbe1e..b54f6277 100644
--- a/StaticModel.cc
+++ b/StaticModel.cc
@@ -1597,6 +1597,11 @@ StaticModel::writeStaticCFile(const string &func_name) const
          << " * Warning : this file is generated automatically by Dynare" << endl
          << " *           from model file (.mod)" << endl << endl
          << " */" << endl
+#if defined(_WIN32) || defined(__CYGWIN32__) || defined(__MINGW32__)
+         << "#ifdef _MSC_VER" << endl
+         << "#define _USE_MATH_DEFINES" << endl
+         << "#endif" << endl
+#endif
          << "#include <math.h>" << endl;
 
   if (external_functions_table.get_total_number_of_unique_model_block_external_functions())
-- 
GitLab