<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Size code grows very quickly when a six elements char array is declared. in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526044#M8677</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Sat May 02 19:53:32 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;static uint8_t i = 0;
[color=#f00]static uint8_t j;[/color]
j= z&lt;I&gt;;

// ...

j = z&lt;I&gt;;
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:59:47 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:59:47Z</dc:date>
    <item>
      <title>Size code grows very quickly when a six elements char array is declared.</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526043#M8676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Sat May 02 18:42:21 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The text/data size is 5064/12 with the newer code commented :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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&lt;I&gt;;

// ...

//j = z&lt;I&gt;;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, commenting out the code that creates and uses the array, the text/data size is 17128/2132:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
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&lt;I&gt;;

// ...

j = z&lt;I&gt;;
}&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, it doesn't matter whether the char array declaration is made inside the Print() function or global (as shown).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a C++ project, with C native code, like the SysTick handler, which in turn is calling the Print() function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#ifdef __cplusplus
extern "C"
{
#endif

void SysTick_Handler(void)
{
&amp;nbsp; // ...
&amp;nbsp; 
&amp;nbsp; Print(&amp;amp;screen);

}

#ifdef __cplusplus
}
#endif&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:59:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526043#M8676</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Size code grows very quickly when a six elements char array is declared.</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526044#M8677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Sat May 02 19:53:32 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;static uint8_t i = 0;
[color=#f00]static uint8_t j;[/color]
j= z&lt;I&gt;;

// ...

j = z&lt;I&gt;;
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:59:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526044#M8677</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Size code grows very quickly when a six elements char array is declared.</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526045#M8678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Sat May 02 20:45:16 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi R2D2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, the variable 'j' needn't to be static at all 'cause its' not holding any state as 'i' is doing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although your workaround works, whenever I have some free time I'll try to find out why the code size grows insanely that big.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:59:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Size-code-grows-very-quickly-when-a-six-elements-char-array-is/m-p/526045#M8678</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:59:48Z</dc:date>
    </item>
  </channel>
</rss>

