0PricingLogin
Zig Academy · Lesson

Import C Headers with @cImport

Use C declarations from Zig.

Zig Talks to C

Zig can use C libraries directly, with no separate binding layer. The bridge starts with the built-in @cImport.

What @cImport Does

@cImport runs Zig's C compiler on a tiny C file you describe, then exposes every declaration it finds as a normal Zig namespace.

All lessons in this course

  1. Import C Headers with @cImport
  2. Calling C Functions and Linking
  3. C Pointers, Strings, and Types
  4. zig translate-c to Read C as Zig
← Back to Zig Academy