Next: ffi foreign wrapper, Previous: ffi shared, Up: ffi [Index]
Callouts allow Scheme code to invoke C functions in a foreign library; callbacks allow foreign C code to call a Scheme function. The following example shows how Scheme code can call a callout which in turns calls a callback:
#!r6rs (import (rnrs) (prefix (vicare ffi) ffi::)) (define callout-maker (ffi::make-c-callout-maker 'unsigned-int '(unsigned-int))) (define callback-maker (ffi::make-c-callback-maker 'unsigned-int '(unsigned-int))) (define callback (callback-maker values)) (define callout (callout-maker callback)) (callout 123) ⇒ 123 (ffi::free-c-callback callback)
• ffi call intro: | Overview of FFI function calls. | |
• ffi call out: | Calling out to foreign procedures. | |
• ffi call back: | Calling back to Scheme. | |
• ffi call types: | Specifying native types. |