Re: [pcre-dev] More Windows-related/misc. tweaks

Startseite
Nachricht löschen
Autor: Daniel Richard G.
Datum:  
To: pcre-dev
Betreff: Re: [pcre-dev] More Windows-related/misc. tweaks
Hi Philip,

On Mon, 2007 Jul 30 10:23:33 +0100, Philip Hazel wrote:
>
> I don't understand
>
> #ifdef HAVE_CONFIG_H
> # include <config.h>
> #endif
>
> Three issues: (1) I think it should be "config.h" and not <config.h>
> because it's a local header file, not a system header file. (2) What's
> with the ifdef? Isn't config.h always present? (3) Why have you moved it
> into many individual sources rather than left it in pcre_internal.h
> which all of them include?


(1) It is indeed a local file, but remember that the behavior is slightly 
    different for #include<> versus #include"". More on this in a moment.


(2) Not necessarily. The autotools configuration can easily be tweaked to 
    pass all the preprocessor symbols as -Dfoo=bar directives on the 
    compiler command line instead. Not that we would do that, but in cases 
    where PCRE is being built using an alternative build system, it's 
    helpful to have the flexibility of using a config header or not.


(3) This way, it's much easier to ensure that all the files are 
    consistently/correctly #including config.h. What about those files that 
    don't #include pcre_internal.h? Or that don't #include it as the first 
    file? You have to do a lot more mental gymnastics in such cases to 
    ensure that config.h is the first non-comment bit that the preprocessor 
    sees.


Points #1 and #3 are addressed in the Autoconf manual. From

    http://www.gnu.org/software/autoconf/manual/html_node/Configuration-Headers.html
:


    The package should `#include' the configuration header file before 
    any other header files, to prevent inconsistencies in declarations 
    (for example, if it redefines const).


    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.



--Daniel


-- 
NAME   = Daniel Richard G.       ##  Remember, skunks       _\|/_  meef?
EMAIL1 = skunk@???        ##  don't smell bad---    (/o|o\) /
EMAIL2 = skunk@???      ##  it's the people who   < (^),>
WWW    = http://www.******.org/  ##  annoy them that do!    /   \
--
(****** = site not yet online)