Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > How do the compiler knows about the change that is made in the static variable?

Reply
Thread Tools

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

 
 
ramu
Guest
Posts: n/a
 
      01-13-2006
Hello,

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


Regards,
ramu

 
Reply With Quote
 
 
 
 
Grumble
Guest
Posts: n/a
 
      01-13-2006
ramu wrote:
> 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.
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      01-13-2006
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.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
 
Reply With Quote
 
Logan Shaw
Guest
Posts: n/a
 
      01-13-2006
ramu wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
difference between change IP with Yast and change it with Static route in Linux z.s.n Software 0 08-21-2011 06:08 AM
difference between change IP with Yast and change it with Static route in Linux z.s.n General Computer Support 0 08-21-2011 06:07 AM
Rebel XT, made in Japan, made in Thailand jazu Digital Photography 10 12-12-2006 05:11 AM



Advertisments