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变量的地址,无论这个变量是否被实际得存放在寄存器里了


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值