Passing a pointer to a cstruct
basho1600 at pm.me
basho1600 at pm.me
Mon Jun 29 14:02:22 UTC 2020
I am using SBCL and trying to pass a pointer to a c-struct to
a CFFI routine. The difficulty I am having is in formulating the
function call correctly. I have tried 'define-alien-routine' but
was getting nowhere. So now I am using cffi:foreign-funcall directly.
Here is the call:
(cffi:foreign-funcall
"v4lconvert_convert"
:POINTER convert-info
:POINTER *camera-format*
:POINTER *display-format*
:POINTER raw-image
:INT *local-length*
:POINTER pixdata
:INT pixbuf-size
:INT)
It is the pointers to the two '-format' items that are causing the
trouble I think. Both of them were defined using defcstruct.
But the error message I get is complaining about the expansion of
the foreign-funcall macro and makes no sense at all to me. Can
somebody help me interpret this?
; (CFFI:FOREIGN-FUNCALL "v4lconvert_convert"
; :POINTER ENCOMM.GUI::CONVERT-INFO
; :POINTER ENCOMM.GUI::*CAMERA-FORMAT* :POINTER
; ENCOMM.GUI::*DISPLAY-FORMAT* :POINTER
; ENCOMM.GUI::RAW-IMAGE :INT ENCOMM.GUI::*LOCAL-LENGTH*
; ...)
; --> LET LET LET LET LET LET LET CFFI-SYS:%FOREIGN-FUNCALL
; --> CFFI-SYS::%%FOREIGN-FUNCALL ALIEN-FUNCALL
; --> SB-ALIEN-INTERNALS:INVOKE-WITH-SAVED-FP-AND-PC LAMBDA FUNCTION
; --> SB-ALIEN-INTERNALS:NATURALIZE LET LET LET LET LET LET LET
; --> SB-ALIEN-INTERNALS:MAYBE-WITH-PINNED-OBJECTS PROGN
SB-C:%ALIEN-FUNCALL
; ==>
; (SB-ALIEN-INTERNALS:DEPORT #:G77
; '#<SB-ALIEN::ALIEN-SYSTEM-AREA-POINTER-TYPE SB-SYS:SYSTEM-AREA-POINTER>)
;
; caught WARNING:
; Derived type of #:G77 is
; (VALUES (ALIEN (* T)) &OPTIONAL),
; conflicting with its asserted type
; SB-SYS:SYSTEM-AREA-POINTER.
; See also:
; The SBCL Manual, Node "Handling of Types"
More information about the cffi-devel
mailing list