Question about "#line"

Henry Spencer henry at zoo.toronto.edu
Fri Oct 19 02:51:43 AEST 1990


In article <656176474 at romeo.cs.duke.edu> drh at duke.cs.duke.edu (D. Richard Hipp) writes:
>   #line 40 "../another_dir/xyzzy.c"
>   #include "incl.h"
>
>After some experimentation, I've determined that GCC is trying to include
>the file named "../another_dir/incl.h", not "./incl.h" as I want...
>... PCC does not exhibit this behavior ...
>Which one is correct?  GCC or PCC.  The PCC version makes the most sense
>(to me) but I don't know what ANSI says...

ANSI says that the #include search procedure is implementation-defined.
Sigh.  (Bear in mind that ANSI C has no notion of "directory" at all.)

The GCC approach would seem closer to the intent of the standard.  By
the looks of it, #line changes PCC's error messages but does not affect
PCC's idea of where the file "really is" for #include search purposes.
ANSI C just says that #line "changes the presumed name of the source
file".  In the absence of further qualification, I'd interpret that as
changing it for all purposes, not just some.
-- 
"...the i860 is a wonderful source     | Henry Spencer at U of Toronto Zoology
of thesis topics."    --Preston Briggs |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list