diff --git a/matplotlibcpp.h b/matplotlibcpp.h index d95d46a..8aabcd1 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -2,7 +2,15 @@ // Python headers must be included before any system headers, since // they define _POSIX_C_SOURCE -#include +#ifdef _MSC_VER + // Avoid Python debug library being pulled in + #define HAVE_ROUND 1 + #undef _DEBUG + #include + #define _DEBUG +#else + #include +#endif #include #include @@ -351,9 +359,13 @@ template <> struct select_npy_type { const static NPY_TYPES type = NPY // Sanity checks; comment them out or change the numpy type below if you're compiling on // a platform where they don't apply static_assert(sizeof(long long) == 8); -template <> struct select_npy_type { const static NPY_TYPES type = NPY_INT64; }; +#ifndef _MSC_VER +template<> struct select_npy_type { static const NPY_TYPES type = NPY_INT64; }; +#endif static_assert(sizeof(unsigned long long) == 8); +#ifndef _MSC_VER template <> struct select_npy_type { const static NPY_TYPES type = NPY_UINT64; }; +#endif template PyObject* get_array(const std::vector& v) @@ -2255,9 +2267,9 @@ inline void subplot(long nrows, long ncols, long plot_number) // construct positional args PyObject* args = PyTuple_New(3); - PyTuple_SetItem(args, 0, PyFloat_FromDouble(nrows)); - PyTuple_SetItem(args, 1, PyFloat_FromDouble(ncols)); - PyTuple_SetItem(args, 2, PyFloat_FromDouble(plot_number)); + PyTuple_SetItem(args, 0, PyLong_FromLong(nrows)); + PyTuple_SetItem(args, 1, PyLong_FromLong(ncols)); + PyTuple_SetItem(args, 2, PyLong_FromLong(plot_number)); PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_subplot, args); if(!res) throw std::runtime_error("Call to subplot() failed.");