CFFI Package

The cffi package is an extension that implements a Foreign Function Interface for Tcl. It is based on the dyncall library available from .

The repository for the package is at . Current version as of 2021-11-20 is 1.0b0.

Documentation pages are at .

Source distributions and binary packages for some platforms are at .

Distinguishing features of the package are

  • Automatic conversion of numerics, strings, structures and arrays to and from the corresponding Tcl script values
  • Safety mechanisms to protect against pointer errors like double frees, mismatched types
  • Support for automatic encoding of string values passed and returned from C functions
  • Exception generation based on error annotations
  • Proc-like argument processing with defaults, error messages etc.
  • Utilities for managing memory and conversion to native formats
  • Extensible type aliases for common system definitions
  • Introspection

Limitations (as of 1.0) include

  • No support of functions taking variable number of arguments
  • No support for callbacks from C code
  • No support for passing structs by value

See also

Driving Libzip with CFFI