<?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: HowTo force packing data structure with size less than 4 bytes? in CodeWarrior for StarCore</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205703#M320</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This forum is dedicated to CodeWarrior for StarCore.&lt;/P&gt;&lt;P&gt;If you have a question on CodeWarrior for Coldfire, please post it under the appropriate forum.&lt;/P&gt;&lt;P&gt;You will not get any answer to a coldfire question in a post dedicated to StarCore development tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jan 2012 16:52:53 GMT</pubDate>
    <dc:creator>CrasyCat</dc:creator>
    <dc:date>2012-01-03T16:52:53Z</dc:date>
    <item>
      <title>HowTo force packing data structure with size less than 4 bytes?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205700#M317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm working on MSC8156 CW 10.1.x.&lt;/P&gt;&lt;P&gt;I would like to define data structure that contains 16 bit field. By default it occupies 4 bytes in the memory. How do I force this structure to occupy its actual size, 16 bits?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Jun 2010 19:42:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205700#M317</guid>
      <dc:creator>ITCO</dc:creator>
      <dc:date>2010-06-07T19:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: HowTo force packing data structure with size less than 4 bytes?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205701#M318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use __attribute__ packed for that in the compiler.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;typedef struct&amp;nbsp; __attribute__((packed, aligned(2))) m {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned short m0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;&amp;nbsp; m1;&lt;/P&gt;&lt;P&gt;} m_struct ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;m_struct m_var;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will remove padding between the field in the structure and will ensure each field is aligned to a 2 bytes boundary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this notation if you change your structure to typedef struct&amp;nbsp; __attribute__((packed, aligned(2))) m {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char&amp;nbsp; m0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;&amp;nbsp; m1;&lt;/P&gt;&lt;P&gt;} m_struct ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be 1 byte padding between m0 and m1 and the structure size will be 6 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you do not want any padding between the fields, you can use __attribute__ ((packed)) alone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the notation&lt;/P&gt;&lt;P&gt;typedef struct&amp;nbsp; __attribute__((packed)) m {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char&amp;nbsp; m0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int&amp;nbsp;&amp;nbsp; m1;&lt;/P&gt;&lt;P&gt;} m_struct ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There will be no padding between m0 and m1 and the size of the structure will be 5 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jun 2010 14:10:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205701#M318</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2010-06-08T14:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: HowTo force packing data structure with size less than 4 bytes?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205702#M319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CrazyCat, I'm trying to accomplish the same thing, but am getting an error in CW 10.1 with MCU MCF51CN128.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied and pasted the same struct:&lt;/P&gt;&lt;PRE&gt;typedef struct  __attribute__((packed)) m {    unsigned char  m0;    unsigned int   m1;} m_struct ;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Here is the error I'm seeing:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"illegal or unsupported __attribute__"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Dec 2011 00:37:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205702#M319</guid>
      <dc:creator>ignisuti</dc:creator>
      <dc:date>2011-12-29T00:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: HowTo force packing data structure with size less than 4 bytes?</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205703#M320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This forum is dedicated to CodeWarrior for StarCore.&lt;/P&gt;&lt;P&gt;If you have a question on CodeWarrior for Coldfire, please post it under the appropriate forum.&lt;/P&gt;&lt;P&gt;You will not get any answer to a coldfire question in a post dedicated to StarCore development tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your understanding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 16:52:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-StarCore/HowTo-force-packing-data-structure-with-size-less-than-4-bytes/m-p/205703#M320</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2012-01-03T16:52:53Z</dc:date>
    </item>
  </channel>
</rss>

