Static data initialization

All statically allocated12 variables/arrays/structures/unions can be statically initialized, as usual in C. Partial initialization of arrays or structs/unions is supported, and constant expressions in initializers are evaluated at compile time, whenever possible.

Initialization from a symbolic constant expression is supported  (eg: expressions such a (t1-t2)+1, where t1 and t2 are static arrays). In this case, symbolic expressions are generated and address calculation is done at assembly time.

When initializing an union, the type of the initializer must match the type of the first member of the union.

/* The following is supported  */
int k = 4 ;                 /* simple initialization */
float  speed = 31.4259e-1 ; /* simple initialization */
char str[] = "hi !" ;       /* array size inferred from initializer */
int array[2][3] = {{1,2,3},{4,5,6}} ; /* initialization of array of arrays */
long z[10] = {0};           /* partial initalization, missing data replaced by 0s */
void f( float ff )
{
  static char t='Z'-26 ;      /* compile-time constant folding */
  static char msg1[] = "OK" ; /* 3 elements static array */
 /* ... */
} 
int *pk = &k +1;            /* address calculation deferred to assembly stage */ 
void (*pf)( float ) = f ;   /* idem */
struct xxx a = { 1, 55 } ;  /* structure initialization */
struct xxx b = { 5 } ;      /* partial  structure initialization */



AG 2013-04-10