J'essaie d'instancier une structure en utilisant la bibliothèque Python cffi. Je voudrais instancier une structure de mon propre fichier .h ainsi que ceux de la bibliothèque standard.Comment instancier une structure dans python cffi?
import datetime
import os
from cffi import FFI
clib = None
script_path = os.path.dirname(os.path.realpath(__file__))
ffi = FFI()
with open(os.path.join(script_path, 'myheader.h'), 'r') as myfile:
source = myfile.read()
ffi.cdef(source)
clib = ffi.dlopen('mylib')
# these all fail
ffi.new("struct tm")
ffi.new("struct tm[]", 1)
ffi.new("struct tm *")
ffi.new("struct mystruct")