>我有一个结构如下:
class Exprs(Structure):
_fields_ = [("func",POINTER(CMPFUNC)),
other members]
CMPFUNC= CFUNCTYPE(ExprArg, POINTER(Exprs), ExprArgList,c_int)// Prototype
e 的类型为 POINTER(Exprs)
当我尝试调用e.contents.func(e, eArgList,0)
时,出现错误
LP_CfunctionType对象不可调用
我使用了适当的 ctype 转换。请帮我解决此错误
函数原型类型的构造函数直接获取地址。您可能只需要删除结构定义中的POINTER
说明符。你写的相当于:
struct Exprs {
ExprArg (**func)(Exprs *, ExprArgList, int);
};
如果这真的是您想要的,请使用e.contents.func.contents(e, eArgList,0)