注册变量 [英] Register variables
问题描述
请清除我的怀疑。我们什么时候声明变量是一个寄存器
变量?它的意义是什么?当函数之间传递寄存器变量时,有什么条件是
?
Please clear my doubt. When do we declare a variable to be a register
variable? What is its significance? What are the conditions to be
adhered to when register variables are passed between functions?
推荐答案
" ;因此********* @ gmail.com" < so ********* @ gmail.comwrote:
"so*********@gmail.com" <so*********@gmail.comwrote:
请清除我的疑问。我们什么时候声明变量是一个寄存器
变量?
Please clear my doubt. When do we declare a variable to be a register
variable?
我们不是。在99.99%的情况下,现代编译器比程序员更好地确定这些事项。
Richard
We don''t. Modern compilers are, in 99.99% of all cases, better at
determining such matters than programmers are.
Richard
so*********@gmail.com 写道:
请清除我的疑问。我们什么时候声明变量是一个寄存器
变量?它的意义是什么?当函数之间传递寄存器变量时,有什么条件可以遵守
?
Please clear my doubt. When do we declare a variable to be a register
variable? What is its significance? What are the conditions to be
adhered to when register variables are passed between functions?
什么时候宣布:正如Richard Bos和Corcoran上尉所说,
从不。好吧,几乎没有。
意义:在旧日里,'注册''是一个提示,
编译器应该尝试保存变量在CPU寄存器中
而不是在内存中。编制者在单独做出这些决定时已经变得更好了,而且这些提示可以反作用于b
。许多编译器忽略了提示。 寄存器的剩余
效果是声明没有指针可以在此变量上指向
。
传递条件:无,因为`register''变量
永远不会传递给函数和从函数传递。既不是'auto''
变量或`静态''变量,也不是任何种类的变量
all:C函数接收和返回*值*,而不是变量。
-
Eric Sosman
es*****@acm-dot-org.inva 盖子
所以********* @ gmail.com 写道:
请清除我的疑问。我们什么时候声明变量是一个寄存器
变量?它的意义是什么?当函数之间传递寄存器变量时,有什么条件可以遵守
?
Please clear my doubt. When do we declare a variable to be a register
variable? What is its significance? What are the conditions to be
adhered to when register variables are passed between functions?
qulifier''register''用于向编译器建议有关的
对象可能被大量访问,因此应该
最好存储在机器寄存器中。寄存器是一个非常快的存储单元的集合,通常在处理器本身内。
注意寄存器的使用仅仅是对编译器的建议,>
可以免费忽略它。
在几乎所有情况下,当前编译器在分配
寄存器方面比程序员更好。因此,寄存器说明符是
,大多是过去的遗物,您不必担心。
至于它的限制,只有自动对象可以用
寄存器来限定,并且注册合格对象的地址可能不是
,即&操作员不能使用。
The qulifier ''register'' used to suggest to the compiler that the
object concerned is likely to be heavily accessed and hence should
preferably be stored in a machine register. Registers are a collection
of very fast memory cells, most often within the processor itself.
Note that the use of register is merely a suggestion to the compiler,
which is free to ignore it.
Current compilers are, in almost all cases, better at allocating
registers than a programmer would be. Hence the register specifier is
mostly a relic from the past that you should not have to worry about.
As for it''s restrictions, only auto objects can be qualified with
register and the address of a register qualified object may not be
taken, i.e. the & operator cannot be used.
这篇关于注册变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!