问题描述
我有一个myExtension.c
文件,如下所示
#include <Python.h>
struct myStruct{
int a;
float b;
}
struct myStruct* myCFunction(void) {
return someFunction(); // some other function which returns pointer to myStruct
}
static PyObject *myPythonFunc(PyObject *self,PyObject *args)
{
return Py_BuildValue("O&",myCFunction()); // unsure if it is the correct way
}
我现在创建了一个myExtension.so
,其中将python3 setup.py build
导入到myPythonApp.py
中,如下所示
import myExtension as ext
//here i want to call myCFunction and get the structure pointer in python
// print(ext.myPythonFunc()) did not return anything
我指的是https://docs.python.org/2.0/ext/buildValue.html和https://docs.python.org/3/c-api/arg.html#building-values,但找不到返回结构指针的正确方法。
有人可以帮我完成正确的方法吗?为我设定正确方向的任何帮助将不胜感激。 谢谢!!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)