### register

The register storage class specifier indicates to the compiler that a heavily used variable (such as a loop control variable) within a block scope data definition or a parameter declaration should be allocated a register to minimize access time.

It is equivalent to the auto storage class except that the compiler places the object, if possible, into a machine register for faster access.

Most heavily-used entities are generated by the compiler itself; therefore, register variables are given no special priority for placement in machine registers. The register storage class keyword is required in a data definition and in a parameter declaration that describes an object having the register storage class. An object having the register storage class specifier must be defined within a block or declared as a parameter to a function.

The following example lines define automatic storage duration objects using the register storage class specifier:

>     register int score1 = 0, score2 = 0;
>     register unsigned char code = 'A';
>     register int *element = &order[0];

Initialization
You can initialize any register object except parameters. If you do not initialize an automatic object, its value is indeterminate. If you provide an initial value, the expression representing the initial value can be any valid C expression. For structure and union members, the initial value must be a valid constant expression if an initializer list is used. The object is then set to that initial value each time the program block that contains the object's definition is entered.

Storage
Objects with the register storage class specifier have automatic storage duration. Each time a block is entered, storage for register objects defined in that block are made available. When the block is exited, the objects are no longer available for use.

If a register object is defined within a function that is recursively invoked, the memory is allocated for the variable at each invocation of the block.

The register storage class specifier indicates that the object is heavily used and indicates to the compiler that the value of the object should reside in a machine register. Because of the limited size and number of registers available on most systems, few variables can actually be put in registers.

If the compiler does not allocate a machine register for a register object, the object is treated as having the storage class specifier auto.

Using register definitions for variables that are heavily used may make your object files smaller and make them run faster. In object code, a reference to a register can require less code and time than a reference to memory. In C programs, even if a register variable is treated as a variable with storage class auto, the address of the variable cannot be taken.

Restrictions
You cannot use the register storage class specifier in file scope data declarations.

You cannot apply the address (&) operator to register variables.

However, C++ lets you take the address of an object with the register storage class. For example:

>     register i;
>     int* b = &i; // valid in C++, but not in C

auto