home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- 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
- From: misar@rbg.informatik.th-darmstadt.de (walter misar)
- Subject: Re: Please help me with my #include mess-up.
- Sender: news@news.th-darmstadt.de (The News System)
- Message-ID: <1992Nov12.110150@rbg.informatik.th-darmstadt.de>
- Date: Thu, 12 Nov 1992 10:01:50 GMT
- References: <1992Nov11.172840.5540@news.ysu.edu>
- Nntp-Posting-Host: rbhp19.rbg.informatik.th-darmstadt.de
- Organization: TU Darmstadt
- Lines: 32
-
- In article <1992Nov11.172840.5540@news.ysu.edu>, ae007@yfn.ysu.edu (Daniel Newcombe) writes:
- >
- > Well here is my problem: I have these modules:
- > MOSTYPES.H - defines several types I am using in this
- > project, such as boolean, and a few structs and typedefs
- > QUEUE.H - the header file for my queue class which has a few
- > inline things in it.
- > This has to include mostypes.h because it needs boolean.
- > QUEUE.CPP - the rest of the code for the queues. It includes
- > queue.h
- > MAINMOD.CPP - my main module. It includes QUEUE.H and MOSTYPES.H.
- > When I compile I get a whole mess of errors saying that all sorts
- > of things in MOSTYPES.H are redefined. There are a lot more
- > modules that are going to have to use mostypes.h before it's
- > all over with.
- >
- > My question - how do I get this to compile, while still keeping
- > the code portable and re-usable???
-
- Hm, first of all, an ANSI-compiler shouldn't complain with an error if you
- re#define a macro with the SAME definition (different white-space doesn't count)
- , but the inlines sure will cause trouble. The easiest way looks like this:
- #ifndef MOSTYPES_H
- #define MOSTYPES_H
- ... /* defines, typedefs, prototypings .... */
- #endif
-
- This way the headers definitions will be visible only the first time.
-
- --
- Walter Misar
- misar@rbhp56.rbg.informatik.th-darmstadt.de
-