Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!usc!apple!hercules!fernwood!decwrl!hplabs!hpl-opus!hpnmdla!hpmwtd!jeffa From: jeffa@hpmwtd.HP.COM (Jeff Aguilera) Newsgroups: comp.lang.c++ Subject: Re: A solution to the multiple inclusion problem Message-ID: <1520005@hpmwjaa.HP.COM> Date: 27 Oct 89 18:11:58 GMT References: <14240@well.UUCP> Organization: HP Microwave Tech. - Santa Rosa, Ca. Lines: 88 Here's my approach for preventing superfluous includes, without relying on the `implementation-defined' #pragma directive, modifications to #include semantics, or an impressively intelligent compiler. A module is divided into three source files: .h [header] interface definition; inlines prohibited .m [macro] inlines; one-liners and common idioms only .c [c] C++ source Each .[hmc] file normally includes just one other file, a corresponding preprocessor file .[hmc]pp: //foo.h -- a foo gadget #include "foo.hpp" //foo.m -- a foo gadget #include "foo.mpp" //foo.c: foo.h -- a foo gadget #include "foo.cpp" These preprocessor files are generated automatically from the source by inspecting the first line, and extracting comments that look like this: //use: "foo.h bar.h" //use: The `extract .?pp' program (xpp) generates files that look like this: //foo.hpp #ifndef foo_h #define foo_h "Fri Oct 27 10:25:37 PDT 1989 foo.h" #endif //foo.mpp #ifndef _memory_h #include #ifndef _memory_h #define _memory_h #endif #endif //foo.cpp #define self (*this) #include "foo.h" #include "foo.m" #ifndef _string_h #include #ifndef _string_h #define _string_h #endif #endif #ifndef _iostream_h #include #ifndef _iostream_h #define _iostream_h #endif #endif #ifndef _X11_Xlib_h #include #ifndef _X11_Xlib_h #define _X11_Xlib_h #endif #endif #ifndef bar_h #include "bar.h" #include "bar.m" #endif Xpp also extracts comments of the form //bug: and colates the results in a correspondind `bug-bucket' file, .?bb: //foo.cbb Known bugs as of Fri Oct 27 10:31:07 PDT 1989 45: X& X::operator=(const X&) not implemented 87: should raise software assertion rather than aborting 134: EOF[3CB7] 2599 characters Xpp also forces a file naming policy, so that porting applications between UNIX and DOS is only a minor nuisance. (Case sensitivity, length, character set, extension.) Still no topological sort on include dependencies.... -------- jeff "reinventing rounder wheels" aguilera