C语言中的register关键字
A register variable declaration advises the compiler that the variable in question will be heavily used.
register的声明的变量,告诉编译器,这个变量将会被频繁使用。
The idea is that register variables are to be placed in machine registers, which may result in samller and faster program.
这就要求将register变量存放在机器寄存器中,这可以带来更小,更快的程序。
But programs are free to ignore the advice.
但是,程序有权忽略这个建议。
The register variable declaration can only be appied to automatic variables, and to the formal parameters of a functions.
这个寄存器变量声明不仅仅可以用在自动变量上,也能用在函数的参数上。
In practice, there are restrictions on register variables, reflecting the realitied of underlying hardware.
实际上,对register的使用是有限制条件的,这个体现在具体硬件上。
Only a few variables in each function may be ketp in registers, and only certain types are allowed.
每个函数中只有很少的变量能够存放在寄存器中,而且,只是确定的类型可以存放在寄存器中。
Excess register declarations are harmless, however, since the word register is ignored for excess or disallowed declarations.
过多的使用寄存器变量并没有坏处,然而,由于“register”会被忽略的。
And it is not possible to take address of a register variable, regardless of whether the variable is actually placed in register.
特别注意:不能用&取地址符号,去获取一个register变量的地址,无论这个变量是否被实际得存放在寄存器里了