[plt-scheme] Win32 FFI: Handling structures.

From: Ben Goetter (goetter at mazama.net)
Date: Fri Oct 3 11:51:54 EDT 2008

Elena Garrulo wrote:
> Program fails with: "zero?: expects argument of type <real number>; 
> given #<cpointer>".
The problem stems from your declaration of pbRecvBuffer.  cbRecvLength 
is already cpointer-ized by the time _vector gets its hands on it:
> (_fun [...]
>                      (pbRecvBuffer :  (_vector o _byte cbRecvLength))
>                      (cbRecvLength : (_ptr io _DWORD))
>                      [...] )
Also, note that when the underlying scard call succeeds, you are 
returning a literal list of the four symbols error, ioRecvPci, 
pbRecvBuffer, and cbRecvLength:

>                        -> (if (scard-ok error) '(error ioRecvPci 
> pbRecvBuffer cbRecvLength) #f)


Posted on the users mailing list.