|
Please listen to nnxion. Header files are designed to convey information to multiple source files (by including them in more than one source file). Consequently, if they have definitions, one will get multiple definitions. Header files are pasted into the source file at the point of inclusion. There is nothing to be gained by having a header used in just one source file, except organizational divisibility. When the compiler sees it, the header and the source will be one thing.
To divide your source, put it in multiple files. Things that need to be known to more than one source file are declared an a header (or more than one header). That header is then included in each source file that needs the declarations. The compiler is converting statements to machine code. It isn't running the program. I needs to know what variables and functions look like, it doesn't need to use them.
At the end of a compilation or set of compilations one will have object files which need to refer to each other, usually. The linker links them together. At that point, things must actually exist somewhere, rather than just be prototyped.
|