2

I am attempting to wrap some C code in Python using Pyrex. I've run into an issue with defining two structs. In this case, the structures have been defined in terms of one another, and Pyrex cannot seem to handle the conflict. The structures look something like so:

typedef struct a {
    b * b_pointer;
} a;

typedef struct b {
    a a_obj;
} b;

They are placed in different files. The code I am using to wrap the structures looks like this:

def extern from "file.c": 
    ctypdef struct a: 
            b * b_pointer 
    ctypedef struct b: 
            a a_obj

File.c is a separate file containing function definitions, as opposed to the structure definitions, but it includes the source files that define these structures. Is there some way I can wrap both of these structures?

4

1 に答える 1

3

不完全な型を使用できます(.hファイルだけでなく、対応する C の typedef が必要.cです)。

cdef extern from "some.h":
  ctypedef struct b
  ctypedef struct a:
    b * b_pointer
  ctypedef struct b:
    a a_obj
于 2009-09-03T22:28:19.910 に答える