使用Funcptr调用函数,Funcptr是python中结构的一个成员

使用Funcptr调用函数,Funcptr是python中结构的一个成员,python,function-pointers,Python,Function Pointers,我有一个结构如下: class Exprs(Structure): _fields_ = [("func",POINTER(CMPFUNC)), other members] CMPFUNC= CFUNCTYPE(ExprArg, POINTER(Exprs), ExprArgList,c_int)// Prototype e是POINTERExprs类型 当我尝试调用e.contents.funce、earlist、0时,我得到一个错误 LP_CfunctionT

我有一个结构如下:

class Exprs(Structure):
  _fields_ = [("func",POINTER(CMPFUNC)),
           other members]

CMPFUNC= CFUNCTYPE(ExprArg, POINTER(Exprs), ExprArgList,c_int)// Prototype
e是POINTERExprs类型

当我尝试调用e.contents.funce、earlist、0时,我得到一个错误

LP_CfunctionType对象不可调用


我使用了合适的C类型铸造。请帮助我解决此错误

函数原型类型的构造函数直接获取地址。您可能只需要在结构定义中删除指针说明符。您所写的内容相当于:

struct Exprs {
    ExprArg (**func)(Exprs *, ExprArgList, int);
};
如果这确实是您想要的,那么请使用e.contents.func.contentse、earlist、0