I was having trouble running the example in the documents:
(foreign-funcall-pointer (foreign-symbol-pointer "abs")
:int -42 :int)
I got SIMPLE-ERROR: Unknown CFFI type: 4.
I was going crazy, until i searched google code and found this working example: http://www.google.com/codesearch/p?hl=en#wVc2UuwHR3k/trunk/tree/resolve.lisp...
Retrying with an added "()" before the arg list works.
foreign-funcall-pointer (foreign-symbol-pointer "abs")
() :int -42 :int)
works !
This allows one to call a defcallback function from lisp
making the following unnecessary in the documentation of defcallback "The macro defcallback defines a Lisp function the can be called from C (but not from Lisp)." because the following works:
(defcallback fx :int ((x :int)) (progn (print "test") 3))
(foreign-funcall-pointer (callback fx) () :int 4 :int)
Thanks for the cffi, Naveen
On Mon, Apr 6, 2009 at 10:09 PM, Naveen Garg naveen.garg@gmail.com wrote:
I was having trouble running the example in the documents:
(foreign-funcall-pointer (foreign-symbol-pointer "abs") :int -42 :int)
Thanks! It should be fixed now.