Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!bionet!apple!bloom-beacon!tut.cis.ohio-state.edu!osu-cis!att!pegasus!hansen From: hansen@pegasus.ATT.COM (Tony L. Hansen) Newsgroups: comp.lang.c++ Subject: Re: Managing C++ Libraries: Dependencies and Headers Summary: another method Keywords: header files, multiple includes, nmake, cpp Message-ID: <3222@pegasus.ATT.COM> Date: 8 Nov 88 18:30:46 GMT References: <5078@thorin.cs.unc.edu> <7573@nsc.nsc.com> Reply-To: hansen@pegasus.UUCP (XT1554000-Tony L. Hansen;LZ 3B-315;3207) Organization: AT&T Bell Laboratories, Lincroft, NJ Lines: 31 < >7. A program written using our management system should read only the < > header files that are necessary and should read them only once. < < OK. So how about a slightly more intelligent pre-processor which would < (a) keep a list of all files included so far, and (b) avoid including < files which have already been included once (even if they are called for < again via further #include's)? This would have the same effect as the < encapsulation of header files within #ifdef's (which many people are using < now). < ... < The only problem is that this approach is *not* compatible with certain < tricky uses of header files (i.e. those cases when a given header file < *must* actually be included more than once for some reason). Maybe this < is a good thing. Such "tricky" uses of header files are probably not < compatible with "good software engineering practices". The 4th generation make system, nmake, comes with an enhanced version of the C preprocessor which does what you suggest with a major modification: A header file will not be #included twice unless it is re-#included from the same level as previously. In other words, if both a.c and b.h #include , and a.c #includes as well, will be #included only once. However, if a.c should #include twice, it will actually get #included twice. This takes care of almost all cases where you don't want files #included more than once, plus it still allows header files which do tricky things to be #included more than once if need be. Tony Hansen att!pegasus!hansen, attmail!tony