home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16077 < prev    next >
Encoding:
Text File  |  1992-11-10  |  1.6 KB  |  50 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: <1992Nov11.051135.4561@mprgate.mpr.ca>
  6. Sender: news@mprgate.mpr.ca
  7. Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
  8. References: <rmartin.721359424@thor> <1992Nov10.104447.12882@us-es.sel.de> <rmartin.721442494@thor>
  9. Date: Wed, 11 Nov 92 05:11:35 GMT
  10. Lines: 38
  11.  
  12. In article <rmartin.721442494@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  13. >reindorf@us-es.sel.de (Charles Reindorf) writes:
  14. >
  15. >|In article <rmartin.721359424@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
  16. >However, using the #ifndef convention does not solve all the problems
  17. >related to inclusion, nor obviate the need to make judicious use of
  18. >forward declarations.  #ifndef, while it *does* keep the contents of a
  19. >header file from being compiled more than once, does not keep the
  20. >header file from being *read* more than once.  Thus, if care is not
  21. >taken, compile times can grow quite long.
  22.  
  23. That too is easily fixed...
  24.  
  25. ---(in a .h) ---
  26.  
  27. #ifndef Tsomething_inc
  28. #define Tsomething_inc
  29.  
  30. // include file for something that a TSomething needs...
  31. #ifndef TAnotherSomething_inc
  32. #include <TAnotherSomething.h>
  33. #endif
  34.  
  35. #endif
  36.  
  37. Voila...header files are now no longer included more than once...
  38.  
  39. Andrew Walduck
  40.  
  41.  
  42.  
  43.  
  44.  
  45. -- 
  46. Andrew Walduck, MPR Canada, walduck@mprgate.mpr.ca
  47. -------------------------------------------------------------------------------
  48. (I hope someone will flatter me by using this as a .sig quote...)
  49.  -- Reid Kneeland
  50.