c ++头文件代码:
typedef int TSecurityFtdcErrorIDType;
typedef char TSecurityFtdcErrorMsgType[81];
struct CSecurityFtdcRspInfoField
{
TSecurityFtdcErrorIDType ErrorID;
TSecurityFtdcErrorMsgType ErrorMsg;
};
c ++ class header:
class CSecurityFtdcMdSpi
{
public:
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
}
我的pxd定义:
ctypedef int TSecurityFtdcErrorIDType
ctypedef char TSecurityFtdcErrorMsgType[81]
cdef struct CSecurityFtdcRspInfoField:
TSecurityFtdcErrorIDType ErrorID
TSecurityFtdcErrorMsgType ErrorMsg
cython类定义pxd:
cdef cppclass CSecurityFtdcMdSpi:
void OnRspError(CSecurityFtdcRspInfoField *pRspInfo,
int nRequestID,
bool bIsLast) except +
如果我尝试在pyx文件中定义类:
cdef class CSecurityMdSpi:
cdef CSecurityFtdcMdSpi *_this_md_spi
cpdef OnRspError(self, CSecurityFtdcRspUserLoginField *pRspInfo,
int nRequestID,
bool bIsLast) except +:
self._this_md_spi.OnRspError(pRspInfo, nRequestID, bIsLast)
但是当我尝试编译代码时,控制台输出:
Cannot convert 'CSecurityFtdcRspInfoField *' to Python object
如何在python中转换c ++结构,如何在cython中声明struct参数,使用cdef
函数还是其他?