我想从python中的c++库中获取一个数组的指针,并将其保存在一个变量中,然后将该变量用作另一个c++函数的参数。你知道吗
ubuntu18.04、pybind11、python3.6.8
C类型
passing-pointer-to-c-from-python-using-pybind11
C++ +<
// class1:
static complex<double>* randomComplexArray(long size);
complex<double>* randomComplexArray(long n){
complex<double>* res = new complex<double>[n];
for ...
return res; //pointer
}
// class2:
void calc(complex<double>* vals);
pybuind11型
// class1:
.def_static("randomComplexArray", &class1::randomCircleArray)
// class2:
.def("calc", (void (*)(complex<double>*)) &class2::calc)
Python
p = randomComplexArray(1024)
calc(p) // what I hope
Segmentation fault
,Bus fault
等等。你知道吗
我是第一次做这件事。如果有人能帮我?你知道吗
非常感谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐