source for included included files

D. Jason Penney penneyj at servio.UUCP
Mon Sep 11 05:39:35 AEST 1989


In article <14172 at bloom-beacon.MIT.EDU> scs at 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...



More information about the Comp.lang.c mailing list