Say I have the following c code:
typedef struct _test test;
struct _test {
test* just_a_test;
char* just_a_char;
};
Would the following implementation work?
class test(Structure):
_fields_ = [
('just_a_test', POINTER(test)),
('just_a_char', c_char_p),
]
I’m just confused regarding the first pointer in the structure.
Your code will not work because at the time it references
test, the class hasn’t been created yet.This exact problem in described in
ctypesdocumentation under 15.17.1.16. Incomplete Types.The solution is to set
_fields_after creating the class: