[squeak-dev] Re: Send NULL to a C function trough FFI
andreas.raab at gmx.de
Wed Sep 17 05:18:58 UTC 2008
Igor Stasenko wrote:
> 2008/9/17 Mariano Martinez Peck <marianopeck at gmail.com>:
>> Hi everybody!
>> I need to call a C function with a NULL value in one of the parameter. I
>> tried to send it a nil but I got an error in FFI when trying to call that
>> function. The error is: "cannot coerce arguments". Obviously this error says
>> FFI cannot map from nil to null.
>> Do someone know how can I do this?
> you mean C's NULL?
> AFAIK it defined as
> #define NULL 0
> so, in squeak you can simply pass 0.
Except where pointers are expected - the FFI does not allow passing an
int as a pointer. Using nil is the correct way of doing it. If it
doesn't work then there is something wrong with the declaration.
More information about the Squeak-dev