[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] Foreign Function Interface, something similar to clisp f
Re: [Gcl-devel] Foreign Function Interface, something similar to clisp ffi?
08 Jan 2005 14:40:07 -0500
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
Check the docs on compiler::link.
(compiler::link nil "new_image" "" "-lfoo")
Will give you a new_image with libfoo linked in, which you can then
reference with defentry and c-lines.
Please keep us posted.
Camilo Olarte <address@hidden> writes:
> Hello list,
> I was studying the way to interface foreign functions from common lisp, until
> now i can only do it with clisp implementation, i was wondering how can i do
> same in gcl.
> the idea is to access functions from a shared library in the example's case it
> is the libncurses library.
> I am aware of the defentry and c-lines functions in gcl , but until now the
> only clear thing i understand : is that with defentry you can access functions
> to linked libraries that were chosen in time of compilation of the gcl
> implementation. Also c-lines would let me include a chunk of c code.
> The idea i repeat is to access a shared library, in the documentation
> is said about faslinks... what i understand is that it only works in BSD
> machines...not linux (by the way i am testing this code in linux machine RH9
> So back to the question : is there some gcl code equivalent to the cliso one
> can i access a shared c library (*.so) from gcl implementation without having
> recompile the gcl implementation to make this links??
> ---- start lisp code : clisp 2.33 implementation -----
> (use-package 'ffi)
> (default-foreign-language :stdc)
> ; Macro to define foreign functions
> (defmacro cfunc (lisp-name c-name &key arguments return-type)
> `(def-call-out ,lisp-name
> (:name ,c-name)
> (:library "/lib/libncurses.so")
> (:arguments ,@arguments)
> ,@(if return-type (list `(:return-type ,return-type)))))
> ; Define the external functions
> (cfunc initscr "initscr")
> (cfunc refresh "refresh")
> (cfunc getch "getch")
> (cfunc printw "printw" :arguments ((message c-string)))
> (cfunc endwin "endwin")
> ; use foreign functions from clisp
> (printw (format nil "Hello ~2%World"))
> ---- end lisp code -----
> Camilo Olarte
> Telesat, más fácil...más Internet.
> Gcl-devel mailing list
Camm Maguire address@hidden
"The earth is but one country, and mankind its citizens." -- Baha'u'llah