存储的静态变量在哪里? [英] Where is a static variable stored?

查看:106
本文介绍了存储的静态变量在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢。

解决方案

" Jack" < ju ****** @ gmail.comwrites:


谢谢。



请将问题放在文章正文中。并非所有

新闻阅读器都会显示主题和主体。


主题是:存储静态变量在哪里?。


答案:在记忆中。在程序的整个生命周期中,静态存储持续时间的变量必须为
。 C标准

并不需要任何特定的方法来实现这一点,并且不同的编译器可以采用不同的方式来实现它。


如果你想知道一些特定的编译器是如何做到这一点的,那么你需要查看编译器的文档或询问

编译器特定的编译器或者系统特定的新闻组 - 但是你写的任何代码依赖于这些信息将是不可移植的,并且可能是不必要的。
$ br />
-

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

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

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


Jack schrieb:


谢谢。



欢迎您。


请在留言文中写下/重复您的问题 - 那里
是新闻阅读器,它们不会同时显示主题和消息文本




你的问题:静态变量在哪里存储"?;没有

标准C答案。

具有静态存储持续时间的变量live整个

计划的一生。无论它们是存储在RAM,ROM还是寄存器中的全部或仅部分时间,它们都没有指定 - 它们只需要表现得好像它们在那里整个时间。


这可能不是你想要问的答案;请

准确的问题。

干杯

Michael

-

电子邮件:我的是/ at / gmx / dot / de地址。




Michael Mair写道:
< blockquote class =post_quotes>
Jack schrieb:


谢谢。



欢迎您。


请在留言文中写下/重复您的问题 - 那里
是新闻阅读器,它们不会同时显示主题和消息文本




你的问题:静态变量在哪里存储"?;没有

标准C答案。

具有静态存储持续时间的变量live整个

计划的一生。无论它们是存储在RAM,ROM还是寄存器中的全部或仅部分时间,它们都没有指定 - 它们只需要表现得好像它们在那里整个时间。


这可能不是你想要问的答案;请

准确的问题。


干杯

Michael

-

电子邮件:我的是/ at / gmx / dot / de地址。



谢谢。是一个存储在堆或堆栈的静态变量吗?


Jack


Thanks.

解决方案

"Jack" <ju******@gmail.comwrites:

Thanks.

Please put the question in the body of your article. Not all
newsreaders display the subject along with the body.

The subject was: "Where is a static variable stored?".

The answer: In memory. A variable of static storage duration must be
available throughout the lifetime of the program. The C standard
doesn''t require any specific method of making this happen, and
different compilers can do it differently.

If you want to know how some particular compiler does this, you''ll
need to consult your compiler''s documentation or ask in a
compiler-specific or system-specific newsgroup -- but any code you
write that depends on this information will be non-portable, and
probably needlessly so.

--
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.


Jack schrieb:

Thanks.

You''re welcome.

Please write/repeat your question in the message text -- there
are newsreaders which do not show subject and message text at
the same time.

Your question: "Where is a static variable stored?" has no
standard C answer.
Variables with static storage duration "live" throughout the
programme''s lifetime. Whether they are stored all or only part
of the time in RAM, ROM, or registers is not specified -- they
have only to behave as if they were there the whole time.

This may not be the answer to what you _wanted_ to ask; please
be precise in your questions.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.



Michael Mair wrote:

Jack schrieb:

Thanks.


You''re welcome.

Please write/repeat your question in the message text -- there
are newsreaders which do not show subject and message text at
the same time.

Your question: "Where is a static variable stored?" has no
standard C answer.
Variables with static storage duration "live" throughout the
programme''s lifetime. Whether they are stored all or only part
of the time in RAM, ROM, or registers is not specified -- they
have only to behave as if they were there the whole time.

This may not be the answer to what you _wanted_ to ask; please
be precise in your questions.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.

Thanks. Is a static variable stored at heap or stack?

Jack


这篇关于存储的静态变量在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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