<?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: extern not working in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131412#M528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;bazza wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I finally stumbled on using static after seeing this used on an external variable in Datebook example.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;After appending static to every variable all the link errors dissappeared.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I also found that I could simply insert these external variables with static at the head of the same segments as the functions and it appears that in this way I don't even have to declare them as extern from the functions. Amazing and so easy.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I admit this is a C problem but there is no guide on the use of external variables using extern in either Code Warrior or Palm documents.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I am happy to use this solution for now but I notice in Datebook there are some external variables that do not use the static symbol. That is still a mystery as I still get an error if I try to do that.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please look up what you are doing here...&lt;BR /&gt;&lt;BR /&gt;By making all variables static, every file/object that includes Globals.c has a &lt;B&gt;local&lt;/B&gt; copy of that variable, and I'm pretty sure that's not what you want.&lt;BR /&gt;&lt;BR /&gt;What you want to do is:&lt;BR /&gt;&lt;BR /&gt;1. Add the file Globals.c to your project&lt;BR /&gt;2. Create a file Globals.h that references all those global variables as extern (so it contains all the extern definitions of the global variables in Globals.c&lt;BR /&gt;3. Where you now include Globals.c, you should include Globals.h instead&lt;BR /&gt;4. Link&lt;BR /&gt;5. See how it works like it should!&lt;BR /&gt;&lt;BR /&gt;And please, read up on the proper use of C, as you don't really know what you're doing.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Sep 2006 14:18:26 GMT</pubDate>
    <dc:creator>TallGuy</dc:creator>
    <dc:date>2006-09-27T14:18:26Z</dc:date>
    <item>
      <title>extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131409#M525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #000000; font-size: 3;"&gt;I am rebuilding an app from scratch after losing the source code due to my own stupidity. Thought I saved it on a cd but found that all I saved was a shortcut and since then have had to reinstall Windows.&lt;BR /&gt;I am attempting to use global variables and it is just not working.&lt;BR /&gt;I create a separate Globals.c file and put the required variables in that file then I intend to use the variables in a function from another file with extern.&lt;BR /&gt;The global vars are there OK and the app compiles but after using #include "Globals.c", I get 36 link errors like this:&lt;BR /&gt;Link Error : Action.c: Global Object 'speed' was already defined in File: 'Globals.c'. There are 36 vars.&lt;BR /&gt;If I comment out #include "Globals.c" I get a couple of hundred "undefined identifier" errors.&lt;BR /&gt;This seems a silly error as the object was not already defined in Globals.c but it was 'only' defined in Globals.c.&lt;BR /&gt;There is no other reference to Globals.c. One of the many vague and unhelpful errors thrown by Code Warrior.&lt;BR /&gt;If someone was able to have a look at the project that would be nice.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2006 18:32:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131409#M525</guid>
      <dc:creator>bazza</dc:creator>
      <dc:date>2006-09-26T18:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131410#M526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;bazza wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;I am rebuilding an app from scratch after losing the source code due to my own stupidity. Thought I saved it on a cd but found that all I saved was a shortcut and since then have had to reinstall Windows.&lt;BR /&gt;I am attempting to use global variables and it is just not working.&lt;BR /&gt;I create a separate Globals.c file and put the required variables in that file then I intend to use the variables in a function from another file with extern.&lt;BR /&gt;The global vars are there OK and the app compiles but after using #include "Globals.c", I get 36 link errors like this:&lt;BR /&gt;Link Error : Action.c: Global Object 'speed' was already defined in File: 'Globals.c'. There are 36 vars.&lt;BR /&gt;If I comment out #include "Globals.c" I get a couple of hundred "undefined identifier" errors.&lt;BR /&gt;This seems a silly error as the object was not already defined in Globals.c but it was 'only' defined in Globals.c.&lt;BR /&gt;There is no other reference to Globals.c. One of the many vague and unhelpful errors thrown by Code Warrior.&lt;BR /&gt;If someone was able to have a look at the project that would be nice.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Provided you want to do it that way, I would:&lt;BR /&gt;&lt;BR /&gt;1. Not #include Globals.c&lt;BR /&gt;2. Compile and link with Globals.c and #include the header file that defines the externs, or alternatively define your externs where you need 'em.&lt;BR /&gt;&lt;BR /&gt;That ought to fix your problem.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;&lt;BR /&gt;Bas Vermeulen&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Sep 2006 19:35:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131410#M526</guid>
      <dc:creator>TallGuy</dc:creator>
      <dc:date>2006-09-26T19:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131411#M527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I finally stumbled on using static after seeing this used on an external variable in Datebook example.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;After appending static to every variable all the link errors dissappeared.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I also found that I could simply insert these external variables with static at the head of the same segments as the functions and it appears that in this way I don't even have to declare them as extern from the functions. Amazing and so easy.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I admit this is a C problem but there is no guide on the use of external variables using extern in either Code Warrior or Palm documents.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I am happy to use this solution for now but I notice in Datebook there are some external variables that do not use the static symbol. That is still a mystery as I still get an error if I try to do that.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Sep 2006 09:06:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131411#M527</guid>
      <dc:creator>bazza</dc:creator>
      <dc:date>2006-09-27T09:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131412#M528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;bazza wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I finally stumbled on using static after seeing this used on an external variable in Datebook example.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;After appending static to every variable all the link errors dissappeared.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I also found that I could simply insert these external variables with static at the head of the same segments as the functions and it appears that in this way I don't even have to declare them as extern from the functions. Amazing and so easy.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I admit this is a C problem but there is no guide on the use of external variables using extern in either Code Warrior or Palm documents.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT color="#000000"&gt;I am happy to use this solution for now but I notice in Datebook there are some external variables that do not use the static symbol. That is still a mystery as I still get an error if I try to do that.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Please look up what you are doing here...&lt;BR /&gt;&lt;BR /&gt;By making all variables static, every file/object that includes Globals.c has a &lt;B&gt;local&lt;/B&gt; copy of that variable, and I'm pretty sure that's not what you want.&lt;BR /&gt;&lt;BR /&gt;What you want to do is:&lt;BR /&gt;&lt;BR /&gt;1. Add the file Globals.c to your project&lt;BR /&gt;2. Create a file Globals.h that references all those global variables as extern (so it contains all the extern definitions of the global variables in Globals.c&lt;BR /&gt;3. Where you now include Globals.c, you should include Globals.h instead&lt;BR /&gt;4. Link&lt;BR /&gt;5. See how it works like it should!&lt;BR /&gt;&lt;BR /&gt;And please, read up on the proper use of C, as you don't really know what you're doing.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Sep 2006 14:18:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131412#M528</guid>
      <dc:creator>TallGuy</dc:creator>
      <dc:date>2006-09-27T14:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131413#M529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The following thread may be of interest, for a discussion&amp;nbsp;about the&amp;nbsp;definition and declaration of global variables.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;message.id=1272&amp;amp;view=by_date_ascending&amp;amp;page=1" target="_blank"&gt;&lt;FONT size="1"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;message.id=1272&amp;amp;view=by_date_ascending&amp;amp;page=1" target="test_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&amp;amp;message.id=1272&amp;amp;view=by_date_ascending&amp;amp;page=1&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Sep 2006 15:14:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131413#M529</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-09-27T15:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131414#M530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks Tallguy and Bigmac for your comments. Truly I really don't know what I'm doing.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I do have a good book on ANSI C which helps but all this linking business is a bit of a mystery.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I took on board what you said and faithfully put my external variables in the correct Global files etc and still got all the link errors.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;So the next thing I did was have a closer look at the Datebook example.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I gradually transferred all my code over to the Datebook example then deleted all the files I didn't need until the Datebook example was 100% identical to my project and it compiled and ran without a hitch.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I then adjusted a few of the settings in my project to agree with Datebook but still I get the link errors, ie 36 errors in all which is the number of variables. I really don't know what else I can do, apparently nothing!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have just renamed the Datebook example and now have my external variables exactly as I want them without the static symbol so I will just carry on from there and put this mystery in the too hard bin.&lt;/FONT&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Sep 2006 16:42:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131414#M530</guid>
      <dc:creator>bazza</dc:creator>
      <dc:date>2006-09-28T16:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: extern not working</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131415#M531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;Finally solved this problem. I had twelve variables among the 36 which I was attempting to define in the process and this is what was causing all the link errors.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;The error would claim that I had already defined the variable in Globals.c which I had not. I was defining it in the file which was using it (as an extern) as I thought this was the correct method.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;I noticed the difference in the Datebook example so I then defined the culprits in Globals.c instead of in the main file and everything works.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;I still claim that the errors are really inappropriate.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT color="#000000" size="3"&gt;Many thanks for your helpful comments.&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Sep 2006 15:07:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/extern-not-working/m-p/131415#M531</guid>
      <dc:creator>bazza</dc:creator>
      <dc:date>2006-09-29T15:07:48Z</dc:date>
    </item>
  </channel>
</rss>

