AnsweredAssumed Answered

Initialization of arrays

Question asked by Colin Cameron on Sep 15, 2016
Latest reply on Sep 21, 2016 by Colin Cameron

I'm using CodeWarrior 10.6 for the MC56f82748 (but the question applies to anything using this compiler). 

 

In the manual it says: "Initialize local arrays and structures at declaration time, if possible. Local arrays and structures are initialized optimally by the compiler." (Section 11.5.10.3.2 Miscellaneous Techniques, in CodeWarrior Development Studio for Microcontrollers V10.x Digital Signal Controller Build Tools Reference Manual, Rev. 10.6, 02/2014). 

 

What does that mean, exactly? 

 

Or more specifically if I have an structure like: 

 

typedef struct {
   unsigned current_size;
   unsigned items[0x64];
} q_t;

volatile q_t q = {0x01, 0x01};

Will the compiler generate 202 bytes of data to initialize this (with 198 of them being zero)? Or will it generate some sort of compressed initialization code / stored data? 

 

How can I see what data is generated for the initialization and how it is used to initialize the variables. Is there any way I can control the behaviour? 

Outcomes