[Top][All Lists]

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

Re: why not #include "config.h"?

From: Thomas Dickey
Subject: Re: why not #include "config.h"?
Date: Tue, 22 Sep 2009 16:50:30 -0400 (EDT)

On Tue, 22 Sep 2009, Patrick Welche wrote:

On Tue, Sep 22, 2009 at 10:49:58AM +0200, Steffen Dettmer wrote:
I hope I don't ask a FAQ. If so, an URL would be appreciated.

I've read here that someone could (should?) write
  #include <config.h>
specifying a system header instead of the IMHO correct
  #include "config.h"
4.9 Configuration Header Files
  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.

It doesn't mention the fact that the choice of starting directory for a nested include using quotes depends upon the compiler (the C standard leaves this as implementation-defined). Given the source, it's understandable that it only provides a comment specific to gcc - however, that's the actual reason for preferring bracketed includes.

Thomas E. Dickey

reply via email to

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