编译 c++ Visual C++ 7.1 没有 Visual C 的解决方案++
我需要构建一个 Visual C++ 解决方案(.dsp VC++ 7.1),该解决方案是由其他人在 2005 年编写的。我试图在 VS2010 试用版中编译该解决方案,但它给了我一些错误,如下所述
error C3867: 'CServerSocket::SelfDestruct': function call missing argument list; use '&CServerSocket::SelfDestruct' to create a pointer to member
error C2039: 'iterator_category' : is not a member of 'CommandDispatchInserter' c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C2602: 'std::iterator_traits<_Iter>::iterator_category' is not a member of a base class of 'std::iterator_traits<_Iter>' c:\program files\microsoft visual studio 10.0\vc\include\xutility
:调查显示,从 VS2005 开始,各种库的不同实现导致了错误,我认为代码相当不符合标准,这也是一个因素。我没有修改代码以适应 VS 的要求(我对此一无所知),而是想知道是否有一种方法可以编译这个 init 的当前状态,而不需要安装 VS2003 的实例。我尝试过在 Windows 上使用 minGW 但没有成功。它似乎不喜欢 MFC 库。有人对最有效的路线有什么建议吗?
提前致谢
I need to build a visual c++ solution (.dsp VC++ 7.1) which was written by someone else back in 2005. I'm attempting to compile the solution in VS2010 trial but it is giving me some errors as outlined below:
error C3867: 'CServerSocket::SelfDestruct': function call missing argument list; use '&CServerSocket::SelfDestruct' to create a pointer to member
error C2039: 'iterator_category' : is not a member of 'CommandDispatchInserter' c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 10.0\vc\include\xutility
error C2602: 'std::iterator_traits<_Iter>::iterator_category' is not a member of a base class of 'std::iterator_traits<_Iter>' c:\program files\microsoft visual studio 10.0\vc\include\xutility
It seems from my investigations that from VS2005 onwards there are different implementations of various libraries which are causing the errors, I think the code is fairly non compliant with standards which is also a factor. Instead of amending the code to fit in with VS's requirement (which I'm fairly clueless about doing) I was wondering if there was a way of compiling this i nit's current state, short of installing an instance of VS2003. I have tried using minGW for windows but had no luck. It didn't seem to like the MFC libraries. Does anyone have any suggestions as to the most productive route to take?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第一个错误(函数调用缺少参数列表;使用“&CServerSocket::SelfDestruct”)是 VS2003 和 VS2005 之间编译器的更改,以便更符合标准。据我所知,这里唯一的解决方案是按照消息建议修改代码。几年前我们升级VS的时候就遇到过好几个这样的情况;修复它们并不难。
我认为如果不以某种方式修改代码,你将无法在 VS2010 下编译它。我会开始一一修复它们;当然,其他四个错误似乎都是相互关联的,如果您找出其中的问题所在,则可能不需要进行太多更改即可修复。发布导致它的代码会对我们其他人有所帮助。
The first error (function call missing argument list; use '&CServerSocket::SelfDestruct') is a change in compiler between VS2003 and VS2005 to be more compliant with the standard. As far as I know, the only solution here is to amend the code as the message suggests. We had several cases of this when we upgraded VS some years ago; it's not that hard to fix them.
I don't think you are going to be able to compile this under VS2010 without amending the code somehow. I would start fixing them one by one; it certainly seems like the other four errors are all linked together and if you figure out what's wrong there it may not require much of a change to fix. Posting the code that causes it would help the rest of us.
对于第一期,请使用 &显式获取指向成员的指针。没有其他方法可以让它用 VS9 或 10 进行编译。这是一个很容易添加的机械东西,只需要很少的 C++ 知识。
我认为第二个问题是您在某处缺少“typename”限定符。这更难,如果你不懂 C++,你能做的就很少。修复 &首先发布并发布编译器日志和代码以获得更好的答案。
至于你的实际问题,没有办法让它用新版本的 VS 进行编译;有一些“向后兼容性”编译器设置,但这些问题不包含在内。除了 Visual Studio 之外,您也无法使用任何编译器来编译 MFC 代码,因此花费更多时间在 MingW 路线上是没有用的。
因此,您的选择是:
顺便说一句,.dsp 不是 Visual Studio 7.1,它是 Visual Studio 6。如果是这样,您就更糟糕了,因为此后的变化比 7.1 (2003) 以来的变化要大得多。
For the first issue, use the & to explicitly take a pointer to member. There is no other way to get this to compile with VS9 or 10. This is a mechanical thing that is easy to add, very little C++ knowledge needed.
The second issue is, I think, that you're missing a 'typename' qualifier somewhere. This is harder, if you don't know C++ there is only little you can do. Fix the & issue first and post compiler logs and code for better answers.
As to your actual question, no there is no way to get this to compile with newer versions of VS; there are some 'backwards compatibility' compiler settings but these issues aren't covered by it. Nor can you compile MFC code with any compiler other than the Visual Studio one, so the MingW route is useless to spend more time on.
So, your options are:
BTW, .dsp is not Visual Studio 7.1, it's Visual Studio 6. If so, you're screwed even more, because the changes since then are a lot bigger than since 7.1 (2003).
您可以通过在 MSDN 中搜索错误代码来获取有关编译器错误的基本原理的详细信息,例如:当您声明的函数没有显式返回类型时,就会发生 C4430。 Visual C++ 6 此处假定为
int
,后续版本将无法编译。有关 MSDN 中的详细信息,请参阅此处 -其他错误代码搜索(在本例中是字符串
C4430
)也将起作用。You can get detailed information on the rationale for a compiler error by searching on the error code in MSDN, eg. C4430 happens when you have a function declared without an explicit return type. Visual C++ 6 assumed
int
here, later versions will fail to compile.See here for details in MSDN - other error code searches (in this case it was for string
C4430
) will also work.