[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why not #include "config.h"?
From: |
Steffen Dettmer |
Subject: |
Re: why not #include "config.h"? |
Date: |
Tue, 22 Sep 2009 17:06:41 +0200 |
On Tue, Sep 22, 2009 at 3:02 PM, Patrick Welche <address@hidden> wrote:
> On Tue, Sep 22, 2009 at 10:49:58AM +0200, Steffen Dettmer wrote:
>> I've read here that someone could (should?) write
>> #include <config.h>
>> specifying a system header instead of the IMHO correct
>> #include "config.h"
>
> I think this is the relevant part of the autoconf info file:
> 4.9 Configuration Header Files
> ==============================
yeah, I knew this text (actually google did :)), but thought it
would be some mistake?
> ...
> To provide for VPATH builds, remember to pass the C compiler a `-I.'
> option (or `-I..'; whichever directory contains `config.h'). Even if
> you use `#include "config.h"', the preprocessor searches only the
> directory of the currently read file, i.e., the source directory, not
> the build directory.
>
> With the appropriate `-I' option, you can use `#include <config.h>'.
> Actually, it's a good habit to use it, because in the rare case when
> the source directory contains another `config.h', the build directory
> should be searched first.
I though this was a kind of lazyness; just used "" and <>
interchangingly without deeper meaning?
I tought correct is:
- with -I (and gcc), #include "config.h" is correct and works
- with -I (and gcc), #include <config.h> is not correct but works
anyway, because gcc searches system headers in user directories
if it was not found in system directories
- if #include <config.h> is really desired, I think for gcc it
would be correct to use -isystem $(top_builddir)
- for other compilers, -I often is -I but -isystem can be -j
- other compilers may not distinguish that much or that flexible
or not configurable where <file.h> is searched
- on other compilers, #include <config.h> may not even work
(when they use a fixed system directory and support no fallback
search to user directories)
Could * please correct my assumptions?
oki,
Steffen
Re: why not #include "config.h"?, Thomas Dickey, 2009/09/22