| Section | Title |
|---|---|
| 1 | Calling C |
| 2 | @cImport |
| 3 | Header Translation |
| 4 | Linking Libraries |
| 5 | Calling Zig from C |
| 6 | ABI and Layout |
| 7 | Exercises |
Calling COne of Zig's design goals is direct interoperability with C.
`@cImport`Writing every C declaration by hand is tedious. Zig can read C headers directly.
Header Translation@cImport does two jobs.
Linking LibrariesCalling a C function is only half the job. The linker must also find the code for that function.
Calling Zig from CC can call Zig when the Zig function is exported with a C-compatible ABI.
ABI and LayoutA C program and a Zig program can share data only when both sides agree on layout.
ExercisesExercise 16-1. Write a C file containing this function: