c++ - Value not assigned to handle when build using Release Configuration in VS2010 -


i use vs2010 , have encountered following problem:

hwnd handle = null; handle = pplatform->getwindowhandle();  

when debug code in debug configuration correct value assigned "handle", when debug in release build "handle" stays null.

getwindowhandle() simple accessor:

hwnd platformmanager::getwindowhandle() {     return windowhandle; } 

"windowhandle" has non-null value both when debugging in debug/release build.

thanks help.

the release build includes optimizations, , debugger might see wrong value variables optimized. makes release builds harder debug, that's why they're not called debug builds. :)

in short, if have debug release build debugger playing tricks on you, can resort good-old printf debugging. add few trace functions, e.g. outputdebugstring, , see if handle stays null @ point.

char buf[256]; hwnd handle = null; handle = pplatform->getwindowhandle(); outputdebugstringa(_itoa((int)handle, buf, 10));


Comments