CFFI, the Common Foreign Function Interface, purports to be a portable foreign function interface for Common Lisp. The CFFI library is composed of a Lisp-implementation-specific backend in the CFFI-SYS package, and a portable frontend in the CFFI package.

The CFFI-SYS backend package defines a low-level interface to the native FFI support in the Lisp implementation. It offers operators for allocating and dereferencing foreign memory, calling foreign functions, and loading shared libraries. The CFFI frontend provides a declarative interface for defining foreign functions, structures, typedefs, enumerated types, etc. It is implemented in portable ANSI CL making use of the low-level operators exported by CFFI-SYS.


Some of the key features include:

  • an extensible foreign type system;
  • callback support;
  • support for foreign string encodings;
  • ported to ABCL, Allegro CL, Corman CL, CLISP, CMUCL, Digitool MCL, ECL, LispWorks, Clozure CL, SBCL, MKCL and the Scieneer CL;
  • a groveller;
  • support for passing structs by value via libffi;
  • a UFFI compatibility layer.

Getting Started

The latest version is 0.12.0, released on March 5th, 2014 (release notes). For installation instructions, please consult the Installation chapter of the CFFI User Manual. If you're new to either CFFI in particular or FFIs in general, have a look at the tutorial chapter.