global static problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

global static problem



Hello,

We are porting an existing application for Symbian UIQ, and we use the
Codesourcery G++ for this. During this development we realised that if we
declare a global variable with the static keyword then something will go
wrong with this variable. For example:

int IntData = 1;
static int StaticIntData = 2;

int main(int argc, char *argv[])
{
   printf("&IntData: %08x", &IntData);
   printf ("IntData: %d", IntData);
   printf ("&StaticIntData: %08x", &StaticIntData);
   printf ("StaticIntData: %d", StaticIntData);

   return 0;
}


This code will generate the following output:

&IntData: 00400000
IntData: 1
&StaticIntData: f4cac004
StaticIntData: -442515452

While the IntData is correct the StaticIntData seem to be corrupted.
Actually its address should be 0x00400004 instead of f4cac004.
Did anyone faced with the same problem? It appeared with the latest
release (4.2.3)
of the arm-none-symbianelf-g++.


Best Regards,
Gabor Posz
Developer