<?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: C99 Extensions in HCS08 and RS08 Compiler in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170075#M5165</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I recently investigated this matter through Freescale support. The only C99 feature available on HC08 compilers is the // comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How exactly would C99 make the code cleaner and more understandable? To my knowledge there are no such features in C99, though plenty of the opposite.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Feb 2011 15:44:42 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2011-02-02T15:44:42Z</dc:date>
    <item>
      <title>C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170072#M5162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know that for CF V1 we can enable C99 extensions wich I think are great for writing cleaner and more understandable code. But I cannot find the option in the Standard Settings window for a 8-Bit project, I tried enabling it with pragma (#pragma c99 on) but it makes a warining:&amp;nbsp;"Warning : C4201 : pragma c99 was not handled" Is there any way to use C99 Extensions for the CW HCS08 &amp;amp; RS08 C compiler?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2010 19:10:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170072#M5162</guid>
      <dc:creator>carloscuevas</dc:creator>
      <dc:date>2010-01-26T19:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170073#M5163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;There is currently no option to enable C99 for S08 and RS08.&lt;/P&gt;&lt;P&gt;BK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2010 20:48:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170073#M5163</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2010-01-26T20:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170074#M5164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does Codewarrior v10.0 (Eclipse based) has C99 support for S08 devices?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2011 14:42:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170074#M5164</guid>
      <dc:creator>carloscuev</dc:creator>
      <dc:date>2011-02-02T14:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170075#M5165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I recently investigated this matter through Freescale support. The only C99 feature available on HC08 compilers is the // comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How exactly would C99 make the code cleaner and more understandable? To my knowledge there are no such features in C99, though plenty of the opposite.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2011 15:44:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170075#M5165</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2011-02-02T15:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170076#M5166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//lets imagine that yopur application uses this struct:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;typedef struct&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; short startingRegister;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; char registerQuantity;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; short registerValuesBuffer[16];&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; short checksum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; short requestLength;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;} modbusRequestData_t;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//if you want to initialize only requestLength with value 0x20 and index 3 of registerValuesBuffer[] array with value 0xFF:&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;// Without C99&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;modbusRequestData_t myRequest = {0, 0, {0, 0, 0, 0xFF}, 0, 0x20 };&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//With C99&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;modbusRequestData_t myRequest = { .&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;registerValuesBuffer[3] = 0xFF,&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;requestLength = 0x20&lt;/FONT&gt; &lt;FONT face="courier new,courier"&gt;};&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;//This C99 feature is called "Designated Initializers", there are other features that help to write more undestandable code&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Feb 2011 00:04:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170076#M5166</guid>
      <dc:creator>carloscuev</dc:creator>
      <dc:date>2011-02-03T00:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170077#M5167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know of designated initializers. Personally I regard them as a pointless feature that doesn't make the code any clearer. No matter how you write initializer lists, it is not easy to read them when they get long-winded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To me, the most readable (and C90-compatible way) would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
modbusRequestData_t myRequest = {0};
myRequest.registerValuesBuffer[3] = 0xFF;
myRequest.requestLength = 0x20;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assigning each member one by one has another big advantage: if the struct is declared static or global, it doesn't rely of static initialization when every member is set in "runtime". Code that doesn't rely on static initialization is more robust and suitable for embedded systems, as you can then remove the static initialization phase from your code and get a quicker program startup (which is especially important on 8-bit MCUs). Ie you have no tight coupling between the compiler-specific way of initializing statics/globals and your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:18:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170077#M5167</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2020-10-29T09:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170078#M5168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have one concern: compiled code size. Do you know which method is more efficient ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You way of thinking is interesting, what do you think about Compound Literals, I think they are a very useful resource in C99. The way I have done lots of things in CFV1 (heavy pointer usage looking for compiled code size optimization) I can assure you my code is smaller and easier to expain to my colleagues when using them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 00:27:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170078#M5168</guid>
      <dc:creator>carloscuev</dc:creator>
      <dc:date>2011-02-04T00:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: C99 Extensions in HCS08 and RS08 Compiler</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170079#M5169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what the compiler does by default:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Allocate a segment in flash containing all init values for every static/global in your program. (Called "rodata" or some such.)&lt;/P&gt;&lt;P&gt;- Copy down these values from flash to your variables, at program startup.&lt;/P&gt;&lt;P&gt;- If you had explicitly initialized a static/global variable, ie "static int x = 5;", the value you wrote will be copied.&lt;/P&gt;&lt;P&gt;- If you didn't explicitly initialize it, the value 0 will be copied. This is required by ISO C.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The answer to your question depends on whether you have set your compiler to use the above method or not. In CW this is called "ANSI startup" or "minimal startup", which you pick when creating a new project. If you pick "ANSI", all your static/global variables will be initialized either to the init value you have written explicitly, or to zero. If you pick "minimal", the only thing the startup code will do is to set the stack pointer and then call main(). Your statics/globals will then &lt;EM&gt;not&lt;/EM&gt; become initialized, even if you explicitly did so. You would have to set them all in runtime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With ANSI startup code, you will have a for() loop sitting in flash memory, which copies down all init values from flash to RAM. The loop itself doesn't take much flash space, but consumes time at program startup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With minimal startup, you will not have this loop, but you will have to setup your variables manually instead. With program space in regard, the difference versus "ANSI" will barely be notable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;However&lt;/EM&gt;, when you do manual assignment of variables, there is a chance that the compiler will optimize the code, particularly for initializing to zero. This will reduce the flash segment of init variables. So in terms of flash memory consumption, you should avoid static/global initialization entirely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding compound literals, I find them as superfluous as designated initializers. Just another thing they just had to include in the language because other languages had similar constructs, even though "anonymous objects" are often considered poor style in those other languages, particularly for complex items such as classes/structs. They make the code cluttered up. Java is known to suffer a lot from it, I remember avoiding anonymous classes like the plauge in Java, just because they weren't readble when the code turned complex. Just look at this snippet:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
typedef struct
{
  int x;
  int y;
}Some_struct;

int func (Some_struct* arg1, int arg2);

...

// Alternative 1, compound literal:
result = func (&amp;amp;(Some_struct){1,2}, 5);

// or if you will, with designated initializers:
result = func (&amp;amp;(Some_struct){.x=1,.y=2}, 5);

// Alternative 2, explicit declaration:
Some_struct ss;
ss.x = 1;
ss.y = 2;
result = func(&amp;amp;ss, 5);&lt;/PRE&gt;&lt;P&gt;To me, alternative 2 is far more readable even for this simple struct with only 2 members. The compound literals have a non-intuitive syntax and they seem mixed up with parameter arg2, which has nothing to do with the struct. The simple truth is: the more you merge non-related operations together on the same row, the messier the code turns out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:18:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C99-Extensions-in-HCS08-and-RS08-Compiler/m-p/170079#M5169</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2020-10-29T09:18:32Z</dc:date>
    </item>
  </channel>
</rss>

