#: 16920 S12/OS9/68000 (OSK)
04-Nov-92 08:32:18
Sb: #16913-#C help
Fm: Bill Dickhaus 70325,523
To: LARRY OLSON 72227,3467 (X)
Larry,
First of all, the extern definition tells the compiler that the variable is
defined elsewhere, and references to it will be resolved by the linker. So in
your example, define the two variables as extern in the source file TEST_2.
Note that if these variables are anything but int's, you must define them as
such, even when they are int's I usually define them anyway, something like
"extern int Window_path". The same two variables must be defined in TEST_1 as
global variables, the easiest way to do this is to place them outside any
function definition, I usually put them at the top after any #include's. If the
functions within TEST_2 do not modify these variables, its better form to pass
them as function arguments, rather than using extern.
To compile TEST_1 one and TEST_2, and link them use the commands:
cc test1.c -r=
cc test2.c -r=
cc test1.r test2.r -f=/dd/cmds/test
Compiling two modules by hand is easy, but if you get into more complex
situations, you will probably want to learn something about make. And if you
don't already have cc, its in LIB3 (cc.ar), it makes it all so much easier and
faster.
-Bill-
There is 1 Reply.
|