Declare Struct Containing Time_t Field In Python Cffi
I am using CFFI to call a C function from Python that returns a struct. The struct is defined with a time_t element. How do I declare the struct to CFFI so that I can access it fro
Solution 1:
I fear there is no nice answer. You need to write typedef long time_t;
or similar, assuming that time_t is always the same size as long. If the code is supposed to be portable to platforms where time_t might be different, then you would need to separately get the size:
ffi1 = cffi.FFI()
ffi1.cdef("""#define SIZE_OF_TIME_T ...""")
lib = ffi1.verify("""
#include <sys/types.h>
#define SIZE_OF_TIME_T sizeof(time_t)
""")
size_of_time_t = lib.SIZE_OF_TIME_T
Post a Comment for "Declare Struct Containing Time_t Field In Python Cffi"