<?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: static storage class missing in stdtypes.h in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197225#M7326</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I was referring to the latter.&amp;nbsp; The reason for a static char type... convenience.&amp;nbsp; I needed a static char for my function to work as expected.&amp;nbsp; But then it's just as easy to declare the variable as "static Byte".&amp;nbsp; &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Feb 2008 04:59:12 GMT</pubDate>
    <dc:creator>irob</dc:creator>
    <dc:date>2008-02-28T04:59:12Z</dc:date>
    <item>
      <title>static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197223#M7324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey everyone.&amp;nbsp; I've been fighting a bug in my RS232 code the last couple days and finally realized that I had a function return declared as "Byte", which is declared as unsigned char in the stdtypes.h.&amp;nbsp; My MCU is the MC9S08QG8.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This function returned two bytes in an array, but I noticed that the second byte kept getting trashed in RAM.&amp;nbsp; What I really needed was a &lt;/SPAN&gt;&lt;I&gt;static&lt;/I&gt;&lt;SPAN&gt; char so that the RAM would be reserved for that array.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm a little surprised there's not a static definition in the stdtypes header file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 04:18:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197223#M7324</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2008-02-28T04:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197224#M7325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;irob wrote:&lt;BR /&gt;I'm a little surprised there's not a static definition in the stdtypes header file.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;Are you saying that you are surpised that Byte wasn't a static unsigned char or that you are surprised that there was no type for a static [signed/unsigned] char?&amp;nbsp; Certainly you wouldn't want the first case as all locals defined as a Byte would be placed in RAM and retained.&amp;nbsp;For the second case, I don't see why&amp;nbsp;there would be a type for a static char.&amp;nbsp;&amp;nbsp;Personally I don't use the stdtypes from&amp;nbsp;CodeWarrior but use uintXX_t (C99) types.&amp;nbsp; Declaring a word on an S08 and having it use 16-bits seems to contradict the definition of a "word".&amp;nbsp;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 04:53:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197224#M7325</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-02-28T04:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197225#M7326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I was referring to the latter.&amp;nbsp; The reason for a static char type... convenience.&amp;nbsp; I needed a static char for my function to work as expected.&amp;nbsp; But then it's just as easy to declare the variable as "static Byte".&amp;nbsp; &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 04:59:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197225#M7326</guid>
      <dc:creator>irob</dc:creator>
      <dc:date>2008-02-28T04:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197226#M7327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Static is not part of the type at all, static defines how objects are allocated. Adding it to stdtypes.h is therefore not meaningful.&lt;BR /&gt;&lt;BR /&gt;It sounds like your actual problem is that the C language does not return arrays per value, arrays are implicitly returned by reference.&lt;BR /&gt;So basically arrays just behave differently than any other kind of type in the language, well C is the way it is....&lt;BR /&gt;Retuning pointers to statically allocated arrays is usually not a such good idea as it opens the door for all kinds of runtime problems. When some other code calls your function and it modifies the buffer, the original result gets invalidated, and such bugs are hard to find.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 06:10:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197226#M7327</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-02-28T06:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197227#M7328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;BTW.&lt;BR /&gt;- You can change your function to return a struct (possibly containing an array)&lt;BR /&gt;- pass the array in instead of returning it&lt;BR /&gt;- encode the two bytes in one 16 bit word and return that.&lt;BR /&gt;&lt;BR /&gt;Whatever makes sense for your case.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Feb 2008 06:13:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197227#M7328</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2008-02-28T06:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: static storage class missing in stdtypes.h</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197228#M7329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I would be bold and say that there is never a reason to return an array, or even a pointer, from a function. The need to do so usually originates from flawed logic. A pointer returned from a function can point at the following kind of variables:&lt;BR /&gt;&lt;BR /&gt;- Local variables. This is always a bug.&lt;BR /&gt;&lt;BR /&gt;- The same data as one of the parameters of the function. This is poor programming, as the same parameter will be used twice in the function, taking up unnecessary stack space when the function is called.&lt;BR /&gt;&lt;BR /&gt;- Dynamically allocated variables. Returning pointers to variables that were dynamically allocated inside the function is one of the most common causes for memory leaks in C programs. It is better to leave the allocation to the caller, or encapsulate it inside the code module.&lt;BR /&gt;&lt;BR /&gt;- Global/static variables. This is a bug in a multi-process program, as it might make the function unsafe for multiple processes. Note that a microcontroller program that is using interrupts is a kind of multi-process program. In case of static variables, this is also a flaw in the program design, as it breaks the encapsulation of private variables.&lt;BR /&gt;&lt;BR /&gt;Instead, return data through pointers in one of the function parameters&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2008 17:13:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/static-storage-class-missing-in-stdtypes-h/m-p/197228#M7329</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-03-03T17:13:51Z</dc:date>
    </item>
  </channel>
</rss>

