How do the compiler knows about the change that is made in the static variable?

R

ramu

Hello,

can anyone tell me how the c compiler remembers the changes
made to the static variable?


Regards,
ramu
 
G

Grumble

ramu said:
can anyone tell me how the c compiler remembers the changes made to
the static variable?

Like elephants, C compilers have an excellent memory. If you've invoked
UB in the past, they might forgive, but they never forget.
 
R

Richard Heathfield

ramu said:
Hello,

can anyone tell me how the c compiler remembers the changes
made to the static variable?

It doesn't. All it does is set up the conditions for that object to be
assigned memory and initialised. The object retains the memory assigned to
it for the entire duration of the program, unlike auto objects.
 
L

Logan Shaw

ramu said:
can anyone tell me how the c compiler remembers the changes
made to the static variable?

As I understand it, it is often the same way that it "remembers"
the values of global variables. The only thing that is different
is that the *name* of the storage (the variable name) has a limited
scope. So, you can think of a static variables as a hybrid between
a global variable and a local variable. It has a lifetime much like
a global variable but a scope just like a local variable.

- Logan
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top