Tag: cffi

用cffi-libffi按值传递结构?

我的印象是CFFI无法通过值传递结构,但CFFI文档说: 要按值传递或返回结构到函数,请加载cffi-libffi系统并将结构指定为(:struct structure-name) 。 要传递或返回指针,可以使用:pointer或(:pointer (:struct structure-name)) 。 我正在重新包装cl-opencv函数get-size ,它是这个opencv函数的包装器: CvSize cvGetSize(const CvArr* arr) 因为我不认为当cl-opencv的作者编写库时,CFFI能够通过cffi-libffi系统按值传递结构,所以他必须使用以下所有代码来包装cvGetSize : (defmacro make-structure-serializers (struct slot1 slot2) “Create a serialization and deserialization function for the structure STRUCT with integer slots SLOT1 and SLOT2. These functions will pack and unpack the structure into an INT64.” (let ((pack-fn (intern (concatenate ‘string (string struct) […]