开发者

Cython recursive struct declarations

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;

开发者_运维百科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*

Any ideas about how to properly handle this recursive definition in Cython?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜