Hi I am learning python and using ctype to embedd 'C' in python. My query is- How to use C stru which again calling a stru inside into cytpe/python.
typedef struct {
struct *i, *j;
BOOLEAN z;
} foo;
Hi I am learning python and using ctype to embedd 'C' in python. My query is- How to use C stru which again calling a stru inside into cytpe/python.
typedef struct {
struct *i, *j;
BOOLEAN z;
} foo;
Copyright © 2021 Jogjafile Inc.
It's not entirely clear from your question, but it looks like you're trying to define a struct that contains a pointer to the same type. It's not immediately obvious how you would accomplish this in python, but you basically define your
Structure
, and then define the_fields_
attribute afterwards.The ctype docs on python.org have a perfectly on-point example of doing exactly this.
There's also good documentation there on working with structs in general, including nesting one struct type within another, which works a little more obviously.