home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16403 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.9 KB  |  45 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!news.th-darmstadt.de!rbg.informatik.th-darmstadt.de!misar
  3. From: misar@rbg.informatik.th-darmstadt.de (walter misar)
  4. Subject: Re: Please help me with my #include mess-up.
  5. Sender: news@news.th-darmstadt.de (The News System)
  6. Message-ID: <1992Nov12.110150@rbg.informatik.th-darmstadt.de>
  7. Date: Thu, 12 Nov 1992 10:01:50 GMT
  8. References:  <1992Nov11.172840.5540@news.ysu.edu>
  9. Nntp-Posting-Host: rbhp19.rbg.informatik.th-darmstadt.de
  10. Organization: TU Darmstadt
  11. Lines: 32
  12.  
  13. In article <1992Nov11.172840.5540@news.ysu.edu>, ae007@yfn.ysu.edu (Daniel Newcombe) writes:
  14. > Well here is my problem:  I have these modules:
  15. >   MOSTYPES.H - defines several types I am using in this
  16. >     project, such as boolean, and a few structs and typedefs
  17. > QUEUE.H - the header file for my queue class which has a few
  18. >    inline things in it.
  19. >    This has to include mostypes.h because it needs boolean.
  20. > QUEUE.CPP - the rest of the code for the queues.  It includes
  21. >   queue.h
  22. > MAINMOD.CPP - my main module.  It includes QUEUE.H and MOSTYPES.H.
  23. > When I compile I get a whole mess of errors saying that all sorts
  24. > of things in MOSTYPES.H are redefined.  There are a lot more        
  25. > modules that are going to have to use mostypes.h before it's   
  26. > all over with.
  27. > My question - how do I get this to compile, while still keeping
  28. > the code portable and re-usable???
  29.  
  30. Hm, first of all, an ANSI-compiler shouldn't complain with an error if you
  31. re#define a macro with the SAME definition (different white-space doesn't count)
  32. , but the inlines sure will cause trouble. The easiest way looks like this:
  33. #ifndef MOSTYPES_H
  34. #define MOSTYPES_H
  35. ... /* defines, typedefs, prototypings .... */
  36. #endif
  37.  
  38. This way the headers definitions will be visible only the first time.
  39.  
  40. -- 
  41. Walter Misar
  42. misar@rbhp56.rbg.informatik.th-darmstadt.de
  43.