Suppose also that I need to use both stdio.h and stdlib.h in this program.
I am used to put only a call to MyHeader.h on both main.c and functions.c, and then put calls for stdio.h and stdlib.h on MyHeader.h (this seems to me the most logic and not-redundant solution).
But, I have seen some very experienced programmers put no header calls at all on MyHeader.h, and then put them as needed on main.c and functions.c, so in this example MyHeader.h would have no calls, main.c would call stdio.h and MyHeader.h, and functions.c would call stdio.h, stdlib.h and MyHeader.h (making stdio.h called twice).
So which is the best/recommended way to call headers (if there is one)?
First of all.. What do you mean by "call headers" ?
If you mean putting code that has function calls(..or any other sort) , in the header; you've got it wrong.
Consider this example:
X.h
Code:
//Guard if needed
void foo(void);
X.c
Code:
#include "X.h"
void foo(void)
{
//Do whatever you like
}
main.c
Code:
#include "X.h"
int main(void)
{
foo();
return 0;
}
Now try to explain your question w.r.t that..
[Edit: Sorry..just saw the last post...
@envec83: If you asked about the guards, look at Tater's explanation]