且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将MFC中的大项目从Visual C ++ 6.0迁移到Visual Studio 2005

更新时间:2021-10-24 01:02:34

我在

I adressed porting from VC6 to VC9 in this post. I ported a million-line monolithic app from VC6 to VC9 last year, and it proved to be extraordinarily difficult. VC6 was notorious for being not very Standards-compliant even when it came out, and as the Standard evolved in the following years, VC6's compliance just became worse. Microsoft took the opportunity to fix this problem in VC7 to a large degree, but in doing so broke a lot of code that compiled in VC6.

在某些情况下,代码中断是因为代码本身很差,而VC7是更好的编译器,它没有VC6的许多***.但是在许多情况下,由于一致性提高,好的代码"(从VC6的角度来看)变成了非法代码.一个非常简单的例子:

In some cases the code broke because the code itself was poor, and VC7 was a much better compiler that did not allow many liberties that VC6 did. But in many cases "good code" (from VC6's point of view) became illegal code because of the increased conformance. A very simple example:

for( int i = 0, cont = 1; cont; ++i )
{
  // count something up
}

cout << "The number is now " << i << endl;

就VC6而言,这段代码是完美的,但是根据标准,ifor块的末尾超出了范围.像这样的事情有很多很多其他示例,它们从VC6更改为VC7(以及从VC7更改为VC8等).在继续之前,您应该仔细检查这些更改:

This code is perfectly fine as far as VC6 is concerned, but according to the Standard i falls out of scope at the end of the for block. There are many, many other examples of things like this that changed from VC6 to VC7 (and from VC7 to VC8 etc). You should review these changes carefully before you proceed:

  • Breaking Changes VC 2005 - 2008 (VC 2005 -> VC 2008)
  • Breaking Changes in the Visual C++ 2005 Compiler (VC 2003 -> VC 2005)
  • Breaking Changes in Visual C++ .NET 2003 (VC6 -> VC 2003)

除了有更好的合规性外,我们还有许多令人信服的理由转向VC9.一种是编译64位应用程序的能力,因此我们最终决定移植整个应用程序.但是您可能还有其他选择.

We had many compelling reasons to move to VC9 beyond just better compliance. One was the ability to compile 64-bit apps, and so we eventually decided to port the entire app. But you may have alternatives.

如果编译器仅在代码的一部分中为您创建障碍,则可以考虑仅移植该部分,并创建在VC9中编译的层,以弥合VB 8.0与VC6应用程序之间的鸿沟.这可能只是封送代理,它只是在主应用程序和第三方组件之间移动数据而已.

If the compiler is creating a roadblock for you in just one portion of the code, you might consider porting just that portion, and creating a layer compiled in VC9 that bridges the gap between VB 8.0 and your VC6 application. This could be little more than a marshalling proxy, that does nothing more than move data between your main application and the 3rd-party component.