Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/143.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在VS2010中使用版本配置生成时未分配给句柄的值_C++_Visual Studio 2010_Build_Release_Hwnd - Fatal编程技术网

C++ 在VS2010中使用版本配置生成时未分配给句柄的值

C++ 在VS2010中使用版本配置生成时未分配给句柄的值,c++,visual-studio-2010,build,release,hwnd,C++,Visual Studio 2010,Build,Release,Hwnd,我使用VS2010,遇到以下问题: HWND handle = NULL; handle = pPlatform->getWindowHandle(); 在调试配置中调试此代码时,会为句柄分配正确的值,但在发布版本中调试此代码时,句柄将保持为NULL getWindowHandle只是一个简单的访问器: HWND PlatformManager::getWindowHandle() { return windowHandle; } 在调试/发布版本中调试时,windowHan

我使用VS2010,遇到以下问题:

HWND handle = NULL;
handle = pPlatform->getWindowHandle(); 
在调试配置中调试此代码时,会为句柄分配正确的值,但在发布版本中调试此代码时,句柄将保持为NULL

getWindowHandle只是一个简单的访问器:

HWND PlatformManager::getWindowHandle()
{ 
   return windowHandle;
}
在调试/发布版本中调试时,windowHandle具有非NULL值


感谢您的帮助。

发布版本包括优化,有时调试器可能会看到优化变量的错误值。这使得发布版本更难调试,但这正是它们不被称为调试版本的原因

简而言之,如果您只需要调试发布版本,但调试器却在捉弄您,那么您总是可以求助于良好的printf调试。添加一些跟踪函数,例如使用OutputDebugString,并查看句柄在该点是否真的保持为NULL

char-buf[256]; HWND handle=NULL; handle=ppplatform->getWindowHandle;
输出DebutDebugstringa_ItaintHandle,buf,10

谢谢,调试器似乎没有看到正确的值: