#include what?

Hans-Peter Diettrich <DrDiettrich@compuserve.de>
25 Apr 2006 10:14:01 -0400

          From comp.compilers

Related articles
#include what? DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-04-25)
Re: #include what? rsc@swtch.com (Russ Cox) (2006-04-26)
Re: #include what? ian@airs.com (Ian Lance Taylor) (2006-04-27)
Re: #include what? cfc@shell01.TheWorld.com (Chris F Clark) (2006-04-27)
Re: #include what? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-04-28)
Re: #include what? anton@mips.complang.tuwien.ac.at (2006-04-28)
Re: #include what? cfc@shell01.TheWorld.com (Chris F Clark) (2006-04-30)
[1 later articles]
| List of all articles for this month |

From: Hans-Peter Diettrich <DrDiettrich@compuserve.de>
Newsgroups: comp.compilers
Date: 25 Apr 2006 10:14:01 -0400
Organization: Compilers Central
Keywords: C, standards, question
Posted-Date: 25 Apr 2006 10:14:01 EDT

As the subject indicates, I'm confused about the searching strategy of
the C preprocessor. The use of the search path is clear to me, but
what about additional locations, like the "current" directory, the
directory of the including file, and the parent directories? Are these
locations extensions of the standard, or does there exist an agreement
about the additional locations to be searched?

What's the "current" directory? Is it a project specific setting, or
is it related to the currently compiled file(s)? I guess that
(typically) it could be the parent directory of the Makefile?

Also, which additional locations apply to patterns like "sys/xyz.h"?
What's the directory of such an file, when it #includes further files?
Is it the .../sys/ directory, or the directory containing the sys/
Or is such a pattern applicable only to system files, i.e. as
<sys/xyz.h>, so that only the includepath is searched? What about

The more I dig into the various specs, the more I'm confused :-(

[The C standards say that the interpretation of the <filename> or
"filename" in #include is entirely up to the implementation. My
impression is that the de-facto standard on Unix systems is whatever
cccp, the GCC preprocessor, does. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.