| Section | Title |
|---|---|
| 1 | Understanding @ Builtins |
| 2 | @import |
| 3 | @sizeOf |
| 4 | @alignOf |
| 5 | @Type |
| 6 | @typeInfo |
| 7 | @ptrCast |
| 8 | @bitCast |
| 9 | @memcpy |
| 10 | @intCast |
| 11 | @truncate |
| 12 | @floatCast |
| 13 | @panic |
| 14 | @compileError |
| 15 | @embedFile |
| 16 | Important Builtins in Zig 1.16 |
Understanding `@` BuiltinsZig has special built-in functions whose names start with @.
`@import`One of the first Zig builtins you will learn is @import.
`@sizeOf`@sizeOf asks the Zig compiler how many bytes a type needs in memory.
`@alignOf`@alignOf asks the Zig compiler for the required memory alignment of a type.
`@Type`@Type builds a type from compile-time type information.
`@typeInfo`@typeInfo asks the compiler for structured information about a type.
`@ptrCast`@ptrCast converts one pointer type into another pointer type.
`@bitCast`@bitCast reinterprets the bits of one value as another type.
`@memcpy`@memcpy copies bytes from one memory region to another.
`@intCast`@intCast converts one integer value to another integer type.
`@truncate`@truncate converts an integer to a smaller integer type by keeping only the low bits.
`@floatCast`@floatCast converts one floating-point value to another floating-point type.
`@panic`@panic stops the program immediately with a message.
`@compileError`@compileError stops compilation with a custom error message.
`@embedFile`@embedFile reads a file at compile time and embeds its bytes into the final program.
Important Builtins in Zig 1.16This chapter covered the builtins you will see most often as a beginner.