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

Re: global static problem



Hi,
We made some more experimenting, and we
unfortunatelly realised that it is the same with the local static variables
too:

int main(int argc, char *argv[])
{
   static int StaticIntData = 5;

   printf ("&StaticIntData: %08x", &StaticIntData);
   printf ("StaticIntData: %d", StaticIntData);

   return 0;
}

It really makes impossible the porting :(

Best Regards,
Gabor Posz
Developer


2008/4/21, Gabor POSZ <uiqporting@xxxxxxxxx>:
>
> 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
>
>