home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!gumby!destroyer!cs.ubc.ca!mprgate.mpr.ca!walduck
- From: walduck@mpr.ca (Andrew Walduck)
- Subject: Re: Multiple Header Files Problem
- Message-ID: <1992Nov11.051135.4561@mprgate.mpr.ca>
- Sender: news@mprgate.mpr.ca
- Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
- References: <rmartin.721359424@thor> <1992Nov10.104447.12882@us-es.sel.de> <rmartin.721442494@thor>
- Date: Wed, 11 Nov 92 05:11:35 GMT
- Lines: 38
-
- In article <rmartin.721442494@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
- >reindorf@us-es.sel.de (Charles Reindorf) writes:
- >
- >|In article <rmartin.721359424@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
- >However, using the #ifndef convention does not solve all the problems
- >related to inclusion, nor obviate the need to make judicious use of
- >forward declarations. #ifndef, while it *does* keep the contents of a
- >header file from being compiled more than once, does not keep the
- >header file from being *read* more than once. Thus, if care is not
- >taken, compile times can grow quite long.
-
- That too is easily fixed...
-
- ---(in a .h) ---
-
- #ifndef Tsomething_inc
- #define Tsomething_inc
-
- // include file for something that a TSomething needs...
- #ifndef TAnotherSomething_inc
- #include <TAnotherSomething.h>
- #endif
-
- #endif
-
- Voila...header files are now no longer included more than once...
-
- Andrew Walduck
-
-
-
-
-
- --
- Andrew Walduck, MPR Canada, walduck@mprgate.mpr.ca
- -------------------------------------------------------------------------------
- (I hope someone will flatter me by using this as a .sig quote...)
- -- Reid Kneeland
-