C - Register variables

From EdWiki

Register variables

  • The register declaration advises the compiler that the variable in question are to be placed in machine(cpu) registers.
  • Compilers are free to ignore the advice.


register int count;
register char ch;
  • The register declaration can only be applied to automatic variables and to the formal parameters of function.
  • It is not possible to take the address of a register variable, regardless of whether the variable is actually placed in a register.