[gambit-list] How to pass a procedure to a nonnull-function?
Vok Vojwo
ceving at gmail.com
Thu Nov 3 08:22:26 EDT 2011
I tried to pass a Scheme procedure to a C nonnull-function. The
documentation says that the two types should be compatible:
http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html#mapping-of-types
But I get the error that the conversion can not be done:
*** ERROR IN ##execute-program -- (Argument 1) Can't convert to C
nonnull-function
(call-func '#<procedure #2 proc>)
This is my test program:
;; Local Variables:
;; compile-command: "gsc -exe ffi-hello.scm"
;; End:
(c-declare #<<end-of-c-declare
typedef void(*func_t)(void);
void call_func (func_t func)
{
func();
}
end-of-c-declare
)
(c-define-type func_t (nonnull-function () void))
(define call-func
(c-lambda (func_t) void "call_func"))
(define proc (lambda () (display "Hello, World!")))
(write (procedure? proc))
(call-func proc)
Can anybody tell me whats wrong?
More information about the Gambit-list
mailing list