Home Segments Index Top Previous Next

678: Mainline

Now the question is, Where should you define the mode global variable? A reasonable answer is that you should put it in its own file inasmuch as speed-versus-accuracy control is a conceptual unit.

Wherever you define the mode variable, you face what seems like a paradox: You use the value of the mode variable in both the main.c file and the trades.c file, but you can define a variable in only one place, just as you can define a function in only one place. But if you define a variable in just one file, how does the C compiler learn what it needs to know about that variable while it is compiling another file that references the variable?