I was having trouble running the example in the documents: <br><pre class="lisp"><span class="paren1">(<span class="lisp-bg">foreign-funcall-pointer <span class="paren2">(<span class="lisp-bg">foreign-symbol-pointer <span class="string">"abs"</span></span>)</span><br>
<span class="keyword">:int</span> -42 <span class="keyword">:int</span></span>)</span><br><br>I got <br>SIMPLE-ERROR: Unknown CFFI type: 4.<br><br>I was going crazy, until i searched google code and found this working example: <br>
<a href="http://www.google.com/codesearch/p?hl=en#wVc2UuwHR3k/trunk/tree/resolve.lisp&q=foreign-funcall-pointer%20lang:lisp">http://www.google.com/codesearch/p?hl=en#wVc2UuwHR3k/trunk/tree/resolve.lisp&q=foreign-funcall-pointer%20lang:lisp</a><br>
<br>Retrying with an added "()" before the arg list works.</pre><pre class="lisp"><span class="paren1"><span class="lisp-bg">foreign-funcall-pointer <span class="paren2">(<span class="lisp-bg">foreign-symbol-pointer <span class="string">"abs"</span></span>)</span><br>
() <span class="keyword">:int</span> -42 <span class="keyword">:int</span></span>)<br><br>works !<br><br>This allows one to call a defcallback function from lisp<br><br>making the following unnecessary in the documentation of defcallback<br>
</span>"The macro <code>defcallback</code> defines a Lisp function the can be called<br>from C (but not from Lisp)."<br>because the following works: <br><br>(defcallback fx<br> :int<br> ((x :int)) <br> (progn (print "test") 3))<br>
<br><br>(foreign-funcall-pointer (callback fx)<br>() :int 4 :int)<br><br>Thanks for the cffi,<br>Naveen<br></pre>