Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!purdue!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: A solution to the multiple inclusion problem Message-ID: <8956@goofy.megatest.UUCP> Date: 25 Oct 89 00:39:27 GMT References: <946@friar-taac.UUCP> Distribution: comp Organization: Megatest Corporation, San Jose, Ca Lines: 27 From article <946@friar-taac.UUCP), by matthew@sunpix.UUCP ( Sun Visualization Products): ) In article <15316@bloom-beacon.MIT.EDU) tada@athena.mit.edu (Michael J Zehr) writes: ))In article <14240@well.UUCP) nagle@well.UUCP (John Nagle) writes: )))[problem of multiple exclusion, generally solved by:] ))) #ifndef XXX ))) #define XXX ))) ...content... ))) #endif )))This works, but on the second inclusion, the file still has to be read and )))parsed ... I think you'll live a happier, more productive life, if you do it this way... #ifndef XXX ...content... #define XXX #endif It makes no difference where you put the #define, unless you have files which define recursive data-structures and thus potentially refer to each other. (You use "struct foo*" before "struct foo" is actually defined.) If it gets screwed up, and each file includes the other, and if the the #define is at the top, trying to figure out what went wrong can make your life a living hell.