I am working on a project which has some python files which are using some SWIG wrapped C data structures.
I have some raw bytes I am passing into the python code which I would like to use to initialize the struct directly. Is there any easy way to do this?
For example
`C struct
struct st{
uint16_t foo;
uint16_t bar;
}
Python code
bytes_val_st = 12345.to_bytes(4, 'big')
obj = st()`
What is the best way to initialize the struct? Can I extend the SWIG struct define with a constructor or is there an easier way to do it directly?
Thank you
I have tried a few things, passing the bytes to the struct, creating a constructor. I am pretty stuck thank you
Michael Silin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.