i wrote a rather large program which's source i'm now trying to organise a bit cleaner. since this is the first time i use *.c files for code and *.h for prototypes, i'm having a bit of trouble with gcc...
i need global variables (stored in "defs.h") for the .c file with main and three others. if i have all these c-files include defs.h, gcc complains about multiple declarations of those variables, otherwise it says they're undeclared.
my defs.h file looks like:
int x, y, z, blah...;
the c file with main() in it includes "main.h". "main.c" includes defs.h, too, and reads user input into those variables. functions from two other .c modules are then called, that use these variables (as does main())- they both include "defs.h", too. if i remove the include from any of these files, i get that "undeclared variable" error.
to make it short: how can i just use globals for multiple .c modules?
any help very appreciated