0
私はPythonのcffiライブラリを使用して構造体をインスタンス化しようとしています。私は自分の.hファイルから構造体をインスタンス化したいと思います。また、標準ライブラリの構造体もインスタンス化したいと思います。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")