#include search paths

Henry Spencer henry at utzoo.uucp
Sun Nov 13 11:10:54 AEST 1988


In article <2899 at ingr.UUCP> crossgl at ingr.UUCP (Gordon Cross) writes:
>  1) the proposed ANSI standard says that the "filename" form "is searched for
>     in association with the original source file".  What exactly does this
>     mean?  ...

You are reading an obsolete draft.  The May draft (which is still the latest)
just says "searched for in an implementation-defined manner".  This arises
from a combination of historical differences in compilers and the problems
of describing a file system in a system-independent way.

>     ... Regarding the
>     <filename> form the standard only states that the preprocessor "searches
>     a sequence of implementation-defined places".  Well, nothing very
>     concrete here...

Again, it's difficult to be concrete in an implementation-independent way.
Note that the <foo.h> form is specifically *not* required to refer to a
*file* at all -- the headers might even be built into the compiler.

>     ... Regarding the
>     "filename" form, Harbison & Steele state that the precessor "typically
>     searches for the file first in the same directory in which the file
>     containing the #include command was found, and then perhaps in other
>     places according to implementation dependent search rules."  Well,
>     perhaps this is what the standard was referring to with the statement
>     "in association with the original source file"...

That and other variations.  Note that "in association with the original
source file", which is more or less K&R1 wording, is *NOT* the same as
"same directory in which the file containing the #include was found" --
if you nest #includes, "original source file" and "file containing
the #include" are not the same file!  Different compilers handle this
in different ways, which is one reason for X3J11 vagueness.

>     ...  Neither of the other two documents [X3J11, H&S]
>     mentioned the -I options!!  And I thought of these as being a de-facto
>     standard...

Only on Unix and Unix-like systems.  Those documents are trying to describe
*C*, not the form of options for a particular C compiler.
-- 
Sendmail is a bug,             |     Henry Spencer at U of Toronto Zoology
not a feature.                 | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list