extern struct and ABI Layout
Match C struct memory layout.
Talking to C
When Zig calls into C code, both sides must agree on memory layout. That shared contract is the ABI.
Plain Structs Are Not Guaranteed
A regular struct lets Zig pick field order and padding freely, so its layout may not match what a C library expects.
All lessons in this course
- packed struct for Exact Layout
- Arbitrary-Width Integers like u3
- Bit Fields and Flags
- extern struct and ABI Layout