Cython recursive struct declarations

2019-07-27 04:29发布

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?

标签: cython
1条回答
趁早两清
2楼-- · 2019-07-27 05:01

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
查看更多
登录 后发表回答