将C ++代码从VC6移植到VS2010

将C ++代码从VC6移植到VS2010

问题描述:



我的代码很旧.在过去的15年中,我已经积累了许多行(有用的VC ++代码).一些库很棒并且可以正常工作.

我正在启动一个新程序.我想使用VS2010.不幸的是,我想使用的2个库是用VC6编译的(大约6年前).那些图书馆很大. (不是巨人,但足够大以至于让我思考:-))

将此源代码移植到VS2010上是否很重要(两者均为32b,并且将一直保持这种状态)?您对此操作有何建议?更麻烦的是,我不知道2003年之后的所有Visual Studio版本! (我使用VS 6 Pro已有很长时间了,没关系:但是情况发生了变化.... ;-))

提前很多建议
最好的问候
Guy

Hi,

My code is old. I have accumulated many lines of (useful) VC++ code for the last 15 years. Some libraries are great and work fine.

I am starting a new program. I''d like to use VS2010. Unfortunately, 2 of the libraries that I''d like to use are compiled with VC6 (6 or so years ago). Those libraries are big. (not giant but big enough to make me think :-) )

Is it a big deal to make the port of this source code to VS2010 (both are 32b and will remains like that)? What is your advice to do this operation? And to add some difficulties, I don''t know at all Visual Studio releases post 2003! (I only used VS 6 Pro for ages and it was ok: but things change.... ;-) )

Many thx in advance for the advice
Best regards
Guy

我的建议是将其移至VS2010.

从计划开始-可能只是您想重构某些代码,如果要将代码移至更新的C ++版本,则应该认真考虑.

在开始之前,有一些库需要我调查(是否使用它们取决于您,但值得研究):
1 增强C ++库 [ ^ ]

2 ICU-Unicode的国际组件 [ ^ ]

3 Xerces C ++ XML解析器 [ ACE/TAO [
My advice would be to move it to VS2010.

Start out by planning - it just might be that you would like to refactor some of your code, and if you''re moving the code to a more modern version of C++, you should proably think things through.

Before you start, there are a few libraries that I would investigate (whether you use them or not is up to you, but they are well worth investigating):
1 Boost C++ library[^]

2 ICU - International Components for Unicode[^]

3 Xerces C++ XML Parser[^]

4 ACE/TAO[^]

These libraries have been ported to a wide range of compilers and platforms, and they are thoroughly tested.

Consider using/replacing parts of your library with functionality from libraries that you do not have to maintain.

Think in terms of header only libraries, this often makes it easier to use you code.

Use namespaces :)

Best regards
Espen Harlinn


除了必须修复一些错误和更改过程之外,这个过程应该不会太痛苦.为了使您轻松自在,您可能需要尝试免费的 Visual C ++ Express [ ^ ].它是精简版,但包含编译器和库,但不包含MFC.我感觉微软还提供了VS2010 Pro的试用版,可能会为您提供帮助.
Apart from having to fix a few bugs and changes the process should not be too painful. In order to ease yourself into it you may want to try the free Visual C++ Express[^]. It''s a cut down version but includes the compiler and libraries but not MFC. I have a feeling Microsoft also offer a trial version of VS2010 Pro, which may help you.


要做的第一件事就是尝试对其进行编译,以了解您遇到的问题.可能有.

如果您拥有Visual Studio的专业版本,并且有很多错误,则应该一个一个地编译文件并修复错误.

项目也是一样.一一建立.当您遇到很多编译错误时,这种方法要容易得多.

真正可以帮助转换的方法是排除和/或注释掉最有问题的区域,然后在编译(构建)后逐步将这些部分添加回去.

最后的技巧是,如果遇到很多问题,编写一些辅助代码.在某些情况下,查找和替换也可能有用.

如果您要进行很多更改,则具有源代码控制也很特别.
The first thing to do would be to try to compile it to get an idea of the problem you might have.

If you have the professionnal version of Visual Studio and there are a lot of errors, then you should compile file one by one and fix errors.

Same thing for project. Build them one by one. It is much easier that way when you have a lot of compilation errors.

Something that can also really help the conversion is to exclude and/or comment out most problematic area and then once it compile (and build) add back those part progressively.

The final trick is to write some helper code if you have problematic case that opccurs a lot. In some case, find&replace might also be useful.

Having source control is also a plus particulary if you have a lot of changes to do.