lpcware

Size code grows very quickly when a six elements char array is declared.

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by fjrg76 on Sat May 02 18:42:21 MST 2015
Hi

I faced this problem: The code I'm working on is 5064 bytes in text, and 12 bytes in data. However, when I declare a simple char array the text size grows to 17128, and data grows to 2132.

The text/data size is 5064/12 with the newer code commented :


const uint8_t ROWS_PER_CHAR = 7;
// ...

//static const uint8_t z[ROWS_PER_CHAR] = {6, 0, 1, 2, 3, 4, 5};

void Print(Dots_Type * screen)
{
static uint8_t i = 0;
//static uint8_t j = z;

// ...

//j = z;
}


Now, commenting out the code that creates and uses the array, the text/data size is 17128/2132:


const uint8_t ROWS_PER_CHAR = 7;
// ...

static const uint8_t z[ROWS_PER_CHAR] = {6, 0, 1, 2, 3, 4, 5};

void Print(Dots_Type * screen)
{
static uint8_t i = 0;
static uint8_t j = z;

// ...

j = z;
}


BTW, it doesn't matter whether the char array declaration is made inside the Print() function or global (as shown).

This is a C++ project, with C native code, like the SysTick handler, which in turn is calling the Print() function:

#ifdef __cplusplus
extern "C"
{
#endif

void SysTick_Handler(void)
{
  // ...
 
  Print(&screen);

}

#ifdef __cplusplus
}
#endif


Any ideas what is this happening? I can change the code inside Print() so not to use the array, but that would be an ugly workaround.

Thank you!

Outcomes