473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

Hello,

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

Jan 13 '06 #1
3 1251
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.
Jan 13 '06 #2
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)
Jan 13 '06 #3
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
Jan 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Marijn | last post by:
I'd like to know how compilers usually handle static variables that are declared inside a function (as opposed to static class-members). Like in: int counter(){ static int c=0; ++c; return c;...
2
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the...
3
by: Dave | last post by:
Hi everyone, Is it possible, using an Attribute or by some other means, to notify the C# Compiler to serialize all static field's that have initializers before code in an explicit static...
1
by: Varadha | last post by:
Hi, I am declaring a variable static char Version_No = '1' in header file header.h In a application "app.exe", i am changing the value of the variable in to '2' In the same application i am...
9
by: Mark Walsh | last post by:
The following is an explanation of a bug that exists in the VB.NET compiler. I've tried to report it to Microsoft, but they've made it so difficult I've given up: MSDN help states that variables...
6
by: Mark Walsh | last post by:
The following is an explanation of a bug that exists in the VB.NET compiler. I've tried to report it to Microsoft, but they've made it so difficult I've given up: MSDN help states that variables...
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
0
by: erik.erikson | last post by:
I am getting a compiler error that I can't well explain or even understand the origin of (though I boiled it down close...). Below is a bare-bones example. What I am doing is defining the...
49
by: valentin tihomirov | last post by:
fDeleted = false; uint jobId; foreach (Struct struct in structures) { if (struct.type == JOB) { jobId = struct.id; if (struct.dataType == STATUS) fDeteted = (struct.data & STATUS_DELETED) !=...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.