J
Jack
Thanks.
Jack said:Thanks.
Jack said:Thanks.
Michael said: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
Please don't quote signatures.Jack said:Thanks. Is a static variable stored at heap or stack?
Jack
Thanks. Is a static variable stored at heap or stack?
Jack said:Thanks. Is a static variable stored at heap or stack?
Jack said:Thanks. Is a static variable stored at heap or stack?
Jack
Jack said:Thanks. Is a static variable stored at heap or stack?
Michael said: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.
Jack said: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?
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?
Jack said: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?
Jack said: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?
Jack said: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?
A static local variable is basically a global which is only visible withinJack said: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?
Malcolm said:A static local variable is basically a global which is only visible within
one function.
That is a contradiction in terms, but it is how the compiler will treat it
under the bonnet.
No. Yes. Maybe. Not applicable. Did you even read the previousI 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?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.