On this page:
FFI2:   Racket Foreign Interface
9.2.0.3

FFI2: Racket Foreign Interface🔗ℹ

 (require ffi2) package: ffi2-lib
The ffi2 library is a more static alternative to ffi/unsafe For more information about the motivation for ffi2, see Interoperability with ffi/unsafe. for using libraries that have a C-based API—without writing any new C code. From the Racket perspective, functions and data with a C-based API are foreign, hence the term foreign interface. Furthermore, since most APIs consist mostly of functions, the foreign interface is sometimes called a foreign function interface, abbreviated FFI.

    1 Overview

      1.1 Unsafety of Foreign Functions

      1.2 Foreign-Function Basics

        1.2.1 Loading C Libraries

        1.2.2 Finding C Functions

        1.2.3 Increasing Safety with Tagged Pointers

        1.2.4 Reducing Boilerplate for Function Definitions

        1.2.5 Defining a Type Conversion

        1.2.6 Putting it All Together

      1.3 Composite Foreign Data

        1.3.1 Array Arguments

        1.3.2 C Structs

        1.3.3 Callbacks from C to Racket

      1.4 Memory Management

        1.4.1 Reliable Release of Resources

        1.4.2 Pointers and GC-Managed Allocation

      1.5 Foreign Unions and Pointer Arithmetic

        1.5.1 Declaring Union Types

        1.5.2 Hiding Pointers through Conversion

    2 Reference

      2.1 Foreign Libraries

      2.2 Base Foreign Types

      2.3 Compound Foreign Types

      2.4 Defining Foreign Types

      2.5 Foreign Pointers

      2.6 Foreign Procedures and Callbacks

    3 Interoperability with ffi/unsafe