Hi,<br>I am able to use
foreign-funcall-pointer to call an ecl callback from within ecl.
However, I get a memory access violation when I use the same pointer to
callback from within a dll loaded into ecl. Does anyone else have the
same issue calling into lisp from c? This technique works fine from sbcl for me. I tried defining the ecl callbacks without using cffi, but got similar problems. <br><br>
I am using the <small><b style="color: black; background-color: rgb(102, 255, 255);">win32</b>-msvc-<b style="color: black; background-color: rgb(255, 102, 255);">stable git branch compiled with threads enabled on windows xp using msvc 2008<br>
bit branch by </b></small><b>Samium Gromoff </b><br>although when i startup ecl, it still says this outdated message: <br>
ECL (Embeddable Common-Lisp) 0.9l (CVS 2008-07-12 18:54)<br><br>Thanks, <br>Naveen<br>Here is the ecl-code: <br>(in-package :cffi)<br>(load-foreign-library "AutoHotkey.dll") <br>(defvar *ahk* "")<br>
(defcallback sbclHotkey<br>
:int <br> ((x :string)) <br> (progn <br> (print x)(print " recieved from dll") <br> 0)) <br>(setf sbclHotkeyP (format nil "~d" (pointer-address (callback sbclHotkey))))<br>(defcfun "ahkdll" <br>
:int<br> (file :string) ; ahk script to launch<br> (p :string) ; pointer to sbclHotkey callback<br> (q :string) ; pointer to sbclHotkey callback<br>)<br>(defcfun "ahkgetvar" <br> :string<br> (varname :string) )<br>
<br>(ahkdll "clinit.ahk" "" sbclHotkeyP)<br>(setf *ahk* (ahkgetvar "ahkCallBack"))<br>(foreign-funcall-pointer (make-pointer (read-from-string *ahk*)) ()<br> :string "Execute, Hotkey, !g, sbclHotkey" :int)<br>
; a hotkey is registered, but the callback fails<br>(foreign-funcall-pointer (make-pointer (pointer-address (callback sbclHotkey)))()<br>:string "test" :int) <br>; this works, but its from within ecl. <br><br>
the ahk side of the code is available here: <br>
<a href="http://github.com/tinku99/ahklisp/tree/master" target="_blank">http://github.com/tinku99/ahklisp/tree/master</a>