[英]why the argument of a function are register type
sorry if my accent hurts 抱歉,如果我的口音疼
In C Programming, you can declare a function like this: dennis ritche 2nd ed page 84 在C编程中,您可以声明如下函数:dennis ritche第2版第84页
f(register unsigned m,register long n)
Most of the books say that the default storage type of function arguments are preferably register
. 大多数书都说函数参数的默认存储类型最好是
register
。
Why so? 为什么这样? What is the need?
有什么需要?
answer followed compiler keeps them with cpu registers but 回答跟着编译器保持与cpu寄存器,但
I've not seen any difference in execution speed when using register type 使用寄存器类型时,我没有看到执行速度有任何差异
Can any one explain in detail why and where and when exactly the register is used in C Programming? 任何人都可以详细解释为什么以及何时何地在C编程中使用寄存器?
thanks 谢谢
I'd be interested in seeing which books say this. 我有兴趣看看哪些书说这个。
To be honest, at this point the state of compiler technology, there is almost never any use to declaring something with a register
modifier. 说实话,在这一点上编译器技术的状态,几乎从来没有任何用于声明
register
修饰符的东西。 In fact, many compilers will simply throw this out, and do whatever they want. 事实上,许多编译器只会抛弃它,并做任何他们想做的事情。 The point is that this varies so much across architectures, compilers, and is also affected by what kinds of other optimization are done by the compiler.
关键在于,这在架构,编译器之间变化很大,并且还受到编译器完成的其他优化的影响。 So, the choice of whether or not to store something in a register is a choice better left to the compiler and the use of the
register
modifier is usually considered an archaic antipattern. 因此,选择是否将某些内容存储在寄存器中是最好留给编译器的选择,并且使用
register
修饰符通常被认为是一种古老的反模式。
EDIT: I incorrectly remembered register
was a qualifier (which doesn't line up with the use of a type qualifier anyway, so I should have known), fixed... 编辑:我错误地记得
register
是一个限定符(无论如何都不符合使用类型限定符,所以我应该知道),修复...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.