[cffi-devel] foreign-funcall-pointer documentation

Naveen Garg naveen.garg at gmail.com
Mon Apr 6 21:09:13 UTC 2009


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&q=foreign-funcall-pointer%20lang: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20090406/e4f97692/attachment.html>


More information about the cffi-devel mailing list