C
Christopher
Looking for some clarity on the when where and how values are stored
and looked up
Hardcoded values
example: std::cout << "test";
"test" is stored at compile time as a sequence of values in the
assembly along with instructions of the program and looked up during
execution by memory location relative to some offset
Variables on the stack
example:
void foo()
{
int x;
...
x=10;
}
space for x is set aside at compile time along with the instructions
for foo. The value in that space could be anything until it is
initialized. When the value of x changes a new value is retrieved
during execution and assigned to that space set aside for x.
Globals
undefined???
Statics
undefined???
Order of initialization of globals and statics is undefined, but they
are guarenteed to be initialized before non-globals and non-statics.
The initialization occurs at runtime before normal execution begins
Is this all correct? Anyone want to elaborate or correct?
I've got problems dealing with order of initialization causing
unexpected behavior, and want to make sure my assumptions are all
correct before trying to refactor.
and looked up
Hardcoded values
example: std::cout << "test";
"test" is stored at compile time as a sequence of values in the
assembly along with instructions of the program and looked up during
execution by memory location relative to some offset
Variables on the stack
example:
void foo()
{
int x;
...
x=10;
}
space for x is set aside at compile time along with the instructions
for foo. The value in that space could be anything until it is
initialized. When the value of x changes a new value is retrieved
during execution and assigned to that space set aside for x.
Globals
undefined???
Statics
undefined???
Order of initialization of globals and statics is undefined, but they
are guarenteed to be initialized before non-globals and non-statics.
The initialization occurs at runtime before normal execution begins
Is this all correct? Anyone want to elaborate or correct?
I've got problems dealing with order of initialization causing
unexpected behavior, and want to make sure my assumptions are all
correct before trying to refactor.