[Openmcl-devel] Calling Lisp from C example?
yversley at gmx.de
Sun Feb 23 15:09:16 EST 2003
> Can anyone point me towards an example that shows how to call a Lisp
> function from C and how to link that into your C program.
Calling a Lisp function from C is not difficult (but irksome), it can be
done with something like
(defcallback my-c-callback (:without-interrupts nil
(format t "my-c-callback(~A)" arg1))
This creates a C stub for the lisp function and you can give that
to a c function that expects a function pointer.
Linking the lisp interpreter into a C program seems nontrivial to me. The
main routine (in ccl/lisp-kernel/pmcl-kernel.c) does lots of magic to set
up the environment.
If you want to have it simple, you can use Objective C to glue the two
together. This is much simpler than the above (thanks to apple-objc.lisp),
and a good example is in ccl/examples/fscript.lisp
The drawback is that you still have to make a framework out of your C
Openmcl-devel mailing list
Openmcl-devel at clozure.com
More information about the Openmcl-devel