home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16032 < prev    next >
Encoding:
Text File  |  1992-11-10  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!gumby!destroyer!cs.ubc.ca!mprgate.mpr.ca!walduck
  3. From: walduck@mpr.ca (Andrew Walduck)
  4. Subject: Re: Multiple Header Files Problem
  5. Message-ID: <1992Nov10.164547.19059@mprgate.mpr.ca>
  6. Sender: news@mprgate.mpr.ca
  7. Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
  8. References: <720993360snx@trmphrst.demon.co.uk> <rmartin.721359424@thor>
  9. Date: Tue, 10 Nov 92 16:45:47 GMT
  10. Lines: 30
  11.  
  12. In article <rmartin.721359424@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  13. >A more interesting variation on this issue is the problem of "circular
  14. >inclusion".  Consider a source file: "a.h" which includes "b.h".
  15. >However, "b.h" includes "a.h".  This trivial example will fail to
  16. >compile.  Unless the compiler is very clever (I haven't seen one yet),
  17. >it will sit and spin until it exhauses some resouce (usually memory),
  18. >and then it will die a horrible death.  If it prints an error at all,
  19. >the error is nearly certain to have nothing to do with the circular
  20. >containment.
  21.  
  22. Why not just wrap your headers in:
  23.  
  24. #ifndef someUniqueIdentiferPerFile_inc
  25. #define someUniqueIdentiferPerFile_inc
  26.  
  27. #include <someotherfile.h>
  28.  
  29. // grotty code goes here...
  30. #endif
  31.  
  32. It solves the problem for us...(between this and forward declarations...)
  33.  
  34.  
  35. Andrew
  36.  
  37. -- 
  38. Andrew Walduck, MPR Canada, walduck@mprgate.mpr.ca
  39. -------------------------------------------------------------------------------
  40. (I hope someone will flatter me by using this as a .sig quote...)
  41.  -- Reid Kneeland
  42.