将C ++从VS2003迁移到VS2005需要哪些代码更改? [英] What code changes are required to migrate C++ from VS2003 to VS2005?

查看:164
本文介绍了将C ++从VS2003迁移到VS2005需要哪些代码更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在考虑将我们的跨平台C ++应用程序的win32版本从MS Visual Studio 2003移动到MS Visual Studio 2005.(是的,非常前瞻的);


$ b $

解决方案

我刚刚迁移了一个比较大代码库从VS2003到VS2008通过VS2005和大多数问题,我发现是const /非常见问题,如分配函数的返回值的函数返回一个const char *到char *。 VS2005和VS2008在const正确性上更加挑剔,如果你现有的代码库有点马虎,对不起,老学校,当它涉及到const正确性,你会看到很多这样。



一个非常受欢迎的变化是,VS2005中的模板支持明显优于VS2003(本身是对早期版本的一个很大的改进),这使我能够为模板相关的问题抛出几个解决方法



你可能会遇到的一个问题是关于deprecated或deprecated的大量警告,不安全的功能,特别是如果你使用C字符串函数。许多这些都是由Microsoft废弃(只是他们省略了由微软部分),仍然完全可用,但已知的潜在的缓冲区溢出的来源。在我转换的项目中,我设置预处理器定义_CRT_SECURE_NO_WARNINGS并禁用警告C4996关闭这些有点恼人的消息。



我们遇到的另一个问题是MS has在VS2005或VS2008中更改time_t的默认大小(我道歉,但我不记得 - 它肯定在VS2008,但它可能已经在VS2005)所以如果你必须链接使用time_t的接口中的传统库,您必须使用_USE_32BIT_TIME_T来恢复旧的编译器行为。



如果您的解决方案包含多个项目,您可能会发现并行构建功能默认情况下)将突出显示丢失的构建依赖关系。所以项目突然建立在错误的顺序,但神奇地建立正确如果你从并行恢复到线性构建。



总的来说,我喜欢VS2005 / 8 VS2003,我建议升级到VS2008如果这是一个选项,因为编译器是更好VS2005 - MS似乎已经做了巨大的努力,以改进本机C ++编译器。其中的一部分在2005年已经很明显,所以即使你坚持2005年,你也会得到一些好处。


We are considering moving the win32 build of our cross-platform C++ application from MS Visual Studio 2003 to MS Visual Studio 2005. (Yes, very forward-looking of us ;)

Should we expect to many code changes to get it compiling and working?

解决方案

I've just migrated a comparatively large codebase from VS2003 to VS2008 via VS2005 and the majority of issues I found were const/non-const issues like assigning the return value of a function that returns a const char * to char *. Both VS2005 and VS2008 are a lot more picky when it comes to const correctness and if your existing codebase is a bit sloppy, sorry, old school when it comes to const correctness, you'll see plenty of this.

A very welcome change was that the template support in VS2005 is noticeably better than it is in VS2003 (itself a big improvement on earlier versions), which enabled me to throw out several workarounds for template related issues that the team had been dragging around since the heady days of VC++ 4.x.

One issue that you are likely to encounter are tons of warnings about "deprecated" or "insecure" functions, especially if you are using the C string functions. A lot of these are "deprecated by Microsoft" (only that they left out the "by Microsoft" part) and are still perfectly usable, but are known potential sources for buffer overflows. In the projects I converted, I set the preprocessor define _CRT_SECURE_NO_WARNINGS and disabled the warning C4996 to turn off these somewhat annoying messages.

Another issue that we came across is that MS has changed the default size of time_t either in VS2005 or in VS2008 (I apologise but I can't remember - it's definitely in VS2008 but it may already be in VS2005) so if you have to link with legacy libraries that use time_t in the interface, you'll have to use _USE_32BIT_TIME_T to revert to the older compiler's behaviour.

If your solution contains several projects, you may find that the parallel build feature (which is turned on by default) will highlight missing build dependencies. so projects are suddenly built in the wrong order but magically build correctly if you revert from parallel build back to linear build.

Overall I do prefer VS2005/8 to VS2003, and I would recommend to upgrade to VS2008 if that is an option, as the compiler is "better" than VS2005 - MS seems to have made a massive effort in improving the native C++ compiler. Part of that was already noticeable in 2005 so you'll get at least some of the benefit even if you stick to 2005.

这篇关于将C ++从VS2003迁移到VS2005需要哪些代码更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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