help-make
[Top][All Lists]
Advanced

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

Re: how to manage an unmanageable recursive make structure?


From: Noel Yap
Subject: Re: how to manage an unmanageable recursive make structure?
Date: Tue, 11 Jan 2005 11:52:18 -0500
User-agent: Mozilla Thunderbird 0.5 (Windows/20040212)

Robert P. J. Day wrote:

On Tue, 11 Jan 2005, Alessandro Vesely wrote:

but, as i read the gcc man page, using

  #include "aeou.h"

will *always* search the current directory first, regardless of what
you add with "-I".  it's my understanding that additional directories
you supply with "-I" will be searched after the current dir, but
before the standard system dirs.

is that not correct?

It depends ... on what you mean by "current directory".

Technically speaking, the C++ standard says that the behaviour of #include "" 
is implementation-dependent.  Practically speaking, IME, all compilers provide the same 
behaviour -- search first in the directory of the includer.

Try it out:

// foo/bar.h
#include "baz.h"

#warning __FILE__

// foo/baz.h
#warning __FILE__

// bar/baz.c

#include "baz.h"
#include <foo/bar.h>

// bar/baz.h
#warning __FILE__


Then build from the directory bar with foo's parent directory in the include 
path.  Here's what I get:

yapn:address@hidden:~/aoeu/bar> gmake baz CPPFLAGS="-I$HOME/aoeu"
cc  -I/ms/user/y/yapn/aoeu   baz.c   -o baz
In file included from baz.c:1:
baz.h:1:2: warning: #warning __FILE__
In file included from /ms/user/y/yapn/aoeu/foo/bar.h:1,
                 from baz.c:3:
/ms/user/y/yapn/aoeu/foo/baz.h:1:2: warning: #warning __FILE__
In file included from baz.c:3:
/ms/user/y/yapn/aoeu/foo/bar.h:3:2: warning: #warning __FILE__


Noel




reply via email to

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