peakzhang 发表于 2008-1-11 21:58:05

debug 和 release 版本的问题

不知大家有没有注意到,这两个版本有不少差异,举个简单的例子
在使用ACE发布Release版本程序时,TryEnterCriticalSection导致无法编译的问题
解决方法:
(1)工程 Project-->setting-->C/C++写入: _WIN32_WINNT=0x0500
(2)包含头文件为:#include <windows.h>

而我在使用前摄器时也碰到过奇怪问题,在debug下delete proactor没有任何问题,但编译为release时,就会在此出现异常!我想是不是由于编译为relase时,由于编译器优化导致的???

peakzhang 发表于 2008-1-11 21:58:17

找到上面所说的问题的办法了,在编译ACE时,把编译选项中的优化由 maximize speed 改为 default,就消除了此问题,看来编译器的优化是有些问题的。

peakzhang 发表于 2008-1-11 21:58:28

对了,感谢 winston 版主的文章,是由于看了文章中的一段话

“注意: TAO分Debug和Release版, 所以在开发时, Debug和Release版的设置要严格区分. 即使是MS自己的库也是这样. 如对于Debug版, 要包含MSVCRTd.lib而不是MSVCRT.lib. 我就是因为这个原因而使程序出现异常, 导致差点放弃了TAO :-(”

使我想起了此种解决方法,下面附上VC6中在 DEBUG 版本下调试RELEASE版本的方法

peakzhang 发表于 2008-1-11 21:58:31

Debugging the release version of a program



Something a lot of programmers don't know is that you can debug the release version of a program as easy as the debug version. I didn't know this until I've read John Robbins 'Bugslayer' column in the 'Microsoft System Journal', April 1998 (Vol 13, No 4):

In MSVC you can set all of your project's configurations in the Project Settings dialog.

1.Select the All Configurations option in the Settings For combobox.
2.On the C/C++ tab, select Program Database in the Debug info combobox.
3.On the Link tab, with the Category combobox on Debug, check the Debug info checkbox and the Microsoft format.

If you use your own make file use /Zi switch with CL.EXE and use the use the /DEBUG and /PDB: switches for LINK.EXE,
That's all there is, now you can set breakpoints and watch variables as usual. Be aware that due to the optimizer not all symbols can be watch and the execution of the line may be in a different order!

A common error that affects only the release version of a program is when you use ASSERT instead of VERIFY. Remember ASSERTs will compile to nothing in a release version but VERIFY does. So if you call a function like ASSERT(DoSomething()) this function will not be called in the release version!
页: [1]
查看完整版本: debug 和 release 版本的问题