限制C程序中寄存器变量的最大数量 [英] Limit on maximum number of register variable in C program

查看:270
本文介绍了限制C程序中寄存器变量的最大数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

在特定硬件上的C程序中声明和初始化的寄存器变量数量是否有限制



平台?如果你定义了比

处理器更多的寄存器变量,那么C编译器如何处理它?<​​br />

问候

解决方案



< al *********** @ gmail.com>在消息中写道

news:11 ********************* @ z14g2000cwz.googlegro ups.com ...

大家好
在特定硬件平台上的C程序中声明和初始化的寄存器变量数是否有限制?


编号然而,编译器没有义务兑现其中任何一个。

如果您定义的寄存器变量数量多于
处理器有没有,C编译器如何处理它?<​​/ blockquote>


忽略寄存器大多数/所有变量的关键字

声明的方式。


使用寄存器关键字很少是非常可取的。在大多数情况下,

优化编译器

无论如何都会将变量放入寄存器中(如果可以的话)。因此

关键字''volatile'这明确地阻止了这个。


唯一一个注册的情况很方便,就是当你想要通过一个提示来编译关于优化什么的编译器。


< posted&邮寄>


register关键字只是对编译器的提示。它不会强制将一个

变量放入寄存器中。因此,对于可以声明的内容,或者b
寄存器,或者有多少变量,没有限制。编译器会简单地选择一些并且

忽略其余部分。

al *********** @ gmail.com 写道:

大家好
是否限制数量注册可以在特定硬件平台上的C程序中声明和初始化的变量?如果你定义了比
处理器更多的寄存器变量,那么C编译器如何处理?

问候




-

从电子邮件地址中删除''.nospam''以通过电子邮件回复


"蒲公英" <哒******* @ meadow.net>写道:

< al *********** @ gmail.com>在消息中写道
新闻:11 ********************* @ z14g2000cwz.googlegro ups.com ...

你好所有
是否可以在特定硬件平台上的C程序中声明和初始化的寄存器变量数量有限制?


不然。编译器没有义务尊重其中任何一个。

如果您定义的寄存器变量数量多于
处理器的数量,它是如何处理的C编译器?



忽略寄存器你声明的大多数/所有变量的关键字。




它不能完全忽略它;它仍然必须禁止(或至少

发出诊断)任何尝试获取

寄存器限定变量的地址。

-

Keith Thompson(The_Other_Keith) ks***@mib.org < ; http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。


Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform? If you define more number of register variables than the
processor has, how is it handled by the C compiler?

regards

解决方案


<al***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform?
No. However, the compiler is not obliged to honour any of them.
If you define more number of register variables than the
processor has, how is it handled by the C compiler?



By ignoring the "register" keyword for most/all of the variables you
declared that way.

Using the "register" keyword is seldomly very desirable. In most cases, an
optimizing compiler
will put variables in a register anyway (if it can, that is). Hence the
keyword ''volatile" which explicitly prevents this.

The only case where "register" is handly, is when you want to pass a hint to
the compiler about what to optimize.


<posted & mailed>

The register keyword is merely a hint to the compiler. it doesn''t force a
variable into a register. So, there''s no limit to what can be declared
register, or how many variables. The compiler will simply choose some and
ignore the rest.

al***********@gmail.com wrote:

Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform? If you define more number of register variables than the
processor has, how is it handled by the C compiler?

regards



--
Remove ''.nospam'' from e-mail address to reply by e-mail


"dandelion" <da*******@meadow.net> writes:

<al***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...

Hi All
Is there a limit on the number of register variables that can be
declared and initialized in a C program on a particular hardware
platform?



No. However, the compiler is not obliged to honour any of them.

If you define more number of register variables than the
processor has, how is it handled by the C compiler?



By ignoring the "register" keyword for most/all of the variables you
declared that way.



It can''t completely ignore it; it still has to forbid (or at least
issue a diagnostic for) any attempt to take the address of a
register-qualified variable.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


这篇关于限制C程序中寄存器变量的最大数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆