source for included included files

Henry Spencer henry at utzoo.uucp
Sun Sep 10 10:57:45 AEST 1989


In article <14172 at bloom-beacon.MIT.EDU> scs at adam.pika.mit.edu (Steve Summit) writes:
>... 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.

One reason why it isn't universally known is that it's not universally true.

>... The ANSI
>standard says, according to K&R II (sec. A12.4), that "a control
>line of the form
>
>	#include "filename"
>
>searches first in association with the original source file (a
>deliberately implementation-dependent phrase)" ...

Beware, this is one respect in which K&R2 is outdated.  The Oct 88 draft,
more or less definitive, just says "searches in an implementation-defined
manner".  This is an area where implementations differ, partly because
the two major oracles -- K&R1 and the Unix cpp -- disagree.
-- 
V7 /bin/mail source: 554 lines.|     Henry Spencer at U of Toronto Zoology
1989 X.400 specs: 2200+ pages. | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list