ffi

FFI is short for Foreign Function Interface, which is useful for linking to an arbitrary C library from Lisp code.
I'm starting work on interfaces to common C-based libraries such as libggi, ImageMagick and possibly more. It seems quite a hassle to support all Common Lisp implementations by hand, so a generic ffi generator tool is useful. Currently many projects have implemented their own tools for this (I can think of Langband, Matlisp). People in comp.lang.lisp make me believe that a generic tool is not necessary, but I beg to differ. Any comments? -- Tijs van Bakel
You might take a look at cparse. -- Tim Moore

Tijs van Bakel replies: cparse is indeed a great tool. Is the goal of cparse to cooperate with a seperate ffi code generator, or is that supposed to be part of cparse? (feel free to remove question if answered on cparse page)

Tim Moore responds: The cparse "code generator" (declaration generator is more accurate) is seperate from the C parsing machinery. The goal is to distribute generators for many implementations with the cparse distribution. The reality is somewhat short of that right now; there's only a generator for CMUCL. I may write one for ACL in the near future.

Surendra Singhi comments: Look at SWIG (tool for generating automatic ffi wrappers), it currently supports AllegroCL and CLISP, and it should not be hard to extend it to other lisp implementations. Some documentation on using it can be found here.

ah2cl is a (very (very)) simple and naive C header parser (according to its web page).


No discussion of FFIs between different implementations would be complete without mentioning UFFI, a thin macro layer over the FFIs for several Lisp implementations. -- Peter Scott

Add CFFI to this list, a different design than UFFI, also working across several Lisp implementations -- Jörg Höhle

A nice summary of (not only Lisp) FFIs can be found on Reini Urban's page.


Pages in this topic: cparse   ffigen   IOlib-POSIX   Objective-CL  


Also linked from: alien   cl-fish   Current recommended libraries   Cut and shut   ECoLisp   perl-in-lisp   Picasso   Reini Urban   SWIG  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively