On my 64-bit office desktop, this compiles fine:
#include <Python.h>
#include <numpy/arrayobject.h>
...
Py_Initialize();
import_array();
long int NUMEL=3;
PyObject *out_array = PyArray_SimpleNew(1, &NUMEL, NPY_DOUBLE);
Conversely, on my 32-bit laptop this does not result in an error:
error: invalid conversion from ‘long int*’ to ‘npy_intp* {aka int*}’ [-fpermissive]
PyArray_New(&PyArray_Type, nd, dims, typenum, NULL, NULL, 0, 0, NULL)
Alternatively, if I declare int NUMEL=3instead, the code will compile on a 32-bit machine, but not on a 64-bit one. I suspect it npy_intpis platform dependent. Since I cannot determine the type of the NUMELtype npy_intp(since in practice it is passed by other C / C ++ routines), is there a way to conditionally determine NUMEL, depending on the platform, inside C ++ code?
source
share