我只是想在开始编写扩展之前创建一个 numpy 数组。这是一个超级简单的程序:
#include <stdio.h>
#include <iostream>
#include "Python.h"
#include "numpy/npy_common.h"
#include "numpy/ndarrayobject.h"
#include "numpy/arrayobject.h"
int main(int argc, char * argv[])
{
int n = 2;
int nd = 1;
npy_intp size = {1};
PyObject* alpha = PyArray_SimpleNew(nd, &size, NPY_DOUBLE);
return 0;
}
该程序在PyArray_SimpleNew
通话中出现段错误,我不明白为什么。我正在尝试关注以前的一些问题(例如numpy array C api和C array to PyArray)。我究竟做错了什么?