# Zig Level 8: C Interoperability

> Level 8: C Interoperability of the LoWisa Zig course: Calling C, Exporting Zig, Replacing or Extending C Components. 3 lessons and 9 ideas, each explained in one line.

C Interoperability is level 8 of 11 of the [LoWisa Zig course](/courses/zig/). It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

## Calling C

- **@cImport.** **@cImport** translates C headers into Zig at build time: bindings without a generator step.
- **C types in Zig.** C types map explicitly: c_int, sentinel **strings**, extern structs matching layouts.
- **Linking.** The build links C **libraries** directly: Zig as the glue over any native stack.

## Exporting Zig

- **export.** **export** gives a function the C ABI: Zig callable from anything that speaks C.
- **ABI-stable surfaces.** Exported APIs stay **C-shaped**: plain structs, no error unions across the border.
- **Errors at the border.** Boundary functions translate errors to **codes**: the union stays home, the contract crosses.

## Replacing or Extending C Components

- **Incremental replacement.** Zig replaces C **file by file**: same build, same ABI, safety rising per commit.
- **Drop-in libraries.** A Zig library exporting the old **header** is a drop-in: consumers never noticing the swap.
- **Honest costs.** Interop is powerful, not free: translated headers audited, layouts **verified** by test.

## Before and after this level

- **Before:** [Level 7: Modules & Build System](/courses/zig/level-7-modules-and-build-system/): Modules, Zig Build, Dependencies and Cross Compilation.
- **Next:** [Level 9: Testing & Debugging](/courses/zig/level-9-testing-and-debugging/): Built-In Testing, Debugging Native Programs, Safety Modes.

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See [Checkpoints and flashcards](/help/checkpoints-and-flashcards/).

## Frequently asked questions

### What does Zig Level 8: C Interoperability cover?

Calling C, Exporting Zig, Replacing or Extending C Components: 3 lessons and 9 ideas.

### What should I know before this level?

The level before it, Level 7: Modules & Build System, which covers Modules, Zig Build, Dependencies and Cross Compilation.

## Learn Zig on your phone

The first level is free. LoWisa is on Google Play and the App Store.

---

Source: https://lowisa.dev/courses/zig/level-8-c-interoperability/ · Updated 2026-11-25
