This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
problem with initialization of global variable & objects
- From: Pascal Degryze <pascal dot degryze at traficon dot com>
- To: "'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 29 Aug 2002 11:01:13 +0200
- Subject: problem with initialization of global variable & objects
Hi,
I am a new user of gcc-tools.
I've bought the GNU X-tools from Microcross for ARM-9 core.
It contains gcc version 2.95.2 / ld version 2.9.5.
I've encountered 2 problems:
1) initialization of global variables at runtime doesn work, so for this
example:
unsigned long LongVar = 123; // initialization doesn't happen
main()
{
LongVar ++; /* LongVar will not be 124, but dummy */
}
LongVar will have a dummy value. The initialisation must happen in main() to
work properly:
main()
{
unsigned long LongVar = 123;
LongVar ++; /* LongVar will not be 124, but dummy */
}
2) For a global defined object, the constructor is not called at runtime.
Creating an object must happen in a function.
What is the reason for all this initialisation problems?
Thanks.