From 3d1b4d3d494e2bc39a70a4bca8c803e7a1ac188d Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Fri, 30 Aug 2024 21:37:22 -0500 Subject: [PATCH] Fix windows vc 2022 compatibility (close #122) --- setup.py | 8 ++++++++ src/mating.cpp | 2 +- src/utility.h | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 00cc70a5..3e52a961 100755 --- a/setup.py +++ b/setup.py @@ -477,7 +477,15 @@ def replaceIntHeader(file): if os.path.isdir(conda_lib): common_extra_include_dirs.append(os.path.join(conda_lib, 'include')) common_library_dirs.append(os.path.join(conda_lib, 'lib')) + for conda_var in ('CONDA_PREFIX', 'CONDA_PREFIX_1'): + if conda_var in os.environ: + conda_lib = os.path.join(os.environ[conda_var], 'Library') + if os.path.isdir(conda_lib): + common_extra_include_dirs.append(os.path.join(conda_lib, 'include')) + common_library_dirs.append(os.path.join(conda_lib, 'lib')) + # msvc does not have O3 option, /GR is to fix a C4541 warning + # /EHsc is for VC exception handling, # /wd4819 disables warning messages for non-unicode character in boost/uitlity/enable_if.hpp # /wd4996 disables warning messages for unsafe function call in boost/serialization diff --git a/src/mating.cpp b/src/mating.cpp index 5ad27a09..40c0cfb6 100644 --- a/src/mating.cpp +++ b/src/mating.cpp @@ -1879,7 +1879,7 @@ bool HeteroMating::mate(Population &pop, Population &scratch) if (fcmp_gt(w_neg[i], 0.)) { // issue 114, allow parental subpopulation to be larger than offspring subpopulation. - vspSize[i] = std::min(all, static_cast(parentSize[i] * w_neg[i])); + vspSize[i] = std::min(all, static_cast(parentSize[i] * w_neg[i])); all -= vspSize[i]; } } diff --git a/src/utility.h b/src/utility.h index f45ed62a..6769ae26 100644 --- a/src/utility.h +++ b/src/utility.h @@ -47,6 +47,10 @@ extern "C" { #include "Python.h" + +#ifdef _MSC_VER +typedef SSIZE_T ssize_t; +#endif } #include "simuPOP_cfg.h"