In C, what keyword declares a variable for fast access in a register?

The story behind the answer

In C, the keyword that declares a variable as a candidate for fast access in a CPU register is register.

register is a storage-class keyword and compiler hint. Historically, programmers used it for values such as loop counters or frequently accessed variables, suggesting that the compiler keep them in a processor register rather than ordinary memory. Registers are much faster to access, but they are scarce hardware resources.

The keyword never guaranteed that the variable would actually be placed in a register; the compiler could ignore the request based on the target processor, optimization settings, or surrounding code. In modern C compilers, optimization algorithms usually make better allocation decisions automatically, so register is rarely useful as a performance command.

A notable language consequence is that a variable declared with register cannot have its address taken with the address-of operator. The alternatives are different: auto indicates ordinary automatic storage, static changes storage duration or linkage, and volatile tells the compiler that a value may change unexpectedly.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: