在Visual Studio C ++ 2010的debug +发布版本中有不同的结果,尽管发布+调试的项目设置相同 [英] Different results in debug+release version of visual studio C++ 2010, although same project settings for release+debug

查看:122
本文介绍了在Visual Studio C ++ 2010的debug +发布版本中有不同的结果,尽管发布+调试的项目设置相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多年前我开发了一种复杂的算法。经过多年的努力,我现在很难理解它的结构。但我现在想把它作为新项目的一部分。在尝试将此代码集成到新项目中时,我得到了一个奇怪的现象。



如果我用VC ++ 6编译代码,算法工作正确,在调试和发布版本。如果我现在使用下面的表达不正确,这并不意味着算法会产生完全错误的结果,但结果的质量要差得多,因为我称之为正确。



如果我使用Visual Studio C ++ 2010编译相同的代码,则该算法在Releaase版本中工作不正确(=低质量结果)。如果我启动由Debug-Compile和Link生成的exe-File,效果相同(结果不好)。但是如果我在VS2010 IDE中启动程序,从Debug-> Start without debugging = F5开始,它会得到正确的结果(=质量好,与VC ++ 6中的Debug + Release相同)。这怎么可能 ?当然,IDE以另一种方式启动Debug-exe-File,就像从命令提示符手动启动一样。设置是什么,以便在发布版本中获得这些结果?



我现在已经更改了所有项目设置,因此它们类似:Release = Debug。特别是我关闭了所有优化。但是,只有当我通过Debug->在IDE中启动程序启动程序时,我才能得到正确的结果。



所以我无法理解这一点效果,我疯狂的原因,因为我在过去的三个晚上尝试了一切,但没有成功。我也尝试使用Visual Studio 2017,结果与VC ++ 2010相同。

我也尝试将lib文件与旧代码链接,由VC +编译和链接+6,在VC ++ 2010的新项目中。但实际上这也会产生不正确的结果(质量差的结果)。



我需要一个可运行的发行版本Windows 10具有正确(良好)的结果。我不能用VC ++ 6来解决这个问题,所以我需要一个解决这个奇怪效果的解决方案。



我尝试了什么:



I have developped a complex algorithm years ago. It is even difficult for me to understand it's structure now after years. But I want to use it now as a part in a new project. While trying to integrate this code in the new project, I got a bizarre phenomenon.

If I compile the code by VC++6, the algorithm works correct, in debug and release version. If I use the expression "incorrect" in the following here now, it does not mean that the algorithm makes completely wrong results, but results that are much worser in quality as I would call it "correct".

If I compile the same code by Visual Studio C++ 2010, the algorithm works incorrect (= low quality results) in the Releaase version. Same effect (bad results) if I start the exe-File that was produced by Debug-Compile and Link. But if I start the program in the VS2010 IDE, from "Debug->Start without debugging = F5", it makes correct results (= good quality, same results as with Debug+Release in VC++6). How is this possible ? Certainly the IDE starts the Debug-exe-File in another way as if it is started manually from command prompt. What is the setting, to get these results also in the Release version ?

I have changed all Project-Settings now, so that they are similar: Release = Debug. Especially I have switched off all optimizations. But there is still the effect that I get the correct results only if I start the program by Debug->Start in the IDE.

So I can not understand this effect, I get crazy cause of that, because I have tried everything to match that during the last three nights, without success. I have also tried it with Visual Studio 2017, with the same result as in VC++ 2010.
I have also tried to link a lib-file with the old code, that was compiled and linked by VC++6, in the new project in VC++ 2010. But in effect also this produces incorrect results (bad quality results).

I need a Release version that is runable in Windows 10 with the correct (good) results. I can not get this with VC++6, so that I need a solution for this bizarre effect please.

What I have tried:

I have also tried to link a lib-file with the old code, that was compiled and linked by VC++6, in the new project in VC++ 2010. But in effect also this produces incorrect results (bad quality results).

推荐答案

引用:

在Visual Studio C ++ 2010的调试版+发布版中有不同的结果,尽管发布+调试的项目设置相同

Different results in debug+release version of visual studio C++ 2010, although same project settings for release+debug



你知道调试和发布版本之间的区别在于,在调试版本中,变量是初始化的,而发布版本不是这种情况。

否则,如果你有一个未初始化的整数变量, debug版本会将其初始化为0,在发布版本中,初始值将是不可预测的,随机的。

但是没有看到代码......


Do you know that 1 difference between debug and release versions is that in debug version, variables are initialized, which is not the case with release version.
Said otherwise, if you have an uninitialized integer variable, the debug version will initialize it to 0, in release version the initial value will be unpredictable, random.
But without seeing the code ...


这篇关于在Visual Studio C ++ 2010的debug +发布版本中有不同的结果,尽管发布+调试的项目设置相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆