From 7347554db51017763b04e644d2d99165d1025652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 25 Jun 2019 11:13:48 +0200 Subject: [PATCH] perfect_foresight_problem MEX: fix compilation under Windows --- .../perfect_foresight_problem/DynamicModelCaller.cc | 13 ++++--------- .../perfect_foresight_problem/DynamicModelCaller.hh | 13 +++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc index 2a59e0937..73d7a4642 100644 --- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc +++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.cc @@ -17,15 +17,6 @@ * along with Dynare. If not, see . */ -#if defined(_WIN32) || defined(__CYGWIN32__) -# ifndef NOMINMAX -# define NOMINMAX // Do not define "min" and "max" macros -# endif -# include -#else -# include // unix/linux DLL (.so) handling routines -#endif - #include #include "DynamicModelCaller.hh" @@ -34,7 +25,11 @@ std::string DynamicModelCaller::error_msg; +#if defined(_WIN32) || defined(__CYGWIN32__) +HINSTANCE DynamicModelDllCaller::dynamic_mex{nullptr}; +#else void *DynamicModelDllCaller::dynamic_mex{nullptr}; +#endif DynamicModelDllCaller::dynamic_tt_fct DynamicModelDllCaller::residual_tt_fct{nullptr}, DynamicModelDllCaller::g1_tt_fct{nullptr}; DynamicModelDllCaller::dynamic_deriv_fct DynamicModelDllCaller::residual_fct{nullptr}, DynamicModelDllCaller::g1_fct{nullptr}; diff --git a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh index 8c64938fd..4d10bb1ad 100644 --- a/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh +++ b/mex/sources/perfect_foresight_problem/DynamicModelCaller.hh @@ -21,6 +21,15 @@ #include #include +#if defined(_WIN32) || defined(__CYGWIN32__) +# ifndef NOMINMAX +# define NOMINMAX // Do not define "min" and "max" macros +# endif +# include +#else +# include // unix/linux DLL (.so) handling routines +#endif + class DynamicModelCaller { public: @@ -39,7 +48,11 @@ public: class DynamicModelDllCaller : public DynamicModelCaller { private: +#if defined(_WIN32) || defined(__CYGWIN32__) + static HINSTANCE dynamic_mex; +#else static void *dynamic_mex; +#endif using dynamic_tt_fct = void (*)(const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, double *T); using dynamic_deriv_fct = void (*) (const double *y, const double *x, int nb_row_x, const double *params, const double *steady_state, int it_, const double *T, double *deriv); static dynamic_tt_fct residual_tt_fct, g1_tt_fct;