[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] c-callbacks
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] c-callbacks |
Date: |
Mon, 20 Aug 2007 00:30:45 +0200 |
On 8/17/07, Bastian Müller <address@hidden> wrote:
>
> ODE uses the following callback:
> typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
> that I interfaced by
> (define-foreign-type dNearCallback (function void (c-pointer
> dGeomID dGeomID)))
>
> For the collision detection call
> void dSpaceCollide (dSpaceID space, void *data, dNearCallback
> *callback);
> I used
> (define ode-space-collide
> (foreign-lambda void "dSpaceCollide" dSpaceID c-pointer
> dNearCallback))
>
> As an example callback I defined:
> (define-external (foobar (c-pointer data) (dGeomID geom1) (dGeomID
> geom2)) void
> (printf "collision") (newline))
>
> Finally, I tried to do the actual call.
> First, I tried:
> (ode-space-collide space (null-pointer) foobar)
> and during the simulation I got an
> Error: bad argument count - received -2 but expected 3: error in
> error
> graphics.scm: 76 ode-space-collide <--
This has nothing to do with arguments, instead it means that the runtime
system is completely screwed up. I assume it is due to "ode-space-collide":
You *MUST* (_MUST_, /MUST/) use "foreign-safe-lambda[*]", instead
of "foreign-lambda[*]" for foreign procedures that invoke, or may invoke
callbacks.
cheers,
felix