Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: warnings when compiling with NDEBUG (PR#1216)
Home

[Freeciv-Dev] Re: warnings when compiling with NDEBUG (PR#1216)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: warnings when compiling with NDEBUG (PR#1216)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Feb 2002 17:08:20 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Feb 05, 2002 at 04:26:35PM +0100, Reinier Post wrote:
> On Mon, Feb 04, 2002 at 08:13:38PM -0500, Jason Short wrote:
> 
> [...]
> 
> > >>>>NDEBUG disables assert which should make freeciv faster. I'm not sure
> > >>>>how much. So I don't see the benefit of removing it.
> > >>>>
> > >>>The name is confusing (it appears to mean !DEBUG).
> > >>>
> > >>  Not much we can do about that, as (according to the assert 
> > >>manpage) NDEBUG is defined to have this assert-disabling behaviour in the 
> > >>ANSI C spec.
> > > 
> > > Thanks.  I didn't even know NDEBUG is standard ANSI C (see
> > > 
> > >   http://www.lysator.liu.se/c/rat/d2.html
> > > 
> > > ) now I wonder if anything is assumed about DEBUG in ANSI C.
> > > Searching for that, I found
> > > 
> > >   http://users.powernet.co.uk/eton/unleashed/errata/ech07.html
> > > 
> > > which describes the problem exactly.  Guides such as
> > > 
> > >   http://www.dpunkt.de/leseproben/3-932588-67-3/Kapitel%207.pdf
> > > 
> > > suggest to use DEBUG for debug levels, which is what Freeciv does.
> > > 
> > > So I suppose Freeciv uses NDEBUG and DEBUG in the usual way after all.
> > 
> > The gist of all that seems to be that DEBUG == !NDEBUG.
> 
> No, the gist of it is that DEBUG is *not* !NDEBUG, but instead, is used
> as an integer for debug levels used in explicit #ifs in the code, while
> NDEBUG has the specific, ANSI-mandated function to turn assert()s off.
> Something like
> 
> #define NDEBUG (DEBUG < DEBUG_LEVEL_FROM_WHICH_WE_WANT_ASSERTS)
> 
> seems reasonable, but I haven't found anything that mandates or
> advises this.

Possible. For the current freeciv code however DEBUG is a boolean. In
general I see no great benefit from this because I don't think that
more than 3 levels are necessary.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "#!/usr/bin/perl -w
  if ( `date +%w` != 1 ) {
    die "This script only works on Mondays." ;
  }"
    -- from chkars.pl by Cornelius Krasel in de.comp.os.linux.misc


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