1

如何在不使用 ctypes 的情况下将 ac 结构传递给 python?

我有一个指向stats_res_t我试图返回 python 的结构的指针。

我正在尝试类似的东西

PyObject* pyobject_get_system_stats(PyObject *self, PyObject *args)
{
    PyObject *temp;

    PyObject *resultlist;
    PyObject *res;
    stats_res_t *response;

    if(PyArg_ParseTuple(args,"O",&temp))
    {

        resultlist=PyDict_Values(temp);
        res=PyList_AsTuple(resultlist);

        // populate response

    }
    return Py_BuildValue("O",response);
}

但它会导致python中的段错误。

是否可以使用将填充的结构传递给 python PyObject

4

0 回答 0