Boost logo

Boost :

Subject: Re: [boost] Mixed use of "include" directives with quoted vs. angle-bracketed params, causing havoc
From: Jonathan Franklin (franklin.jonathan_at_[hidden])
Date: 2008-09-07 23:10:36


On Sun, Sep 7, 2008 at 6:55 PM, Michael Fawcett
<michael.fawcett_at_[hidden]>wrote:

> On Sun, Sep 7, 2008 at 2:21 PM, Rene Rivera <grafikrobot_at_[hidden]> wrote:
> > That would be because AFAIK all Boost headers start with "boost/..." and
> > don't reference local includes. But moving to preferring ("") will likely
> > encourage library authors to rely on what is essentially non-portable
> > compiler behavior. The use of (<>) includes is technically also
> non-portable
> > but is currently universally portable or can be made that way.
>
> So it sounds like libraries should prefer <>, and the only time ""
> should be used is in project specific headers (i.e. won't be reused).
> But then often times project specific code ends up being generalized
> into a library at a later date, at which point it should be <>, so
> shouldn't you just always use <> then?

I only use "" in source (.cpp) files for including headers that live in the
same directory, in which case I don't qualify the filename w/ a directory
prefix. I basically use <> for everything else, qualified w/ the top-most
directory prefix (e.g. #include <boost/.../foo.hpp>).

Using the directory-qualified includes is especially important in library
headers so that the compiler is happy when building the library itself, as
well as when building against the library. However, I find that always
including in this fashion, even in stand-alone executables, makes it easier
to move code into a library later.

Using <> by default works well for me because I like to use -I to control
include order. I like to specify a single -I for the library, and dont want
the CPP to search the current directory first, which is what one of the
compilers that I use will do if I use "".

And perhaps I'm also a bit superstitious. ;-)

Jon


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk