[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] ffi howto

From: Richard
Subject: Re: [Chicken-users] ffi howto
Date: Fri, 21 Nov 2014 18:32:14 +0000

Hello Omar,

The problem with your code is that wait-for-a-while must be declared as
an external function; like so:

  (wait_for_a_while ((c-pointer uv-idle-t) handle))
  (let lp ((counter 0))
    (if (>= counter 10000000)
        (uv-idle-stop handle)
        (lp (+ counter 1)))))

note that the name of the function must be a valid C function name, so
it cannot be dash-seperated. Also looking at the libub documentation,
the callback did not have a status argument.

An external function that is going to call such a callback function must
be declared using 'foreign-safe-lambda' instead of
'foreign-lambda'. Thus uv-run must be declared as such:

(define uv-run
  (foreign-safe-lambda int "uv_run" (c-pointer uv-loop-t) int))

Hope this helps and good luck,

address@hidden writes:

> Hello,
> I need some help getting started with ffi. 
> I am attempting to bind libuv to scheme code.
> My chicken scheme code at fails with the
> following error.
> The following code fails with the following:
> Error: bad argument count - received 152135942 but expected 2: 0
>       Call history:
>       uv.scm:33: uv-default-loop        
>       uv.scm:33: uv-idle-init   
>       uv.scm:34: uv-idle-start          
>       uv.scm:36: uv-default-loop        
>       uv.scm:36: uv-run               <--
> I am attempting to port the following C code.
> - Omar
> _______________________________________________
> Chicken-users mailing list
> address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]