Debug & Release Mode Probs
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
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=-
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement