1

使用 SBCL,我正在尝试使用此签名调用 GStreamer 函数:

void gst_init (int *argc, char **argv[]);

所以我根据我在这里看到的内容编写了这个接口代码(简化) :

(cffi:defcfun gst-init :VOID
  (argc :POINTER :INT)
  (argv :POINTER :STRING))
(defun start-gstreamer ()
   (cffi:with-foreign-object (argc :INT)
     (setf (cffi:mem-ref argc :INT) 1)
     (cffi:with-foreign-string (options "foo ")
       (cffi:with-foreign-object (poptions :POINTER)
         (setf (cffi:mem-ref poptions :POINTER) options)
         (gst-init argc poptions)))))

但是当我运行它时,我得到一个“内存错误”引用一个地址,该地址原来是一个“oof”的 ASCII 字符串,与原始字符串相反。看来我需要另一个级别的间接性。或者也许 defcfun 是错误的。我该如何做到这一点?

4

0 回答 0