Why don't nested #include's start at the source directory?

Henry Spencer henry at utzoo.uucp
Wed Dec 13 04:20:09 AEST 1989


In article <49549 at bbn.COM> jgrace at BBN.COM (Joe Grace) writes:
>Is this behavior generally broken or am I missing something?

The problem is that K&R1 was not entirely explicit about how things happened
when #includes got nested.  Some compilers look for #include "..." in the
directory of the first source file, some look for it in the directory of
the current source file.  (ANSI C just says that it is implementation-defined,
with a strong hint in the Rationale that first-source-file behavior is
preferred.)  The only portable way to deal with the situation, insofar as
there is one, is to use #include <...> and -I to get the rules you want.
-- 
1755 EST, Dec 14, 1972:  human |     Henry Spencer at U of Toronto Zoology
exploration of space terminates| uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list