Path: utzoo!attcan!lsuc!ncrcan!hcr!stacey From: stacey@hcr.UUCP (Stacey Campbell) Newsgroups: comp.lang.c Subject: Re: Recursive #includes Keywords: recursive includes, modularity Message-ID: <5277@hcr.UUCP> Date: 2 Mar 89 21:50:02 GMT References: <570@marob.MASA.COM> Reply-To: stacey@hcrvax.UUCP (Stacey Campbell) Organization: HCR Corporation, Toronto Lines: 33 In article <570@marob.MASA.COM> samperi@marob.UUCP writes: >#ifndef H_FOO >#define H_FOO > >defines, declarations, etc. > >#endif It is almost essential on very large projects to implement a form of guarding of recursive includes. I'm currently working on a project where a typical 'crunched' cpp file is over 10000 lines and where over 100 included files are nested up to 14 levels. The guarding is implemented differently; (contents of bar.h) #ifndef FOO #include #endif (contents of foo.h) #ifndef FOO #define FOO ... #endif Yes, two sets of guards just in case someone implements a module including foo.h without checking FOO. Prechecking to see if a module has already been included saves an enormous amount of compile time and file inclusion overhead. -- Stacey Campbell, HCR Corporation, {lsuc,utzoo,utcsri}!hcr!stacey