Originally Posted by st_crab
My problem is with the hello_fn.c file, because it contains the definition of the hello function. So why would it ever need to include the prototype (which is like a partial definition) via hello.h?
Well, that would all depend on exactly how you had written your hello_fn.c source file.
If hello_fn.c contains multiple functions, some of which call the hello function before it is even defined in the source file, then you most certainly would need to have it in the header file and to #include the header file.
But if the hello_fn.c file does not contain functions that also depend on the hello function, then there is of course no need to have #included that function prototype. Though there was also absolutely no harm in having #include'd that function prototype.
No harm, no foul. Ne?
There are far too many picky little details to consider here.
We have this source file, hello_fn.c. It has functions in it that other source files need, so those source files absolutely need to #include the header file that contains that function's prototype. OK, that is a given.
Now we have hello_fn.c itself. Does it really need to know what's in the header file? Only if any function within it tries to reference one of the functions in the header file.
OK, so let's assume that's not the situation. What harm does it do to prototype a function that nobody references before it's defined? None whatsoever.
So just what do you think is the problem?