将 VC++6/Win32 项目转换为 VS2010 C++/Win32 项目:已知问题
您是否知道在将 VC++6/Win32 项目转换为 VS2010 C++/Win32 项目类型期间突出显示已知或可能问题的资源?我对各种问题感兴趣:
- 编译器选项兼容性
- 编译时问题
- 链接时问题
- 运行时问题
- MFC 问题
否则,如果您已经执行了此类迁移,那么您遇到了哪些问题?
谢谢
Do you know of any resources highlighting known or possible issues during conversion of a VC++6/Win32 project to VS2010 C++/Win32 project type? I'm interested in all kinds of issues:
- Compiler options compatibility
- Compile-time issues
- Link-time issues
- Runtime issues
- MFC issues
Otherwise, if you already performed that kind of migration, what issues have you encountered?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
VC++6有非标准的异常处理。我们遇到了一些问题,因为我们的代码包含以下内容:
一些开发人员依赖于这种损坏的行为,并且我们的应用程序在 VS2008 中编译后严重崩溃。
这篇文章很好地解释了它以及如何解决问题。
VC++6 has non-standard exception handling. We hit a few problems because our code contain this:
Some developers had relied on this broken behaviour and our application crash badly after being compiled in VS2008.
This article explains it well and how to solve the issue.
首先,这些问题高度依赖于代码质量以及如何修改古老的代码以适应 VC++6 编译器的“功能”。
无法直接将
.dsp
转换为 VS 2010 格式 (至少是 Express 版本),您必须经过 2008 年才能进行转换。转换向导应该警告并通知您可能存在的任何问题。我还没有经历过这个过程,但我认为编译器切换是你最不用担心的。一般来说,我预计糟糕的代码会产生更多您需要担心的错误。
至于你的具体问题:
旁注:我并不是说旧代码不好,只是说关于 VC++6 的 SO 上的很多问题都是由糟糕的代码质量/一致性引起的。
First of all, these issues are highly dependent on code quality and how the ancient code has been adapted to fit the VC++6 compiler's "features".
It's not possible to convert
.dsp
to the VS 2010 format directly (at least with the express editions), you'll have to pass through 2008 to be able to convert.The conversion wizards should warn and inform you of any issues there might be. I haven't been through this process, but I would think compiler switches are the least of your worries. In general, I would expect bad code to produce a lot more errors you need to worry about instead.
As to your specific queries:
sidenote: I'm not saying the old code is bad, just that a lot of questions on SO regarding VC++6 are caused by bad code quality/conformance.
呵呵,vs6 允许你在循环范围之外使用循环变量。即:
这在任何事情上都会失败> vs6 :) 在 2005 年和 2010 年失败了 - 尽管有一个编译器设置允许您再次强制执行此行为(我建议修复它,不要强制它,无论如何它是不合规的),至少在 vs2005 中是这样。我还没有进入 2010 年,因为我做了很多嵌入式开发,而且似乎为嵌入式东西切换编译器通常是一个很大的痛苦。所以,我不能对 2010 年说太多,但我知道这一点将会持续下去!
Heh, vs6 allowed you to use loop variables outside the scope of the loop. ie:
This will fail in anything > vs6 :) fails in 2005 and 2010 - although there is a compiler setting that will allow you to force this behavior again (I would suggest just fixing it, don't force it, its noncompliant anyhow), at least in vs2005. I haven't made the dive to 2010 yet, as I do a lot of embedded development, and it seems switching compilers for the embedded stuff is usually a major pain. So, I can't say too much for 2010, but I know that carries through!
搬家了吗,我知道两个痛苦的问题:
- VC6 及更高版本之间的异常处理默认值已更改。我相信
/Eh
是默认设置,但情况已发生变化。- VC6 运行时 (msvcrt DLL) 包含在自 Win2k 以来的所有 Windows 操作系统中,而对于任何其他版本,您需要将其与几乎所有操作系统的软件一起安装。
Did the move, two painful issues I'm aware of:
- The exception handling default was changed between VC6 and later versions. I believe
/Eh
was the default and that has changed.- VC6 runtime (msvcrt DLL) is included in any Windows OS since Win2k, while for any other version you need to install it with your software for almost any OS.
你会遇到很多问题,因为 VC6 是出了名的不符合标准,而且你的代码(特别是如果你使用模板)可能会充满一些黑客行为,使其不再需要工作,因为 MS 做了很多一致性工作更新的编译器版本,VC10 编译器可能会拒绝它们。
You will have a lot of problems because VC6 was notoriously non-conformant, and your code (especially if you used templates) will likely be full of hacks to make it work that no longer are necessary, as MS did a lot of conformance work for more recent compiler versions, and the VC10 compiler will probably barf on them.
如果您有 Visual C++ 的商业版本:
在 Visual C++ 安装目录中查找 devenv(应为
%VS90COMNTOOLS%\..\IDE\devenv.exe
检查编译
,但如果您有免费版本Visual C++ 的:
在 Visual C++ 安装目录中查找
vcbuild.exe
(应为%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe
)以供将来使用不需要转换的构建,输入:
If you have a commercial edition of Visual C++:
Find devenv within your Visual C++ install directory (should be
%VS90COMNTOOLS%\..\IDE\devenv.exe
Check the compilation
but If you have a free edition of Visual C++:
Find
vcbuild.exe
within your Visual C++ install directory (should be%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe
)For future builds which don’t need conversion, type:
从 VS2005 迁移到 VS2010 时,我们遇到了第 3 方库的问题,导致我们的程序之一在每次加载时崩溃。事实证明,该问题是由 Microsoft 反转链接器中 /NXCOMPAT 开关的默认设置引起的。该开关控制是否启用数据执行保护 (DEP)。在 VS2010 之前,该开关的默认设置为 NO,并且我们使用的 DLL 显然依赖于该设置才能正常运行。
我不确定 NXCOMPAT 链接器开关可以追溯到多远。它未在 VS2005 对话框中的任何可用设置中列出,但在从命令行运行
link /help
时列出。我从来没能从微软找到这样的更改列表,所以这种错误很难追踪。When moving from VS2005 to VS2010, we ran into a problem with a 3rd party library causing one of our programs to crash every time it was loaded. The problem turned out to be caused by Microsoft reversing the default setting for the /NXCOMPAT switch in the linker. That switch controls whether or not Data Execution Prevention (DEP) is enabled or not. Prior to VS2010, the default setting for that switch was NO and the DLL we were using apparently relied upon that setting to function correctly.
I'm not sure how far back the NXCOMPAT linker switch goes. It wasn't listed in any of the settings available in the VS2005 dialogs but it was listed when
link /help
was run from the command line. I've never been able to find a list of changes such as this from Microsoft, so this kind of bug is VERY tricky to track down.如果您使用 CLR 从 VC++ 6 迁移到 VS2015,则不再找到现有的 min 和 max 函数,请添加
其次,NAN float 更改为 nan
If you're migrating from VC++ 6 to VS2015 with CLR, existing min and max functions are no longer found, add
Secondly, NAN float changed to nan