Files
2026-08-11 23:08:24 +08:00

806 B

C/C++ Side

This chapter introduces some things you need to know before writing the C/C++ side files of a C-friendly FFI.

Header File Structure

Writing the C/C++ side of a C-friendly FFI requires two kinds of header files: the C headers and the C++ headers. Each kind may contain any number of individual header files.

The C headers are a simple wrapper around the FFI surface. They must be loadable correctly in both C and C++ translation units.

It is important that the C++ headers are wrappers around the C headers, not rewrites of them from scratch. The C++ headers build on top of the declarations already provided by the C headers and only add the C++ conveniences.

Language Standards

The C headers target the C11 language standard.

The C++ headers target the C++17 language standard.