automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Include paths: no "-I." please


From: Stepan Kasal
Subject: Re: Include paths: no "-I." please
Date: Thu, 30 Jun 2005 16:31:43 +0200
User-agent: Mutt/1.4.1i

Hi,

On Wed, Jun 29, 2005 at 06:07:35PM -0700, overbored wrote:
> How do I tell automake not to pass "-I." to g++/gcc? Thanks in advance.

I don't know.

> (The problem is that this project has a string.h, which conflicts with 
> the standard string.h. Besides, why "-I." in the first place? Is it 
> because some people prefer #include <blah> over #include "blah" for 
> their own header files as well?)

My guess: in short, -I. ensures uniformity between the "inplace builds"
(srcdir = builddir) and "VPATH builds" (srcdir != builddir).

As we all know, when cpp processes #include "xx.h", it searched first
the "current directory", and then the system directories.  The problem
here is that "current directory" here means the directory of the currently
processed file, so it's the srcdir, not builddir!

Imagine the following situation:

foo.c contains #include "gen.h" .
foo.c is distributed while gen.h is generated.
When you do a VPATH build, the file gen.h is searched in the same directory
where foo.c is, that is in the sorce tree.  But it's not there and the
compiler won't search the build directory.  Thus the build directory has to
be given with -I.

Most of the projects use a config.h file, and most of them have it in the
same directory with some *.c files.  These projects _need_ -I. at least in
that directory, no matter whether they use #include <config.h> or "config.h".
Would you consider reasonable to ask people to add -I. manually in this
situation?

So at least in some directories, -I. is mandatory.  I guess it's easiest to
add it to all makefiles.

Hope this helps,
        Stepan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]