On my 64-bit office desktop this compiles fine:
#include <Python.h>
#include <numpy/arrayobject.h>
...
Py_Initialize();
import_array();
// Build array object
long int NUMEL=3;
PyObject *out_array = PyArray_SimpleNew(1, &NUMEL, NPY_DOUBLE);
Conversely, on my 32-bit laptop this fails producing the 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=3
instead, the code will compile on 32-bit machine but not on the 64-bit one. I suspect that npy_intp
is platform dependent. As I cannot define NUMEL
of npy_intp
type (as in practice it is passed by other C/C++-only routines), is there a way to conditionally define NUMEL
depending on the platform within the C++-code?