[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:


But I get the error that the conversion can not be done:

*** ERROR IN ##execute-program -- (Argument 1) Can't convert to C
(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)


(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