Warning warning

Posted by Robert Powell on Fri 27 Feb 2004 05:35 AM — 2 posts, 11,529 views.

Australia #0
I have made a lot of additions and changed the way a lot of others work lately and now have a few warnings i would like to fix. The first one is this:
: left hand operand of comma expression has no effect

if ( !(ch, number_percent(), gsn_scribe) > 50)

How can i re-write this line so as to stop the error, this line is from a scribe 3 spells snippet.

The next one is:

: assignment from incompatible pointer type

AttrPerm = &ch->max_hit;

Ok with this one i have sh_int *AttrPerm going into int max_hit, which i guess in it self isnt a bad thing as they are both types int and its the smaller going into the bigger(if i read how it happens correctly), max_hit is now int so i can have 100K hp, what i would like to know is what would be my best remidy for this, i was going to make all the stats ints but thats a waste of memory, my next guess was to add another pointer into the function *AttrPerm2 and make it int. What would be the tidiest way to achieve this. Thanks in advance for all replys.
Australia Forum Administrator #1
Quote:

if ( !(ch, number_percent(), gsn_scribe) > 50)


This looks like a function call without the function name.

Here is a simple test program that does that, and gives that warning:


int main (void)
  {
  if ( (2, 4, 6) == 6)
    printf ("true\n");
  else
    printf ("false\n");
  }


If you run that, it prints "true".

In other words, the expression (2, 4, 6) is simply 6, the 2 and 4 are discarded.

Sounds like it should read:


if ( ! some_function(ch, number_percent(), gsn_scribe) > 50)


Quote:

AttrPerm = &ch->max_hit;



Ok with this one i have sh_int *AttrPerm going into int max_hit ...


Not really, you are assigning pointers here, not what they point to. You may mean this:


*AttrPerm = ch->max_hit;


This would put the contents of max_hit (ie the number of hits) into whereever AttrPerm points to.