A solution to the multiple inclusio
joe at modcomp.UUCP
joe at modcomp.UUCP
Wed Oct 25 13:34:00 AEST 1989
Lawrence Crowl writes:
> Each include file defines a symbol (preferably related to its name). For
> example, in foo.h:
> #define foo_h
> Each file that includes foo.h, protects the inclusion with a #ifndef:
> #ifndef foo_h
> #include "foo.h"
> #endif foo_h
> I have used this solution as a matter of course since shortly after I learned
> to program in C. It is an obvious solution, and leads me to wonder why it is
> not common practice. Any explainations?
Well, for one thing, it's clumsy to enter. For another, it's clumsy to
read. Finally, it places this dirt at point-of-use, rather than
point-of-definition, where it really belongs (reason: thingys defined
once; used many times). For many of us, these are sufficient reasons
to put this mechanism entirely in the include file, in spite of the
obvious (machine) inefficiencies involved.
--
joe korty "for every vengence there is an equal and
uunet!modcomp!joe opposite revengence." (from Cartoon Laws)
More information about the Comp.lang.c
mailing list