Stupid Compiler Tricks

From: Sammy (samedi@DHC.NET)
Date: 05/14/98

I've had the strangest thing happen to me while troubleshooting code
recently.  I worked around it the first time, but tis is something that
definitely needs fixing.

What is happening is that I'm adding variables and code to an existing
function (mobile_activity) which when compiled are completely ignored.
Dong an "info locals" in gdb doesn't show my variables, and if I try to
print them, I'm told there aren't any variables of that name in this
context.  Strangely, the code shows up as expected when I "list" it, and
if I pass the variables to functions, they're passed as 0.

Here's a specific example.  I'm adding a dragon breath feature where I
need to check each mob for it's dragon type, which I then pass to the
dragon_breath() function if the mob is a dragon and fighting.  I'm using
flags to set dragon type so I don't have to do anything with the mob

In mobile_activity(), I added int dragon_type.  A little ways down,
dragon_type is found by doing some bit shifting (I'm using 5 mob flag bits
to allow for 31 dragon types).  If the dragon type is valid and the mob is
fighting, I call dragon_breath(ch, dragon_type).

Now, when this code runs, it acts as if dragon_type is always 0.  I've
doublechecked my math to make sure it's correct.  GDB tells me dragon_type
doesn't exist in mobile_activity.

Any ideas about what's going on here?


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST