Cython递归结构声明 [英] Cython recursive struct declarations
本文介绍了Cython递归结构声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Cython中使用C结构,该结构定义一个链表:
I'm trying to use a C struct in Cython, that defines a linked list:
typedef struct {
struct query_result* next_result;
char* result;
} query_result;
如您所见,我正在使用自己定义中的query_result类型。
照此使用,在Cython中会给我带来编译器错误:
As you can see I'm using the query_result type inside its own definition. Using this as is, in Cython gives me compiler errors:
cdef extern from 'c_wrapper.h':
struct query_result:
struct query_result*
char*
任何想法
推荐答案
有关如何正确处理Cython中的递归定义的内容,您不应该使用 struct
关键字,当您引用类型时:
You shouldn't use the struct
keyword when you are referring to the type:
cdef extern from 'c_wrapper.h':
struct query_result:
query_result* more
char* data
这篇关于Cython递归结构声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文