A portable foreign function interface (FFI) for Common Lisp that abstracts differences between Lisp implementations.
CFFI is a foreign function interface library for Common Lisp that enables Lisp programs to call C functions and interact with shared libraries. It provides a portable abstraction layer over the native FFI capabilities of different Common Lisp implementations, allowing developers to write cross-implementation compatible code. The library handles foreign memory management, function calling, and library loading through a declarative interface.
Common Lisp developers who need to interface with C libraries, system APIs, or existing native codebases while maintaining portability across different Lisp implementations.
CFFI offers a standardized, implementation-agnostic approach to foreign function calls in Common Lisp, eliminating the need to write different FFI code for each Lisp environment. Its declarative interface and optional C2FFI toolchain for automatic binding generation significantly reduce the boilerplate and complexity of creating C bindings.
The Common Foreign Function Interface
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
CFFI abstracts the FFI differences between Common Lisp environments, allowing code to run on multiple implementations like SBCL and CCL without changes, as highlighted in its portable frontend design.
It provides a high-level, declarative interface for defining foreign functions, structures, and types, reducing boilerplate and making FFI code more readable and maintainable.
With CFFI/C2FFI, developers can automatically generate bindings from C header files using Clang, speeding up integration with complex C libraries, though it requires external tools.
Includes operators for foreign memory allocation and dereferencing in the CFFI-SYS backend, essential for low-level C data interaction and shared library handling.
CFFI/C2FFI integration depends on c2ffi and Clang, which can be a hurdle to set up and maintain, especially in restricted or cross-platform environments.
Key features like CFFI/C2FFI lack proper documentation, forcing users to rely on example projects for guidance, as admitted in the README notes.
The abstraction layer may introduce runtime overhead compared to direct native FFI calls, which could impact performance-sensitive applications.