www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/15/17:30:07

From: dmcg6174 AT yahoo DOT com (Daniel McGrath)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with nested #include's
Date: Sun, 15 Nov 1998 23:12:38 GMT
Organization: Long Island Information, Inc.
Lines: 66
Message-ID: <364f5d7b.5753228@news.liii.com>
NNTP-Posting-Host: mcgrath.liii.com
X-Trace: cedar.liii.com 911168111 6088 204.180.230.5 (15 Nov 1998 22:15:11 GMT)
X-Complaints-To: news AT liii DOT com
NNTP-Posting-Date: 15 Nov 1998 22:15:11 GMT
X-Newsreader: Forte Free Agent 1.11/16.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Article #412057568 of Deja News:

---------------------------------------------------------------------------------------
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Subject: Re: Problem with nested #include's
Date: 15 Nov 1998 00:00:00 GMT
Message-ID: <Pine DOT SUN DOT 3 DOT 91 DOT 981115133732 DOT 1381m-100000 AT is>
X-NNTP-Posting-Host: 208.7.170.162
References: <364e0e09 DOT 936581 AT news DOT liii DOT com>
To: Daniel McGrath <dmcg6174 AT yahoo DOT com>
X-Sender: eliz AT is
Content-Type: TEXT/PLAIN; charset=US-ASCII
DJ-Gateway: from mailing list djgpp
X-Unsubscribes-To: listserv AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Trace: 15 Nov 1998 07:59:20 -0500, 208.7.170.162
Organization: None provided
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Newsgroups: comp.os.msdos.djgpp


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 <bar.h> and
<baz.h>, and add -I. to the GCC command line.
-----------------------------------------------------------------------------------------------------------

Actually, I am writing out the file names, complete with the drive
letter and the path (i.e., "#include "c:/.../bar.h" (or baz.h)).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019