我可以在Visual Studio 2008中使C ++表现得像早期版本吗?

时间:2022-07-17 06:26:21

I need to work with some old C++ code that was developed in Visual C++ 6.0. Right now it's giving me compile errors galore. (For instance, "cannot open include file: 'iostream.h'"... because now it should say #include <iostream> rather than #include <iostream.h>).

我需要使用在Visual C ++ 6.0中开发的一些旧的C ++代码。现在它给了我很多编译错误。 (例如,“无法打开包含文件:'iostream.h'”...因为现在应该说#include 而不是#include )。

How can I work with this code without having to change it all over the place?

如何使用此代码而无需在整个地方进行更改?

5 个解决方案

#1


Unfortunately, there isn't a targetting feature in VS2008 that lets you do this.

不幸的是,VS2008中没有一个目标功能可以让你这样做。

You'll just need to clean up your code. Luckily, VS2008 is far more standards-compliant than older versions of Visual C++ (in particular, VC 6). Getting the code clean should help in the future (you're less likely to have to worry about this later), as well as help if you ever decide to port to other platforms.

您只需要清理代码即可。幸运的是,VS2008比旧版Visual C ++(特别是VC 6)更符合标准。获取代码清洁应该有助于将来(您不太可能在以后担心这一点),以及如果您决定移植到其他平台的帮助。

#2


Problem is, VC6 was very very broken. You only got away with those compiler errors in vc6 because vc6 was so loose. Fix the errors, you'll be glad that you did-- I've done that conversion twice, and it makes the code much safer.

问题是,VC6非常破碎。你只是逃避了vc6中的编译器错误,因为vc6太松了。修复错误,你会很高兴你做了 - 我已经完成了两次转换,它使代码更安全。

#3


As others have mentioned, improving the code to work with VS 2008 will be a worthwhile exercise.

正如其他人所提到的,改进与VS 2008一起使用的代码将是值得的。

If that is not an option (i.e., the legacy app broke and a fix is needed immediately) you could try creating a virtual machine with VC 6 installed and using that to compile the application.

如果这不是一个选项(即遗留应用程序崩溃并且需要立即修复),您可以尝试创建安装了VC 6的虚拟机并使用它来编译应用程序。

#4


If you're looking for a swich that will essentially force Visual Studio 2005/2008 to use the VC6 compiler for C++ code, it doesn't exist.

如果您正在寻找一个基本上迫使Visual Studio 2005/2008将VC6编译器用于C ++代码的swich,它就不存在了。

There are ways to do it with custom make files and lots of hackery. I don't know anyone who's achieved this but I'm sure it's possible with enough work.

有很多方法可以使用自定义make文件和大量hackery来实现。我不知道有谁实现了这个目标,但我确信有足够的工作可以实现。

However, I agree with most of the other people on this thread. You'd be much better served by fixing the code now. You'll likely spend as much time or more implementing a work around as you would just fixing the code straight up.

但是,我同意这个帖子中的大多数其他人。现在修复代码可以让你获得更好的服务。你可能会花费尽可能多的时间或更多的时间来实现一个解决方案,就像你直接修复代码一样。

#5


You should definitely fix the code.

你应该修复代码。

If you cannot do it, and if you have only issues like #include<iostream.h> you can also create an iostream.h file yourself:

如果你不能这样做,如果你只有像#include 这样的问题,你也可以自己创建一个iostream.h文件:

#pragma once

#pragma message("*********************************************")
#pragma message("Do not use #include <iostream.h> in new code!")
#pragma message("*********************************************")

#include <iostream>

using namespace std;

#1


Unfortunately, there isn't a targetting feature in VS2008 that lets you do this.

不幸的是,VS2008中没有一个目标功能可以让你这样做。

You'll just need to clean up your code. Luckily, VS2008 is far more standards-compliant than older versions of Visual C++ (in particular, VC 6). Getting the code clean should help in the future (you're less likely to have to worry about this later), as well as help if you ever decide to port to other platforms.

您只需要清理代码即可。幸运的是,VS2008比旧版Visual C ++(特别是VC 6)更符合标准。获取代码清洁应该有助于将来(您不太可能在以后担心这一点),以及如果您决定移植到其他平台的帮助。

#2


Problem is, VC6 was very very broken. You only got away with those compiler errors in vc6 because vc6 was so loose. Fix the errors, you'll be glad that you did-- I've done that conversion twice, and it makes the code much safer.

问题是,VC6非常破碎。你只是逃避了vc6中的编译器错误,因为vc6太松了。修复错误,你会很高兴你做了 - 我已经完成了两次转换,它使代码更安全。

#3


As others have mentioned, improving the code to work with VS 2008 will be a worthwhile exercise.

正如其他人所提到的,改进与VS 2008一起使用的代码将是值得的。

If that is not an option (i.e., the legacy app broke and a fix is needed immediately) you could try creating a virtual machine with VC 6 installed and using that to compile the application.

如果这不是一个选项(即遗留应用程序崩溃并且需要立即修复),您可以尝试创建安装了VC 6的虚拟机并使用它来编译应用程序。

#4


If you're looking for a swich that will essentially force Visual Studio 2005/2008 to use the VC6 compiler for C++ code, it doesn't exist.

如果您正在寻找一个基本上迫使Visual Studio 2005/2008将VC6编译器用于C ++代码的swich,它就不存在了。

There are ways to do it with custom make files and lots of hackery. I don't know anyone who's achieved this but I'm sure it's possible with enough work.

有很多方法可以使用自定义make文件和大量hackery来实现。我不知道有谁实现了这个目标,但我确信有足够的工作可以实现。

However, I agree with most of the other people on this thread. You'd be much better served by fixing the code now. You'll likely spend as much time or more implementing a work around as you would just fixing the code straight up.

但是,我同意这个帖子中的大多数其他人。现在修复代码可以让你获得更好的服务。你可能会花费尽可能多的时间或更多的时间来实现一个解决方案,就像你直接修复代码一样。

#5


You should definitely fix the code.

你应该修复代码。

If you cannot do it, and if you have only issues like #include<iostream.h> you can also create an iostream.h file yourself:

如果你不能这样做,如果你只有像#include 这样的问题,你也可以自己创建一个iostream.h文件:

#pragma once

#pragma message("*********************************************")
#pragma message("Do not use #include <iostream.h> in new code!")
#pragma message("*********************************************")

#include <iostream>

using namespace std;