[Larceny-users] boxed vs. void* in the Larceny FFI on Windows

David Rush kumoyuki at gmail.com
Mon Jul 23 01:20:38 EDT 2007


On 7/22/07, Felix Klock <felixluser at pnkfx.org> wrote:
> On Jul 22, 2007, at 6:08 PM, David Rush wrote:
> > SO can someone tell me what the difference is between
> > boxed and void* in the (require 'std-ffi) layer? *And* how to pass a
> > null pointer to a call-out in a reliable fashion?
>
> I'll write up a more complete answer to these questions later and
> incorporate it into the docs, but I thought you'd like a quick answer
> now.

Bingo. And thank you very much for the effort :)

> A parameter of the 'boxed' type is meant to be a structured Scheme
> ...
> To pass a null pointer as a parameter declared as 'boxed' or '(maybe
> void*)', I pass #f.  The void* type doesn't support null pointers
> (again an artifact of my GTK experiments; I wanted to be able to
> express in an interface to a foreign function that null pointers are
> not accepted by a particular function); that's why you have to use
> the 'maybe' unary type constructor.

Aha! That's the missing link. In the MySQL API mysql_init() function
you have one of those `smart' memory management interfaces that lets
you choose who allocates the memory by
passing in an optionally null pointer, so I guess that is where you
mean to use (maybe void*). I am presuming that you must pass this as a
list where normally you are using symbols in the FFI specs. I don't
recall seeing the maybe form in the *ffi-attributes* list in std-ffi
anyway.

Ta much,

david
-- 
Once you label me, you negate me
    - Soren Kierkegaard



More information about the Larceny-users mailing list