[Courses] [C] Lesson Three: Basic Declarations & Expressions

Akkana akkana at shallowsky.com
Thu Oct 10 13:42:58 EST 2002


KWMelvin writes:
> u> On Thu, Oct 10, 2002 at 06:14:26PM +0300, Anca M. Holban wrote:
> u> #include "myheader.h"  /* contains my declarations, etc. */
> u> #include <stdio.h>     /* Standard C Library header file */

Eugene Teo writes:
> correction. always include after standard headers.

Why?

I usually do it the other way around: I include my own header first,
before standard headers.  That way, I find out whether my header file
(which ideally is meant to be portable and re-usable in other projects)
has dependencies which it doesn't satisfy.  For example, if myheader.h
refers to EOF and expects to get that from stdio.h, then it should
probably include stdio.h itself; but I could easily not notice that
problem if I included stdio.h before myheader.h, and then anyone who
ever used myheader would have to include stdio as well.  This gets
complicated when you have complicated header files that depend on
six or seven other header files (which each depend on ...) and it
can be a real pain for whoever tries to reuse your code.

	...Akkana



More information about the Courses mailing list