Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!aplcen!ginosko!uunet!zephyr.ens.tek.com!tektronix!psueea!parsely!bucket!servio!penneyj From: penneyj@servio.UUCP (D. Jason Penney) Newsgroups: comp.lang.c Subject: Re: source for included included files Summary: Double-Quote #include's: Stay Away? Message-ID: <249@servio.UUCP> Date: 10 Sep 89 19:39:35 GMT References: <9275@cbnews.ATT.COM> <14172@bloom-beacon.MIT.EDU> Reply-To: penneyj@servio.UUCP (D. Jason Penney) Organization: Servio Logic Development Corp.; Beaverton, OR Lines: 55 In article <14172@bloom-beacon.MIT.EDU> scs@adam.pika.mit.edu (Steve Summit) writes: > >Yes. It is a not-universally-known and possibly surprising fact >that #include with double quotes searches in the directory of the >file doing the #including, not (necessarily) in the current >directory from which the compiler was invoked. > We also have a large programming project written in C. One objective in the design of our programming methodology was to allow a programmer to check out any set of source files (including .h files) and then do a "local make", building a variant of the system against standard source in the "product directory". For instance, one person may wish to make substantial changes to the compiler subsystem while another person may be testing user interfaces. Clearly the first person doesn't want to test with a broken interface and the second doesn't need a broken compiler. If we have the following include layout: /**************************/ /* a.h */ typedef long OopType; /**************************/ /* b.h */ #include "a.h" OopType aGlobalVar; /**************************/ /* x.c */ #include "b.h" aGlobalVar = 10; /**************************/ and then, if the user checks out b.h into his local directory and then compiles x.c in the product directory, the WRONG version of b.h will be included in the resulting compilation! Our programming methodology takes Steve Summit's approach one step further: we NEVER use includes with double-quotes. We ALWAYS use angle-bracket includes and specify the search path appropriately in the compile step. Some veteran C programmers have been astonished by this, but I think this is yet again another example where "programming in the large" requires a different approach than programming in the small. So here is a philosophical question, to which I would appreciate REPLIES and not FOLLOWUPs: what is the use of double-quote includes? I have followed corporate programming style in my own small programs, and I have yet seen a situation where the double-quote includes were strictly necessary. -- D. Jason Penney Ph: (503) 629-8383 Beaverton, OR 97006 uucp: ...uunet!servio!penneyj STANDARD DISCLAIMER: Should I or my opinions be caught or killed, the company will disavow any knowledge of my actions...