#: 17949 S12/OS9/68000 (OSK)
20-Apr-93 22:54:24
Sb: #17944-#C_error_help
Fm: Bob van der Poel 76510,2203
To: Graham Trott 100115,1075 (X)
This business of breaking up programs is probably more art than science. One
can build some nice safety nets by declaring functions as static...that way
stuff in other files can't find them.
I might as well add in my method of declaring global variables in a common
h file. In the file containing main() I do a
#define MAIN
Then in the .h file (which is included in all the files) I have:
#ifndef MAIN
#define GLOBAL extern
#else
#define GLOBAL
#endif
To declare/define a variable I just do:
GLOBAL char foo;
This will define foo in main.c; and declare it in the other files.
Hope this helps someone.
There is 1 Reply.
|