Date: Sun, 15 Nov 1998 13:37:52 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Daniel McGrath cc: djgpp AT delorie DOT com Subject: Re: Problem with nested #include's In-Reply-To: <364e0e09.936581@news.liii.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Sat, 14 Nov 1998, Daniel McGrath wrote: > Suppose I have a source file foo.c, and in the file it says > > #include "bar.h" > > where bar.h is a header file. In this header file, bar.h, it says > > #include "baz.h" > > Now, when I run the preprocessor using "gcc" or "cpp", I will get an > error message like this: > > In file included from foo.c:LINE_NUMBER: > bar.h:LINE_NUMBER: baz.h: No such file or directory (ENOENT) > > I get this error message _even when the file baz.h actually does > exist_. In what directory does baz.h exist? Is it in the same place where bar.h resides? If it is, it should be something funny in your source (like if there's an invisible character on the line which includes "bar.h"). If baz.h is NOT in the same directory where bar.h is, then you should be aware of the following excerpt from the cpp docs, where the ``#include "foo"'' feature is described: This variant is used for header files of your own program. It searches for a file named FILE first in the current directory, then in the same directories used for system header files. The current directory is the directory of the current input file. Note the last sentence: when "bar.h" is processed, the ``directory of the current input file'' is the one where bar.h is kept, not the one where you keep the source file that included bar.h. The usual way to handle these cases is to use #include and , and add -I. to the GCC command line.