Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] Re: (PR#11248) connection.h and spaceship.h should require
Home

[Freeciv-Dev] Re: (PR#11248) connection.h and spaceship.h should require

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: fbriere@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#11248) connection.h and spaceship.h should require config.h
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Nov 2004 21:57:02 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11248 >

Frédéric Brière wrote:
> On Mon, Nov 29, 2004 at 07:58:20AM -0800, Jason Short wrote:
> 
>>The rule is that every .c file should include config.h *before* 
>>including any other .h files.
> 
> 
> Out of curiosity, why can't the .h files include it themselves, instead
> of printing an error message?  I'm sure there's a good reason, but I
> can't imagine what it is.

Well, every piece of code should have config.h included before it.  This 
is needed for all sorts of macros, from DEBUG to HAVE_STDBOOL.  Putting 
the #include at the start of every .c file accomplishes this.  Putting 
it at the start of the .h files that "need" it risks error because 
you're sure to miss some, and you'll probably hide errors because it 
will *usually* (but not always) get included anyway.

>>Don't include <config.h> in your .h files as that can hide errors.  But 
> 
> Unfortunately, I have no other choice, as some of my .cpp files are
> auto-generated.

Can't you auto-generate the #include <config.h> part as well?

-jason





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