Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6380) remove is_real and is_valid sanity variables
Home

[Freeciv-Dev] Re: (PR#6380) remove is_real and is_valid sanity variables

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#6380) remove is_real and is_valid sanity variables
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Oct 2003 01:50:17 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Guest wrote:
> [jdorje - Fri Oct  3 19:32:07 2003]:
> 
> 
>>John Wheeler wrote:
>>
>>>[jdorje - Thu Oct  2 23:47:02 2003]:
>>>
>>>
>>>
>>>>Most places in the code use this form:
>>>>
>>>>  if (!normalize_map_pos(&x, &y)) {
>>>>    assert(0);
>>>>  }
>>>
>>>
>>>Hmm... for a quick solution, would "assert(normalize_map_pos(&x, 
> 
> &y);" 
> 
>>>work?
>>
>>No, it absolutely would not.  Anything include in the assertion is 
> 
> not 
> 
>>compiled at all if debugging is not used.
> 
> 
> What the heck!?!
> 
> ... searching assert.h ...
> 
> #ifdef NDEBUG
> #define assert(x) (x)
> #else

 From 'man assert' (in glibc):

        If  the  macro  NDEBUG  was  defined  at the moment <assert.h>
        was last included, the macro assert() generates no code, and
        hence does  nothing at all.  Otherwise, the macro assert() prints
        an error message to standard output and terminates the program by
        calling abort() if expression is false (i.e., compares equal to
        zero).

assert is defined by ANSI C.  I haven't read the full spec, however; 
perhaps the behavior is unspecified in the NDEBUG case.

jason




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