gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Foreign Function Interface, something similar to clisp f


From: Camm Maguire
Subject: Re: [Gcl-devel] Foreign Function Interface, something similar to clisp ffi?
Date: 08 Jan 2005 14:40:07 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

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.

Take care,

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 
> the
> 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 
> something
> 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 
> and
> debian)
> 
> So back to the question : is there some gcl code equivalent to the cliso one
> below???
> can i access a shared c library (*.so) from gcl implementation without having 
> to
> 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
> (initscr)
> (printw (format nil "Hello ~2%World"))
> (refresh)
> (getch)
> (endwin)
> ---- end lisp code -----
> 
> Camilo Olarte
> Telesat, más fácil...más Internet.
> http://www.telesat.com.co/
> 
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gcl-devel
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]