Re: Where is a static variable stored?
- From: roberson@xxxxxxxxxxxxxxxxxx (Walter Roberson)
- Date: Sat, 15 Jul 2006 03:27:02 +0000 (UTC)
In article <1152901674.865652.57980@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Jack <junw2000@xxxxxxxxx> wrote:
I think for a static variable defined out of any functions, i.e., it is
a global variable, it is located in the data segment of the program.
How about a static variable defined within a function? it is a local
variable. Is it located at the stack?
And if the other more detailed answers are not sufficiently clear
to you:
NO. I have never encountered an implementation that stored
a static variable in the stack. Doing so would not be impossible
(provided the implementation has a stack at all), but it is enough
extra work to be unlikely to be the chosen mechanism; such an
implementation would, for example, have the side effect of being
unable to build dynamically loadable libraries.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
.
- References:
- Where is a static variable stored?
- From: Jack
- Re: Where is a static variable stored?
- From: Michael Mair
- Re: Where is a static variable stored?
- From: Jack
- Where is a static variable stored?
- Prev by Date: Re: good C compiler
- Next by Date: Re: Convert Int Value To Pointer
- Previous by thread: Re: Where is a static variable stored?
- Next by thread: Re: Where is a static variable stored?
- Index(es):
Relevant Pages
|