Thanks Tallguy and Bigmac for your comments. Truly I really don't know what I'm doing.
I do have a good book on ANSI C which helps but all this linking business is a bit of a mystery.
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.
So the next thing I did was have a closer look at the Datebook example.
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.
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!
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.
I finally stumbled on using static after seeing this used on an external variable in Datebook example.
After appending static to every variable all the link errors dissappeared.
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.
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.
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.
bazza wrote:I finally stumbled on using static after seeing this used on an external variable in Datebook example.
After appending static to every variable all the link errors dissappeared.
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.
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.
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.
bazza wrote: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.
I am attempting to use global variables and it is just not working.
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.
The global vars are there OK and the app compiles but after using #include "Globals.c", I get 36 link errors like this:
Link Error : Action.c: Global Object 'speed' was already defined in File: 'Globals.c'. There are 36 vars.
If I comment out #include "Globals.c" I get a couple of hundred "undefined identifier" errors.
This seems a silly error as the object was not already defined in Globals.c but it was 'only' defined in Globals.c.
There is no other reference to Globals.c. One of the many vague and unhelpful errors thrown by Code Warrior.
If someone was able to have a look at the project that would be nice.