[squeak-dev] Send NULL to a C function trough FFI
Mariano Martinez Peck
marianopeck at gmail.com
Wed Sep 17 05:09:37 UTC 2008
Igor: I tried what you said but I get the same error. Here is more information:
The C function is like this:
int *odbx_result*(
odbx_t* *handle*,
odbx_result_t** *result*,
struct timeval* *timeout*,
unsigned long *chunk* )
My method with FFI is this:
apiQueryResult: connectionHandle handle: handle timeout: timeout chunk:
chunk
<cdecl: long 'odbx_result' (ulong ulong* DBXTimeSpec ulong) module:
'opendbx'>
^self externalCallFailed
And DBXTimeSpec has 2 attributes (seconds y nseconds). It has this class
message:
DBXTimeSpec
fields
^#(
(seconds 'long')
(nseconds 'long'))
Many thanks,
Mariano
On Wed, Sep 17, 2008 at 2:02 AM, Igor Stasenko <siguctua at gmail.com> 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.
>
> > many thanks,
> >
> > mariano
> >
> >
> >
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080917/5da1427f/attachment.htm
More information about the Squeak-dev
mailing list
|