0

Visual Studio 2019 (compiling with 2017 64 bit)

This code

... (code before that runs fine)...

PyArrayObject* extents = NULL;
npy_intp extent_dims[] = { 2, 2, 0 };
try {
    extents = (PyArrayObject*)PyArray_SimpleNew(2, extent_dims, PyArray_DOUBLE);
    if (extents == NULL) {
        printf("error \n");
    }
}
catch (...) {
    printf("catch\n");
}
printf("I am here\n");

The statement

extents = (PyArrayObject*)PyArray_SimpleNew(2, extent_dims, PyArray_DOUBLE);

appears to fail silently, exits the Python interpreter. Any ideas?

ccr
  • 1
  • I have tried various other numpy calls, all exhibit the same behavior – ccr Dec 30 '21 at 19:55
  • 1
    Does this answer your question? [creating numpy array in c extension segfaults](https://stackoverflow.com/questions/25494858/creating-numpy-array-in-c-extension-segfaults). You shold initialize numpy with [import_array](https://numpy.org/doc/stable/reference/c-api/array.html?highlight=import_array#c.import_array) – dewaffled Dec 30 '21 at 20:09

0 Answers0