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

Discussion in 'C Programming' started by ramu, Jan 13, 2006.

  1. ramu

    ramu Guest

    Hello,

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


    Regards,
    ramu
     
    ramu, Jan 13, 2006
    #1
    1. Advertising

  2. ramu

    Grumble Guest

    Re: How do the compiler knows about the change that is made in thestatic variable?

    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.
     
    Grumble, Jan 13, 2006
    #2
    1. Advertising

  3. 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)
     
    Richard Heathfield, Jan 13, 2006
    #3
  4. ramu

    Logan Shaw Guest

    Re: How do the compiler knows about the change that is made in thestatic variable?

    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
     
    Logan Shaw, Jan 13, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil
    Replies:
    0
    Views:
    342
  2. Neil
    Replies:
    2
    Views:
    596
  3. misiek
    Replies:
    7
    Views:
    6,848
    misiek
    Feb 28, 2006
  4. Christian Tismer

    Made a huge change to Stackless. Please test!

    Christian Tismer, Jan 6, 2004, in forum: Python
    Replies:
    0
    Views:
    264
    Christian Tismer
    Jan 6, 2004
  5. Helge Stenström
    Replies:
    4
    Views:
    293
    Helge Stenström
    Mar 17, 2010
Loading...

Share This Page