0PricingLogin
Zig Academy · Lesson

comptime Parameters and Values

Pass values that exist at compile time.

Some Arguments Must Be Known Early

Sometimes a function needs an argument the compiler can see, not just the running program. Zig lets you mark such a parameter comptime. 🧩

Marking a comptime Parameter

Write comptime before a parameter name to require that its value be known at compile-time. The caller must pass a known value.

fn repeat(comptime n: usize) void {}

All lessons in this course

  1. Compile-Time vs Run-Time
  2. comptime Parameters and Values
  3. Types Are comptime Values
  4. inline for and Unrolled Loops
← Back to Zig Academy