Path: utzoo!attcan!uunet!husc6!ogccse!blake!uw-beaver!teknowledge-vaxc!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.c++ Subject: Re: Including header files minimally. Message-ID: <750@quintus.UUCP> Date: 26 Nov 88 06:26:37 GMT References: <3561@pt.cs.cmu.edu> <7860@nsc.nsc.com> <3614@pt.cs.cmu.edu> <559@redsox.UUCP> <867@cantuar.UUCP> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 32 In article <867@cantuar.UUCP> greg@cantuar.UUCP (G. Ewing) writes: >Instead of including the same header file several times, what's >wrong with having the header file define a macro, including it >once, and then using the macro several times? It requires that the macro processor be able to handle very large macros, which might not otherwise be required. Also, it is not possible for the two approaches to be equivalent (consider the built-in macros __FILE__ and __LINE__). >The point is that cpp could safely be hacked >to only ever include things once; anything that can be done with >multiply included files can also be done using macros. But not using the existing sources. If you don't like #include, use something else. It is bad manners to break other people's tools, without even asking them. As an example of a company with good manners, the High C compiler has a pragma which goes something like this: pragma Include(); /* or Include("file"); */ pragma C_Include(); /* or C_Include("file"); */ where C_Include includes the file only if it hasn't already been included. (This is "pragma", by the way, not "#pragma".) Note that at least in UNIX systems, it is possible to #include "/dev/tty" {This can actually be useful, if you know what you're doing.} There are other kinds of files where the contents may be different, _by design_, when you open them again.