home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16551 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.3 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!swrinde!emory!sol.ctr.columbia.edu!caen!uwm.edu!linac!att!cbnewsc!cbfsb!cbnewsg.cb.att.com!nh
  3. From: nh@cbnewsg.cb.att.com (nicholas.hounsome)
  4. Subject: Idempotent header file proposal
  5. Message-ID: <1992Nov19.090742.23696@cbfsb.cb.att.com>
  6. Sender: news@cbfsb.cb.att.com
  7. Organization: AT&T
  8. Date: Thu, 19 Nov 1992 09:07:42 GMT
  9. Lines: 31
  10.  
  11. One problem with C++ is that when used properly it requires huge
  12. numbers of header files most of which are included multiple times.
  13. Of course I know that there is the crude workaround :
  14.  
  15. #ifndef HEADER_H
  16. #define HEADER_H
  17.  
  18. stuff
  19.  
  20. #endif
  21.  
  22. But the preprocessor still has to find, open , and read the whole file
  23. so it does not realy gain you any efficiency.
  24.  
  25. The best available soloution is:
  26.  
  27. #ifndef HEADER_H
  28. #include "header.h"
  29. #endif
  30.  
  31. but this is clumsy. 
  32.  
  33. Can we not have a standard pragma to say that a header file is idempotent
  34. (A long word  I discovered that means that it only need be included once).
  35. eg. put #pragma IDEMPOTENT in the header and have the preprocessor
  36. understand that it need not bother reading this file again it seems
  37. very easy to implement provided only that you use an ANSI preprocessor
  38. and it requires no language extension since it is only a convention
  39. which the preprocessor can ignore if it does not understand it.
  40.  
  41. Nick Hounsome
  42.