From e74df853fc676279b40bb6a3e8c76df0545cd8a9 Mon Sep 17 00:00:00 2001
From: AlQuemist <alquemist@Lyriks>
Date: Sat, 5 Feb 2022 17:29:48 +0100
Subject: [PATCH] Amend PythonInterpreter for Windows compiler MSVC 19

The change prevents the following errors from Windows compiler MSVC 19 on x64
platform:
```
error C2196: case value 'NPY_LONG' already used
error C2196: case value 'NPY_ULONG' already used
```
---
 PyTools/Embed/PythonInterpreter.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/PyTools/Embed/PythonInterpreter.cpp b/PyTools/Embed/PythonInterpreter.cpp
index cc3807fb94f..50df04d84fc 100644
--- a/PyTools/Embed/PythonInterpreter.cpp
+++ b/PyTools/Embed/PythonInterpreter.cpp
@@ -646,9 +646,16 @@ Result<std::vector<double>> PythonInterpreter::Numpy::createVectorFromArray2D(Py
     case NPY_INT32:
         _realArray2DToDouble<npy_int32>(npArray_ptr, rowIdxMax, colIdxMax, data);
         break;
+
+// prevent the error from Windows compiler MSVC 19:
+// `error C2196: case value 'NPY_LONG' already used`
+#ifndef _WIN32
+
     case NPY_LONG:
         _realArray2DToDouble<npy_long>(npArray_ptr, rowIdxMax, colIdxMax, data);
         break;
+#endif // _WIN32
+
     // unsigned int
     case NPY_UINT8:
         _realArray2DToDouble<npy_uint8>(npArray_ptr, rowIdxMax, colIdxMax, data);
@@ -659,9 +666,15 @@ Result<std::vector<double>> PythonInterpreter::Numpy::createVectorFromArray2D(Py
     case NPY_UINT32:
         _realArray2DToDouble<npy_uint32>(npArray_ptr, rowIdxMax, colIdxMax, data);
         break;
+
+// prevent the error from Windows compiler MSVC 19:
+// `error C2196: case value 'NPY_ULONG' already used`
+#ifndef _WIN32
     case NPY_ULONG:
         _realArray2DToDouble<npy_ulong>(npArray_ptr, rowIdxMax, colIdxMax, data);
         break;
+#endif // _WIN32
+
     default:
         std::stringstream msg_ss;
         msg_ss << "PythonInterpreter::Numpy: "
-- 
GitLab