I have a real strange & frustrating experience here:
While trying to iron out another problem, i suddenly got a lot of undefined references to a number of variables and structures i had declared (say myvar is one of them) as extern in my gui-protos.h file.
I deleted them there and added them to gui.c where i have my main() function.
The problem did not disappear. I tried at different places with regard to my includes to no avail. I then just put the declaration as well in gui-protos.h
and gui.c and now got understandable errors pointing me to the last redefined variable.
I also had an error of 'myvar undeclared' in main where myvar was the first one used in main (myvar = 0; )
Stripping them from gui.c brings me back to the previous situation: lots of undefined references.
What can i have done to get into this situation ? How can i detect it??
I'm not sure if it's the situation you've got but variables can be declared as extern any amount of times but have to be non-extern once. I use a trick that I got from a Paul Overaa book years ago and have something like this in a header file, globals.h, say.
Then any file can include this header to get the variables as extern references and in just one file have ALLOCATE_GLOBALS prior to including "globals.h" e.g.
All the other modules can simply just include globals.h to get their extern references.
Hope this helps
billy
@billyfish.
Thanks. You pointed me in the right direction and made me look more closely to the use of extern variables.
The author of the source i am working on seems to have followed the guidelines described here
http://stackoverflow.com/questions/1433204/what-are-extern-variables-in-c
so i'll continue using these.