Advertisement

Debug & Release Mode Probs

Started by January 25, 2002 08:48 AM
1 comment, last by Wavarian 23 years, 1 month ago
Ack.. try to help me figure out this one.. After making a small engine in c++ under debug mode, all ran well until i decided to run it in release mode to check its size. Unfortunately, what this release mode is mistaking in particular is: char* mystring; mystring = "none"; if (mystring == "none") return false; else return true; in debug mode, this returns false (the correct answer), however in release mode, it returns true. what the heck is going on? i was thinking of some library or flag missing from the release mode config, but im baffled.. anyone know an answer to this prob? 0 errors, 0 warnings just before you ask if an error message appeared following the compilation. Thanks again guys
Well, the thing is that while this might work, sometimes, you should not check string values like this. What you're actually doing is checking the value of the mystring pointer to the address where "none" resides. If the compiler decides it's necessary to store that string ("none") in the same location both times then your comparison will work. Otherwise, it won't. Thus you see the mysterious results you are getting in the two different modes.

Try using 'strcmp' :-) It compares the strings and will work properly all the time

-------------------
"Pointer?????"
-Anonymous

-=Xelius=-

Edited by - xelius on January 25, 2002 10:02:29 AM
-------------------"Pointer?" -Anonymous-=Xelius=-
Advertisement
Thanks for the quick reply.. I was going to say that thats what i thought it was doing in my previous post but decided to leave it out just incase i was way off track =)

Thanks alot for the advice, i''ll try it out first thing tomorrow

This topic is closed to new replies.

Advertisement