Kinda surprised it compiled in an earlier version to begin with.
at any rate, most .c files tends to have a .h file, the .h file tends to include:
type definitions
prototypes of functions i.e. void somefunc(int a);
extern declarations of global variables that are used in other .c files
constants/enums
this is the stuff other compilation units need to know to get things ready for the linker.
each .c file will then include the .h's of any other compilation unit that it needs to access parts of.
you place these in a .h file so that they only have to exist in one place and because other .c files need to know about them. If you only have two .c files you might just put the extern into that .c file but by the time you have a whole mess of .c files it's far more convenient to be able to just include the collection of .h files you need in each .c than to try to remember all the different externs and function prototypes you call from each individual file.
so in this case
sourceA.c:
Code: Select all
#include "sourceA.h"
int myGlobalInt;
...
sourceA.h:
sourceB.c:
You can of course instead just create one master .c file that includes all other files turning the project into a single compilation unit.