Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2306) config.h for all files
Home

[Freeciv-Dev] (PR#2306) config.h for all files

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2306) config.h for all files
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 11 Nov 2002 12:31:42 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Attached is a patch to bring #include <config.h> to every source file.

In addition to the arguments below, there are some practical reasons why 
this is needed.  Currently config.h #defines 'const', which is used all 
over the place.  If it changes the definition, right now this will 
result in changes in only some places, lots of warnings, and (if the 
definition is necessary) compilation failure.

jason

Jason Dorje Short wrote:
> Currently <config.h> is #included only by files "that need it".  This 
> means when config.h is changed, only those files will be recompiled. 
> DEBUG and NDEBUG are not defined within config.h; they are command-line 
> compilation parameters.  This means that when you toggle them you will 
> have to force recompilation with a "make clean" or some such (very bad, 
> IMO).  But it also means that <config.h> is "needed" in many fewer files 
> and thus when a small change is made to it only some recompilation is 
> needed.
> 
> Additionally, the question of where config.h is "needed" is tricky.  I 
> think currently it's just been put in where it seems appropriate.  But 
> with the large number of #definitions in the file it is difficult to 
> determine whether this is correct.  A missing inclusion can break things 
> - sometimes they will be easy to catch (in compilation) and some times 
> they will cause things to go subtly wrong because the right thing is not 
> defined.
> 
> (An example of when something can go subtly wrong is when a platform has 
> a broken (or nonstandard) function that is conditionally redefined 
> somewhere in the header files.  But if a .c file doesn't include 
> config.h, then the original function will be used.  Compilation will go 
> fine, and any error will only show up in runtime and will be very hard 
> to trace.)
> 
> In my opinion, config.h should be included from every .c file.  This 
> will make recompilation take somewhat (2x) longer after config.h is 
> changed, but will cut down on bugs.  It also makes it much easier to add 
> new things to config.h without having to search to see where they are 
> needed.
> 
> Some background reading:
> 
> In which Gaute contemplates the same idea:
> http://lists.complete.org/freeciv-dev@xxxxxxxxxxx/2000/09/msg00314.html.gz
> 
> In which the pros and cons of #include <config.h> are considered:
> http://lists.complete.org/freeciv-dev@xxxxxxxxxxx/1999/06/msg00266.html.gz
> 
> In which a missing #include <config.h> gives problems:
> http://lists.complete.org/freeciv-dev@xxxxxxxxxxx/1998/11/msg00216.html.gz


Attachment: config.h.diff.gz
Description: config.h.diff.gz


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