Recursive #includes

Daniel F. Fisher dff at Morgan.COM
Fri Mar 3 05:04:30 AEST 1989


In article <2941 at hound.UUCP> rkl1 at hound.UUCP (K.LAUX) writes:
>	I suppose, given all the discussion, that it might be best to Not Use
>Nested Includes at all.  Then the only problems (minor) would be to keep the
>MakeFile Dependencies up to date and in sync with the actual Includes in the
>source code module and to get the order of inclusion correct (in case one
>Header File needs something that appears in another Header file).
>
>--rkl

But nested includes obviate the need to know the correct order of inclusion,
which would involve MANUALLY compiling and then topologically sorting an
include file list.  This is far more tedious than simply compiling a list
of make dependencies from the transitive closure of the "source file includes
other source file" relation.  And the availability of automatic header
dependency generation even removes this tedium.  Furthermore, if one only
needs to include those header files that are directly referenced in a given
source file, allowing header files to include those headers that they need,
one need not change the list of included files in any source file unless and
until that source file otherwise changes.  Contrast this with having to add
include lines to a multitude of different source files when a shared header
file changes to require prior inclusion of another header file.  Or consider
the pain involved in transporting a program to a system with a somewhat
different set of LOW LEVEL system header files.  Personally, I'd rather deal
with nested includes.

-- 
Daniel F. Fisher
dff at morgan.com



More information about the Comp.lang.c mailing list