如何处理cython中的C typedef?
我正在古巴图书馆工作,我希望在我的Cython文件中使用C代码。要使用头文件cuba.h中的方法,我在Cython文件的顶部编写如何处理cython中的C typedef?,c,cython,typedef,C,Cython,Typedef,我正在古巴图书馆工作,我希望在我的Cython文件中使用C代码。要使用头文件cuba.h中的方法,我在Cython文件的顶部编写 cdef extern from "cuba.h": void Cuhre(const int ndim, const int ncomp, integrand_t integrand, const double epsrel, const double epsabs, const int flags, const int mineval, c
cdef extern from "cuba.h":
void Cuhre(const int ndim, const int ncomp, integrand_t integrand,
const double epsrel, const double epsabs,
const int flags, const int mineval, const int maxeval,
const int key,
int *nregions, int *neval, int *fail,
double integral[], double error[], double prob[])
Cuhre是我唯一希望使用的方法,上面是它的签名。该程序能够定位cuba.h,但它会引发一个错误,即它无法将被积函数识别为一种类型。在cuba.h中,它定义了一个函数类型*integrand\u t:
typedef double cubareal;
typedef int (*integrand_t)(const int *ndim, const cubareal x[], const int *ncomp, cubareal f[], void *userdata);
那么,我如何修复这个错误并在Cython程序中使用Cuba库呢?提前感谢您的帮助。在cython文件中定义您的typedef,如下所示
cdef extern from "cuba.h":
ctypedef int (*integrand_t)(const int *ndim, const cubareal x[], const int *ncomp, cubareal f[], void *userdata)
typedef
=>ctypedef
并在文件前加上前缀。