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: <1992Nov10.164547.19059@mprgate.mpr.ca>
- Sender: news@mprgate.mpr.ca
- Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
- References: <720993360snx@trmphrst.demon.co.uk> <rmartin.721359424@thor>
- Date: Tue, 10 Nov 92 16:45:47 GMT
- Lines: 30
-
- In article <rmartin.721359424@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
- >A more interesting variation on this issue is the problem of "circular
- >inclusion". Consider a source file: "a.h" which includes "b.h".
- >However, "b.h" includes "a.h". This trivial example will fail to
- >compile. Unless the compiler is very clever (I haven't seen one yet),
- >it will sit and spin until it exhauses some resouce (usually memory),
- >and then it will die a horrible death. If it prints an error at all,
- >the error is nearly certain to have nothing to do with the circular
- >containment.
-
- Why not just wrap your headers in:
-
- #ifndef someUniqueIdentiferPerFile_inc
- #define someUniqueIdentiferPerFile_inc
-
- #include <someotherfile.h>
-
- // grotty code goes here...
- #endif
-
- It solves the problem for us...(between this and forward declarations...)
-
-
- Andrew
-
- --
- Andrew Walduck, MPR Canada, walduck@mprgate.mpr.ca
- -------------------------------------------------------------------------------
- (I hope someone will flatter me by using this as a .sig quote...)
- -- Reid Kneeland
-