FLI: sending binary data from Lisp to C
Hi, I’m building a dynamic library in LispWorks, to be called from C. The library produces binary data (size not known at compile time). My problem is that I don’t understand how to define the foreign function regarding the pointer parameters. This is what I have in C: typedef int(*data_function)(unsigned char**); … unsigned char** data; int size = get_data(data); And in Lisp: (fli:define-foreign-callable (preview_pdf :result-type :int) ((out-data (:reference-pass :pointer))) (let* ((size 256) (test-data (make-array size :element-type '(unsigned-byte 8))) (c-array (fli:allocate-foreign-object :type :unsigned-byte :nelems size :initial-element 0))) (fli:replace-foreign-array c-array test-data) (fli:with-coerced-pointer (ptr) c-array (setf out-data ptr)) size)) But it seems I got the pointer type wrong: An error of type FLI:FOREIGN-TYPE-ERROR occured, arguments : (:EXPECTED-TYPE :POINTER :DATUM #<unknown object, header / pointer: 202AAD11 /EE1FEE2F>) Any suggestions? Thanks Erik _______________________________________________ Lisp Hug - the mailing list for LispWorks users lisp-hug@lispworks.com http://www.lispworks.com/support/lisp-hug.html