Topic : Simple question...

Forum : Ride IDE

Original Post
Post Information Post
January 17, 2009 - 9:06pm
Guest

Hi,

If I declare a (external global) variable at the top of my sourcefile like shown below and execute vMyFunc() what will happen, something good or something bad?
In other words, are global declared variables initialized?
Thanks
Henk

unsigned int iMyInt=0x35;

void vMyFunc(void){
if(iMyInt==0x35){
//do something good
}
else{
//do something bad
}
}

Replies
Post Information Post
+1
0
-1
January 19, 2009 - 1:47pm
Guest

Hi

The result will be "do something good".
Data initialisation is done, when you start the debug you can open the memory view, there you search for "iMyInt" and you should see its value.

Please note that in this case you use in your function iMyInt so the variable can not be optimized, this is the reason why you can see it the memory view.

Matloub