Re: [NEWBIE][CODE] invalid_race/invalid_class

From: The Luthers (Dana and Todd) (luthers@ex-pressnet.com)
Date: 03/06/01


----- Original Message -----
From: "Jared Noble" <jnoble@INREACH.COM>
> > All the conditions must be enclosed in ().
>
> I appreciate that two of you took the time to respond, but you both
> neglected to actually read my email.  My first attempt did include the
extra
> parentheses. Here is a quote from my original mail.
>
> ---------------- snip snip -------------------
> The only modification I had made was not following that particular list of
> races. Anyhow, upon compile the following error was thrown at me.
>
> gcc -g -O2 -Wall  -c class.c
> class.c: In function `invalid_race':
> class.c:2270: warning: suggest parentheses around && within ||
> class.c:2270: parse error before `return'
> *** Error code 1
---snip---
Nonetheless, they are correct. You need those parends. You're warning is
suggesting that you use more of them.

Robert Masten wrote:
>> if  (IS_OBJ_STAT(obj, ITEM_ANTI_HUMAN)    && IS_HUMAN(ch)) ||
>>      (IS_OBJ_STAT(obj, ITEM_ANTI_ELF)      && IS_ELF(ch)) ||
>>      (IS_OBJ_STAT(obj, ITEM_ANTI_HALF_ELF) && IS_HALF_ELF(ch)) ||
.>     (IS_OBJ_STAT(obj, ITEM_ANTI_DWARF)    && IS_DWARF(ch)) ||
>>     (IS_OBJ_STAT(obj, ITEM_ANTI_HALFLING) && IS_HALFLING(ch)) ||
>>     (IS_OBJ_STAT(obj, ITEM_ANTI_GNOME)    && IS_GNOME(ch))
>
>What you have actually added is:
>
>if (item) || (item) || (item)
>
>instead of
>
>if ( (item) || (item) || (item) )

the
if (item) || (item) || (item)
may be clearer if you view it in this way:

if (item)  // if item is true
    || (item)  || (item) // do this

because that's what you're telling it - which makes no sense.
putting the ( )s around the whole thing turns it into a single if condition
of

if ((item)||(item)||(item))
     //do whatever follows

so, put the outer parenthesis *back* on and hunt out the true problem ;)
Dana

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/04/01 PST