<?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: Porting problem: GNU to CW in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Porting-problem-GNU-to-CW/m-p/198774#M7422</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wade,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume that the type &lt;EM&gt;uint8&lt;/EM&gt; is defined as &lt;EM&gt;unsigned char&lt;/EM&gt;.&amp;nbsp; This should not cause a bitfield warning unless you have specifically enabled "strict ANSI" compiler option.&amp;nbsp; Have you included the device header file for the target MCU, that is present within the CW installation?&amp;nbsp; This header file also makes extensive use of bitfields of non-standard type &lt;EM&gt;unsigned char&lt;/EM&gt;, normally without warning messages being generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the device header file may also cause a conflict with your code, since here &lt;EM&gt;byte&lt;/EM&gt; is also typedef'ed as &lt;EM&gt;unsigned char,&lt;/EM&gt; and &lt;EM&gt;word&lt;/EM&gt; as &lt;EM&gt;unsigned int.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, the bit allocation sequence used by CW is the opposite of what you seem to be assuming - the LSB is allocated first.&amp;nbsp; Of course this should not matter if you are using the bitfield simply as a series of single bit flags.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With respect to the &lt;EM&gt;enum&lt;/EM&gt;, CW does define this as a signed int value, so the error message is valid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2009 22:54:07 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2009-07-14T22:54:07Z</dc:date>
    <item>
      <title>Porting problem: GNU to CW</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Porting-problem-GNU-to-CW/m-p/198773#M7421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to move a project from GNU C to Codewarrior.&lt;/P&gt;&lt;P&gt;The first sticking point came up right away in the bit-fields:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| typedef union {&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 byte;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp; struct {&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 BIT7 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;/STRONG&gt;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 BIT5 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;/STRONG&gt;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 BIT4 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;BR /&gt;&lt;/STRONG&gt;| &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; uint8 BIT2 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;/STRONG&gt;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 BIT1 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;/STRONG&gt;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint8 BIT0 : 1;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Warning: C1106 Non-Standard bitfield type&lt;/STRONG&gt;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp; }bit;&lt;BR /&gt;|}reg08;&lt;/P&gt;&lt;P&gt;|typedef union {&lt;BR /&gt;|&amp;nbsp;&amp;nbsp; uint16 word;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp; struct {&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT15 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT14 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT13 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT12 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT11 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT10 : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT9&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT8&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT7&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT6&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT5&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT4&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT3&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT2&amp;nbsp; : 1;&lt;BR /&gt;| &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; uint16 BIT1&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint16 BIT0&amp;nbsp; : 1;&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp; }bit;&lt;BR /&gt;}reg16;&lt;/P&gt;&lt;P&gt;|&lt;BR /&gt;|enum {&amp;nbsp; BIT15 = 0x8000,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&amp;lt;- Error C1014: Integral type expected or enum value&amp;nbsp; out of range&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT14 = 0x4000,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT13 = 0x2000,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT12 = 0x1000,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT11 = 0x0800,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT10 = 0x0400,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT9&amp;nbsp; = 0x0200,&lt;BR /&gt;|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BIT8&amp;nbsp; = 0x0100 };&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;.. that is, a warning each time 'uint8' is used in the enumeration, no warning when 'unit16' is used and an error when 'BIT15' is assigned a value over 32767, defined, as if it is actually a signed value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Changing the first eight to 'uint16' removes the first eight warnings, but the error has me stumped&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Wade Hassler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2009 03:20:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Porting-problem-GNU-to-CW/m-p/198773#M7421</guid>
      <dc:creator>WadeH</dc:creator>
      <dc:date>2009-07-14T03:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Porting problem: GNU to CW</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Porting-problem-GNU-to-CW/m-p/198774#M7422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wade,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume that the type &lt;EM&gt;uint8&lt;/EM&gt; is defined as &lt;EM&gt;unsigned char&lt;/EM&gt;.&amp;nbsp; This should not cause a bitfield warning unless you have specifically enabled "strict ANSI" compiler option.&amp;nbsp; Have you included the device header file for the target MCU, that is present within the CW installation?&amp;nbsp; This header file also makes extensive use of bitfields of non-standard type &lt;EM&gt;unsigned char&lt;/EM&gt;, normally without warning messages being generated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the device header file may also cause a conflict with your code, since here &lt;EM&gt;byte&lt;/EM&gt; is also typedef'ed as &lt;EM&gt;unsigned char,&lt;/EM&gt; and &lt;EM&gt;word&lt;/EM&gt; as &lt;EM&gt;unsigned int.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, the bit allocation sequence used by CW is the opposite of what you seem to be assuming - the LSB is allocated first.&amp;nbsp; Of course this should not matter if you are using the bitfield simply as a series of single bit flags.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With respect to the &lt;EM&gt;enum&lt;/EM&gt;, CW does define this as a signed int value, so the error message is valid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2009 22:54:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Porting-problem-GNU-to-CW/m-p/198774#M7422</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-07-14T22:54:07Z</dc:date>
    </item>
  </channel>
</rss>

