[plt-scheme] PLT Scheme FFI on Win32: handling structures and byte arrays
Elena Garrulo wrote:
> I'm trying out PLT Scheme FFI on WIn32. Examples included into the
> distribution show only simpler cases.
IMHO the distribution could use some more elaborate examples. It's just
that there is little code in the wild using the PLT Scheme FFI.
> (pioSendPci : _SCARD_I0_REQUEST-pointer) ;; ERROR: expand: unbound variable in module in: __SCARD_I0_REQUEST-pointer
I guess it should be IO instead of I0.
> (pbSendBuffer : (_cvector i _byte)) ;; ERROR: expand: unbound variable in module in: i
Should be _vector here, not _cvector.
> (pbRecvBuffer : (_cvector o _byte )) ;; ERROR: expand: unbound variable in module in: o
For output vectors you need the length so try this:
(pbRecvBuffer : (_vector o _byte cbRecvLength))
(cbRecvLength : (_ptr io _DWORD))
Quote from the manual:
#v+
The optional len argument is needed for output values where it is used
in the post code, and in the pre code of an output mode to allocate the
block. In either case, it can refer to a previous binding for the length
of the list which the C function will most likely require.
#v-
Btw. Eli, as can be seen here we can refer to a following binding as
well. Maybe the docs could use some clarification?
> And what about byte aligned, word aligned, double word aligned
> structures? What about calling conventions?
Everything is handled by libffi.
--
regards,
Jakub Piotr Cłapa