Register variables
A register variable is a type of local
variable. The register keyword tells the compiler
“Make accesses to this variable as fast as possible.” Increasing the
access speed is implementation dependent, but, as the name suggests, it is often
done by placing the variable in a register. There is no guarantee that the
variable will be placed in a register or even that the access speed will
increase. It is a hint to the compiler.
There are restrictions to the use of
register variables. You cannot take or compute the address of a
register variable. A register variable can be declared only within
a block (you cannot have global or static register variables). You
can, however, use a register variable as a formal argument in a function
(i.e., in the argument list).
In general, you shouldn’t try to
second-guess the compiler’s optimizer, since it will probably do a better
job than you can. Thus, the register keyword is best
avoided.