Automatically generates complete Common Lisp foreign function interface (FFI) wrappers from C header files using c2ffi.
cl-autowrap is a Common Lisp tool that automatically generates comprehensive foreign function interface (FFI) bindings from C header files. It uses c2ffi to parse C definitions and produces architecture-specific specification files, enabling seamless interaction with C libraries without requiring users to have compilers or header files. The tool focuses on performance, convenience, and completeness, allowing developers to quickly transition from C interfacing to 'lispifying' their code with minimal manual intervention.
Common Lisp developers who need to interface with C libraries, particularly those working on projects that require extensive FFI bindings, such as wrapping system libraries or third-party C APIs. It is also suitable for developers who want to avoid manual FFI definition writing and prefer automated, architecture-specific binding generation.
Developers choose cl-autowrap because it automates the entire FFI binding process with a single command like (c-include "file.h"), generating thin wrappers, recursive accessors, and full metadata without requiring compilers or header files for end-users. Its unique selling points include support for complex C features like bitfields, anonymous structs, and libffi integration for struct-by-value calls, along with flexible configuration for symbol renaming and package management.
(c-include "file.h") => complete FFI wrapper
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
A single command like (c-include "file.h") generates complete FFI bindings, including types, functions, and accessors, eliminating manual definition writing as shown in the README.
Handles nested structs, bitfields, anonymous members, and struct-by-value calls via libffi integration, enabling seamless interaction with intricate C libraries.
Produces .spec files that users can employ without needing c2ffi or C compilers, simplifying deployment across different systems.
Allows excluding definitions with regex, renaming symbols, and separating symbols into packages for better code organization, as detailed in the Tweaking section.
Requires building c2ffi from source, which depends on LLVM and Clang, adding significant setup complexity compared to tools with binary distributions.
The README explicitly warns that duplicate wrappers can occur and lead to bad outcomes, forcing manual management to avoid crashes or memory issues.
Thin wrappers and recursive accessors introduce indirection and validation checks, which may slow down performance-sensitive code compared to raw CFFI calls.