Targets · Zig · Reserved words

Reserved words

Zig keeps a set of words for its own syntax, so a program cannot use them as names. When a Program name collides with one, the renderer appends a single underscore — fn becomes fn_ — so the program keeps the name it chose and the output still compiles. Because _ is illegal in a Program identifier, the escape can never collide with a name a program actually chose.

Contents

How a Program becomes Zig, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

The full list

Every word Zig reserves, with the identifier a colliding Program name is escaped to. The rule is uniform — append a single _:

Reserved wordRendered identifier
addrspaceaddrspace_
alignalign_
allowzeroallowzero_
andand_
anyframeanyframe_
anytypeanytype_
asmasm_
asyncasync_
awaitawait_
breakbreak_
callconvcallconv_
catchcatch_
comptimecomptime_
constconst_
continuecontinue_
deferdefer_
elseelse_
enumenum_
errdefererrdefer_
errorerror_
exportexport_
externextern_
fnfn_
forfor_
ifif_
inlineinline_
noaliasnoalias_
noinlinenoinline_
nosuspendnosuspend_
opaqueopaque_
oror_
orelseorelse_
packedpacked_
pubpub_
resumeresume_
returnreturn_
linksectionlinksection_
structstruct_
suspendsuspend_
switchswitch_
testtest_
threadlocalthreadlocal_
trytry_
unionunion_
unreachableunreachable_
usingnamespaceusingnamespace_
varvar_
volatilevolatile_
whilewhile_