This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]