I was surprised to read from eric76 "In many language
implementations, variables declared statically are also stored on the stack." If
this is so, then where do the automatic variables go? In fixed storage I
suppose?
I was referring to automatic variables, not static
variables. A variable declared to be static could not reside on the stack
because during other function calls it's value would tend to be overwritten and
so it would not be able to retain its value.
The confusion comes about
because it is not uncommon to refer to variables that are allocated statically
vs those that are allocated dynamically. It is more common, I think, to refer
to arrays as either being allocated statically vs dynamically, but it would be
applicable to variables as well. I was thinking about the allocation of regular
variables, not about variables declared to be static.
Sorry about the
confusion. I should have been clearer about that. I wasn't even thinking about
variables that were declared as static -- it's probably been ten years since the
last time I used one in C. [ Reply to This | Parent | # ]
|