<p>Say I have a C program which is broken to a set of *.c and *.h files. If code from one file uses functions from another file, where should I include the header file? Inside the *.c file that used the function, or inside the header of that file?</p>

<p>E.g. file <code>foo.c</code> includes <code>foo.h</code>, which contains all declarations for <code>foo.c</code>; same for <code>bar.c</code> and <code>bar.h</code>. Function <code>foo1()</code> inside <code>foo.c</code> calls <code>bar1()</code>, which is declared in <code>bar.h</code> and defined in <code>bar.c</code>. Now the question is, should I include <code>bar.h</code> inside <code>foo.h</code>, or inside <code>foo.c</code>?</p>

<p>What would be a good set of rules-of-thumb for such issues?</p>

I include the most minimal set of headers possible in the
```
.h
```
file, and include the rest in the
```
.c
```
file. This has the benefit of sometimes reducing compilation times. Given your example, if
```
foo.h
```
doesn't really need
```
bar.h
```
but includes it anyway, and some other file includes
```
foo.h
```
, then that file will be recompiled if
```
bar.h
```
changes, even though it may not actually need or use
```
bar.h
```
.