diff --git a/emd.h b/emd.h index 2456cb5..cab384f 100644 --- a/emd.h +++ b/emd.h @@ -1,3 +1,7 @@ +// fix windows compile +#ifdef _MSC_VER +#define __restrict__ __restrict +#endif // fix inttypes for GCC #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS diff --git a/emd_relaxed.h b/emd_relaxed.h index cc1bb7b..da93288 100644 --- a/emd_relaxed.h +++ b/emd_relaxed.h @@ -1,3 +1,8 @@ +// fix windows compile +#ifdef _MSC_VER +#define __restrict__ __restrict +#endif + #pragma once #include diff --git a/python.cc b/python.cc index b5ba98e..1a0ec6c 100644 --- a/python.cc +++ b/python.cc @@ -149,8 +149,8 @@ PyObject* emd_entry( C *cache = nullptr; std::unique_ptr cache_ptr; if (cache_obj != Py_None) { - cache = reinterpret_cast(reinterpret_cast( - PyLong_AsLong(cache_obj))); + long l=PyLong_AsLong(cache_obj); + cache = reinterpret_cast(reinterpret_cast( &l )); if (PyErr_Occurred()) { return NULL; } diff --git a/setup.py b/setup.py index 8d83110..7a1decd 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "-Wno-sign-compare", "-fPIC", "-flto"], "Linux": ["-fopenmp", "-std=c++11", "-march=native", "-ftree-vectorize", "-DNDEBUG", "-Wno-sign-compare", "-fPIC", "-flto"], - "Windows": ["/openmp", "/std:c++latest", "/arch:AVX2", "/DNDEBUG", "/LTCG", + "Windows": ["/openmp:experimental", "/std:c++latest", "/arch:AVX2", "/DNDEBUG", "/LTCG", "/GL"] } @@ -29,6 +29,10 @@ "Windows": ["/LTCG", "/GL"] } +if platform.system() == "Windows" and platform.python_version_tuple() >= ("3", "5", "0"): + CXX_FLAGS["Windows"].append("/d2FH4-") + LD_FLAGS["Windows"].append("/d2:-FH4-") + setup( name=PACKAGE, description="Accelerated functions to calculate Word Mover's Distance",