<?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: #pragma pack(1) supported? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181285#M2779</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its been a while but I thought CW used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma options align=packed&lt;/P&gt;&lt;P&gt;#pragma options align=reset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pairs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Nov 2011 00:13:25 GMT</pubDate>
    <dc:creator>BryGuyH</dc:creator>
    <dc:date>2011-11-10T00:13:25Z</dc:date>
    <item>
      <title>#pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181284#M2778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How to tell CW compiler to pack structs?&lt;/P&gt;&lt;P&gt;#pragma pack(1) gives an "Illegal pragma" warning and does not pack variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The compiler generates dummy byte between variables:&lt;/P&gt;&lt;P&gt;typedef struct {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint_8 channel;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint_16 value;&lt;BR /&gt;}ADC_Value_t;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When communicating with other systems the struct need to be packed.&lt;/P&gt;&lt;P&gt;~Mark&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 20:57:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181284#M2778</guid>
      <dc:creator>MarkP_</dc:creator>
      <dc:date>2011-11-09T20:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: #pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181285#M2779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its been a while but I thought CW used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#pragma options align=packed&lt;/P&gt;&lt;P&gt;#pragma options align=reset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pairs?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 00:13:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181285#M2779</guid>
      <dc:creator>BryGuyH</dc:creator>
      <dc:date>2011-11-10T00:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: #pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181286#M2780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;I found out how to do two things: turn on checking for structures being padded and how to ensure the structure parameters are packed.&amp;nbsp; I haven't found out how to globally set the packing option.&lt;/P&gt;&lt;P&gt;The below #if has comments to explain.&lt;/P&gt;&lt;P align="left"&gt;#if&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;1&lt;/FONT&gt; &lt;FONT color="#3F7F5F" size="2"&gt;&lt;FONT color="#3F7F5F" size="2"&gt;//DES test for customer MarkP from forums&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;#pragma&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;warn_padding on&lt;/FONT&gt; &lt;FONT color="#3F7F5F" size="2"&gt;&lt;FONT color="#3F7F5F" size="2"&gt;//turns on warning but have to visually check if you get a warning...other settings [off | reset].&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;typedef&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#7F0055" size="2"&gt;&lt;FONT color="#7F0055" size="2"&gt;struct&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;{&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#7F0055" size="2"&gt;&lt;FONT color="#7F0055" size="2"&gt;volatile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#005032" size="2"&gt;&lt;FONT color="#005032" size="2"&gt;uint_8&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000C0" size="2"&gt;&lt;FONT color="#0000C0" size="2"&gt;channel&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#7F0055" size="2"&gt;&lt;FONT color="#7F0055" size="2"&gt;__attribute__&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;((aligned (1)));&amp;nbsp;&amp;nbsp;&amp;nbsp; //DES changing 1 to a 4 and recompile to see warning&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#7F0055" size="2"&gt;&lt;FONT color="#7F0055" size="2"&gt;volatile&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#005032" size="2"&gt;&lt;FONT color="#005032" size="2"&gt;uint_16&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000C0" size="2"&gt;&lt;FONT color="#0000C0" size="2"&gt;value&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#7F0055" size="2"&gt;&lt;FONT color="#7F0055" size="2"&gt;__attribute__&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;((aligned (1)));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //DES not really needed but if you were to add to struct handy to already have in code&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P align="left"&gt;}&lt;/P&gt;&lt;P&gt;&lt;FONT color="#005032" size="2"&gt;&lt;FONT color="#005032" size="2"&gt;ADC_Value_t&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warning in console when aligned(4):&lt;/P&gt;&lt;P align="left"&gt;(C:\Freescale\FreescaleMQX3.7\mqx\examples\adc\adc_demo.c|158|1|11|6463|11)&lt;/P&gt;&lt;P align="left"&gt;=}ADC_Value_t;&lt;/P&gt;&lt;P&gt;&amp;gt;1 pad byte(s) inserted after data member 'value'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively you could turn on the Pad Bytes Added (full) option in the ARM compiler Warnings settings and you will see a number of struct warnings about bytes being padded.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 05:05:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181286#M2780</guid>
      <dc:creator>DavidS</dc:creator>
      <dc:date>2011-11-10T05:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: #pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181287#M2781</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;&lt;FONT size="2"&gt;You can use the following approach to align the struct:&lt;BR /&gt;&lt;BR /&gt;typedef struct&lt;BR /&gt;{&amp;nbsp;&amp;nbsp;&lt;BR /&gt;unsigned long ChunkID __attribute__((aligned (4)));//4 bytes = "RIFF" 0x52494646 big-endian form&amp;nbsp;&lt;BR /&gt;unsigned long ChunkSize __attribute__((aligned (4)));//4 bytes&amp;nbsp;&lt;BR /&gt;unsigned long Format __attribute__((aligned (4))); //4 bytes = "WAVE" 0x57415645 big-endian form&amp;nbsp;&lt;BR /&gt;unsigned long Subchunk1ID __attribute__((aligned (4))); //4 bytes = "fmt"&amp;nbsp; 0x666d7420 big-endian form&amp;nbsp;&lt;BR /&gt;unsigned long Subchunk1Size __attribute__((aligned (4))); //4 bytes&amp;nbsp;&lt;BR /&gt;unsigned short AudioFormat __attribute__((aligned (2)));//2 bytes: 0 =???;&amp;nbsp; 1 = Linear quantization; Others = compression&amp;nbsp;&lt;BR /&gt;unsigned short NumChannels __attribute__((aligned (2)));//2 bytes: Mono = 1; Stereo = 2; etc.&amp;nbsp;&lt;BR /&gt;unsigned long SampleRate __attribute__((aligned (4)));//4 bytes: 8000, 44100, etc.&amp;nbsp;&lt;BR /&gt;unsigned long ByteRate __attribute__((aligned (4)));//4 bytes: SampleRate * NumChannels * BitsPerSample/8&amp;nbsp;&lt;BR /&gt;unsigned short BlockAlign __attribute__((aligned (2)));//2 bytes: NumChannels * BitsPerSample/8&amp;nbsp;&lt;BR /&gt;unsigned short BitsPerSamples __attribute__((aligned (2)));//2 bytes: 8 = 8 bits; 16 = 16 bits; etc.&amp;nbsp;&lt;BR /&gt;unsigned long Subchunk2ID __attribute__((aligned (4)));//4 bytes = "data" 0x64617461 big-endian form&amp;nbsp;&lt;BR /&gt;unsigned long Subchunk2Size __attribute__((aligned (4)));//4 bytes: NumSamples * NumChannels * BitsPerSample/8&amp;nbsp;&lt;BR /&gt;unsigned char x __attribute__((aligned (1)));&amp;nbsp;&lt;BR /&gt;// unsigned long Data;//(ChunkSize) bytes&lt;BR /&gt;} WAVE_FILE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Best Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Luis&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 05:57:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181287#M2781</guid>
      <dc:creator>LuisCasado</dc:creator>
      <dc:date>2011-11-10T05:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: #pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181288#M2782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answers.&lt;/P&gt;&lt;P&gt;There is also another potential problem, is the uint_16 variable big or little endian.&lt;/P&gt;&lt;P&gt;Is it compatible with another system?&lt;/P&gt;&lt;P&gt;Solved like this:&lt;/P&gt;&lt;P&gt;typedef struct {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint_8 channel;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint_8 valueHi;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint_8 valueLo;&lt;BR /&gt;}ADC_Value_t;&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 00:43:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181288#M2782</guid>
      <dc:creator>MarkP_</dc:creator>
      <dc:date>2011-11-11T00:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: #pragma pack(1) supported?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181289#M2783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have aligned structure members something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;struct USB_SysInfoResponse&lt;BR /&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint_16 version;// __attribute__((aligned (2)));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;uint_8&amp;nbsp; configuration __attribute__((aligned (1)));&amp;nbsp;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After doing this i can still get the size of struct as 4bytes, the result should have been 3bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To have effect fo&amp;nbsp; __attribute what needs to added in the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raghu&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 19:55:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/pragma-pack-1-supported/m-p/181289#M2783</guid>
      <dc:creator>mpc8377e</dc:creator>
      <dc:date>2012-03-19T19:55:51Z</dc:date>
    </item>
  </channel>
</rss>

