Automatic initialization of global variables

Taka
2007-09-27
2013-03-12
  • Taka
    Taka
    2007-09-27

    Hi,

    I'm using z80-port of SDCC version 2.7.0, which has
    a problem regarding initialization of global variables.

    From the standard C point of view,

    struct bar {
      char* str;
    };
    struct foo {
      int a;
      struct bar b;
    };
    struct foo myvar;

    the above code fragment is compiled to an output,
    which should initialize the variable "myvar" (and its
    nested members) to zero upon initialization.  SDCC,
    however, doesn't emit this type of automatic initialization code on _GSINIT area unless an initialization code is explicitly specified like:

    struct foo myvar = { 0, { 0 } };

    Is this a bug? or am I missing something?

    Takahide