Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何处理cython中的C typedef?_C_Cython_Typedef - Fatal编程技术网

如何处理cython中的C typedef?

如何处理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

我正在古巴图书馆工作,我希望在我的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, 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
并在文件前加上前缀。