<?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: Codewarrior Type Casting issue when passing &amp;quot;void *&amp;quot; from a function pointer in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257300#M6552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Charles, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding to your issue, could you please send your project to me?&lt;/P&gt;&lt;P&gt;So I can fully know what's the problem and what's your target, then, it could be effective to investigate!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Aug 2013 15:26:10 GMT</pubDate>
    <dc:creator>jorge_plascencia</dc:creator>
    <dc:date>2013-08-29T15:26:10Z</dc:date>
    <item>
      <title>Codewarrior Type Casting issue when passing "void *" from a function pointer</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257299#M6551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have this function:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;static void T_CALLBACK _transmit(&lt;/P&gt;&lt;P&gt;&amp;nbsp; void *pContext,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TX_DATA *pTxDescriptor)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; CONTEXT *pLinkContext = (CONTEXT *)pContext;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is being called via a function pointer.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void *pContext is being passed an address of 0x1558.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when it gets cast, it casts to 0x0AAC.&amp;nbsp; For obvious reasons, this causes problems because it is pointing to the wrong address in memory and I quickly get a long access misalign interrupt.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't fully understand what is going on or how to fix it, this is third party code and not something I do in coding, so while I see WHAT is going wrong (the address is shifted by 1, so it points to the wrong spot in memory), but I'm not sure WHY it is doing it and, more importantly, how I can fix it.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 18:41:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257299#M6551</guid>
      <dc:creator>Charlie</dc:creator>
      <dc:date>2013-04-08T18:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior Type Casting issue when passing "void *" from a function pointer</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257300#M6552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Charles, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding to your issue, could you please send your project to me?&lt;/P&gt;&lt;P&gt;So I can fully know what's the problem and what's your target, then, it could be effective to investigate!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 15:26:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257300#M6552</guid>
      <dc:creator>jorge_plascencia</dc:creator>
      <dc:date>2013-08-29T15:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior Type Casting issue when passing "void *" from a function pointer</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257301#M6553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Charles,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you are targeting DSCs, am I right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The DSC compiler treats the void pointers as they are pointers to bytes by default.&lt;/P&gt;&lt;P&gt;This causes shifting the address to left and right &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;back and forth according to type casting. (See more info about this feature in DSC CodeWarrior compiler manual,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;section "4.6 Code and Data Storage" and "11.5.10.3.1 The Effects of Casting on Code Quality" );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://cache.freescale.com/files/soft_dev_tools/doc/ref_manual/DSC_Compiler.pdf?fpsp=1&amp;amp;WT_TYPE=Reference%20Manuals&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=pdf&amp;amp;WT_ASSET=Documentation" title="http://cache.freescale.com/files/soft_dev_tools/doc/ref_manual/DSC_Compiler.pdf?fpsp=1&amp;amp;WT_TYPE=Reference%20Manuals&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=pdf&amp;amp;WT_ASSET=Documentation"&gt;http://cache.freescale.com/files/soft_dev_tools/doc/ref_manual/DSC_Compiler.pdf?fpsp=1&amp;amp;WT_TYPE=Reference%20Manuals&amp;amp;WT_VE…&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what is &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;CONTEXT type is on your side, but assume it's a structure or a non-char data type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;In such a case the compiler cast (shift right) the byte address (viod *) before it's assigned&amp;nbsp; *&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;pLinkContext. This is correct behavior.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;The problem probably occurs somewhere else where you are accessing *&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;pLinkContext. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Can you possibly post&amp;nbsp; body of _&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;transmit&lt;/SPAN&gt;() function including definitions of user data types involved (&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;CONTEXT&lt;/SPAN&gt;, &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;TX_DATA &lt;/SPAN&gt;...)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;This will help to find a root cause.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Stan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Sep 2013 10:14:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257301#M6553</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2013-09-10T10:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior Type Casting issue when passing "void *" from a function pointer</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257302#M6554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll review the documentation, but I am posting this while I do so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are correct, the CONTEXT is a struct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't entirely clear.&amp;nbsp; It doesn't fail ON the cast, but when I call a function passing that pointer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the rest of that function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;CONTEXT *pLinkContext = (CONTEXT *)pContext;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Initialize context */&lt;/P&gt;&lt;P&gt;&amp;nbsp; pLinkContext-&amp;gt;retryCount = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; pLinkContext-&amp;gt;pTxDescriptor = pTxDescriptor;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Call function to send variable frame */&lt;/P&gt;&lt;P&gt;&amp;nbsp; _sendVariableFrame(pLinkContext);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It goes into the misalign when it goes into _sendVariableFrame.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cheated a bit to get it to work by changing the function declaration to only accept CONTEXT * instead of void * and this solved the problem and I have not seen a problem with this yet, but the change does scare me a little bit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Sep 2013 19:01:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Codewarrior-Type-Casting-issue-when-passing-quot-void-quot-from/m-p/257302#M6554</guid>
      <dc:creator>Charlie</dc:creator>
      <dc:date>2013-09-17T19:01:25Z</dc:date>
    </item>
  </channel>
</rss>

