Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!scs From: scs@athena.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: #include search paths Message-ID: <7995@bloom-beacon.MIT.EDU> Date: 16 Nov 88 05:23:28 GMT References: <1866@loral.UUCP> <2899@ingr.UUCP> <1988Nov13.011054.23413@utzoo.uucp> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 46 In article <1988Nov13.011054.23413@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: [A completely correct discussion of the #include path problem noting that] >Different compilers handle this >in different ways, which is one reason for X3J11 vagueness. [and concluding that the "usual rules" are true] >Only on Unix and Unix-like systems. [H&S, ANSI] are trying to describe >*C*, not the form of options for a particular C compiler. I would like to point out that the "usual rules" have proved to be convenient and powerful, so implementors should be encouraged to emulate them if possible. To reiterate, the double quoted form searches in 1. the directory of the source file doing the #include 2. places listed on command line (-I) 3. "standard" places (/usr/include) while the angle bracket form searches only places 2 and 3. Even if the specifics vary (the syntax of the command-line flag for rule 2, or the precise location(s) for rule 3), the general pattern can usually be maintained. Maintaining the pattern makes it easier to port large programs which have made judicious use of the possibilities inherent on the "usual rules." (I labor under no miscomprehensions as to how much variation is already out there, and how much a large program may consequently have to be modified during porting.) In particular, it is nice to be able to port a large piece of software by changing only the Makefile, not every #include line in every source file. Compiler implementers should keep "make"-like utilities firmly in mind, making sure that both macro #definition (-D) and #include path additions (-I) can be performed from the command line. For example, the VMS C compiler (VAX11C) allows the #include search path to be modified using logical names, but not on the compiler invocation line, making Makefiles considerably harder to write. Make sure, also, that both the quote form and the angle bracket form can make use of a search path (it's okay if it's the same path). The ability to have either form search for a header file not in the #includer's directory is useful. Steve Summit scs@adam.pika.mit.edu