<?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: Pointer problems in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138068#M1102</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks for your help. That worked however the first const is not required as this brings up a warning.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Nov 2006 04:08:35 GMT</pubDate>
    <dc:creator>NZ_Design</dc:creator>
    <dc:date>2006-11-29T04:08:35Z</dc:date>
    <item>
      <title>Pointer problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138066#M1100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have used the ICC compiler in the past and are changing my code over into CW.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;One line I are haveing trouble with it is one I use all the time.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have a string decleared&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;#define S_TABLANE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "LANE\0"&lt;BR /&gt;#define S_TABOUTLET&amp;nbsp;&amp;nbsp;&amp;nbsp; "OUTLET\0"&lt;BR /&gt;#define S_TABSIZE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "SIZE\0"&lt;BR /&gt;#define S_TABAVGSIZE&amp;nbsp;&amp;nbsp; "PACKS\0"&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;I then have an array that points to each of these strings.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;const char* TabName[] = {S_TABLANE,S_TABOUTLET,S_TABSIZE,S_TABAVGSIZE};&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;in my old code I accessed this by doing this&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;gputs(TabName[cTab]);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;That would display the required string this on longer is the case. The screen displays rubish and it is in a never ending loop. Never finds the end of the string.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To get round it I did a switch case statement which works&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;switch (cTab) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 0:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gputs(S_TABLANE);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 1:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gputs(S_TABOUTLET);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 2:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gputs(S_TABSIZE);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;case 3:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;gputs(S_TABAVGSIZE);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;why does CW not like my pointer array.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 06:41:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138066#M1100</guid>
      <dc:creator>NZ_Design</dc:creator>
      <dc:date>2006-11-28T06:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pointer problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138067#M1101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;This partial coded snipped you are showing looks ok, it should work with CW too.&lt;BR /&gt;Without a full compilable sample showing the problem it is impossible to say.&lt;BR /&gt;Some notes anyway:&lt;BR /&gt;&lt;PRE&gt;
&amp;gt;const char* TabName[]
&lt;/PRE&gt;&lt;BR /&gt;This is a non constant array, therefore you have to have the startup code to initialize it properly. Do you have start12.c in your project? (or start08.c, if this is for the HC08).&lt;BR /&gt;&lt;BR /&gt;Probably you should change this to:&lt;BR /&gt;&lt;PRE&gt;
const char* const TabName[]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;so it would end up in flash and not use RAM.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;
&amp;gt;#define S_TABLANE      "LANE\0"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The ANSI-C standard adds a 0 byte at the end of every string literal for you. When you add one explicitly like this, you will end up with two 0 zero bytes at the end.&lt;BR /&gt;&lt;BR /&gt;So if this does not help, the best would be to post a zip file with a complete project showing the problem. As the startup code note shows, the problem may be somewhere else than directly in the C file too.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 18:39:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138067#M1101</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2006-11-28T18:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Pointer problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138068#M1102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks for your help. That worked however the first const is not required as this brings up a warning.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 04:08:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138068#M1102</guid>
      <dc:creator>NZ_Design</dc:creator>
      <dc:date>2006-11-29T04:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pointer problems</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138069#M1103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The first const is not strictly necessary, but I would write it. It says that the string literals cannot be changed, and as the do by default end up in flash, that's just the truth....&lt;BR /&gt;&lt;BR /&gt;Warnings about different const qualifiers are often caused by missing const qualifiers, not by having too many of them, at least this is my experience with existing code and const's.&lt;BR /&gt;Does the prototype of gputs contain a const?&lt;BR /&gt;&lt;PRE&gt;
void gputs(const char*);
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Well, otherwise you would have to show the warning and the code generating it. But as it works now maybe that good enough too &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 14:46:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Pointer-problems/m-p/138069#M1103</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-11-02T14:46:13Z</dc:date>
    </item>
  </channel>
</rss>

