VS2008-> VS2010 导致神秘的 STL 错误
以下 C++ 库已在 VS2008
http://sourceforge. net/projects/xmlrpcc4win/files/xmlrpcc4win/XmlRpcC4Win1.0.8.zip/download
当我在 VS2010 中打开它时,它会完成转换向导过程,没有任何错误。
现在,当我尝试在 VS2010 中编译它时,我收到一些奇怪的 STL 错误,如下所示:
1>TimXmlRpc.cpp(1018): error C2039: 'back_insert_iterator' : is not a member of 'std'
1>TimXmlRpc.cpp(1018): error C2065: 'back_insert_iterator' : undeclared identifier
1>TimXmlRpc.cpp(1018): error C2275: 'XmlRpcValue::BinaryData' : illegal use of this type as an expression
1>TimXmlRpc.cpp(1018): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1018): error C2039: 'back_inserter' : is not a member of 'std'
1>TimXmlRpc.cpp(1018): error C3861: 'back_inserter': identifier not found
1>TimXmlRpc.cpp(1019): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2039: 'back_insert_iterator' : is not a member of 'std'
1>TimXmlRpc.cpp(1031): error C2065: 'back_insert_iterator' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression
1> with
1> [
1> _Ty=char
1> ]
1>TimXmlRpc.cpp(1031): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2039: 'back_inserter' : is not a member of 'std'
1>TimXmlRpc.cpp(1031): error C3861: 'back_inserter': identifier not found
1>TimXmlRpc.cpp(1032): error C2065: 'ins' : undeclared identifier
我不知道如何处理其中的一些错误。例如, back_insert_iterator
实际上是 std
的成员,但 VS 似乎并不认为它是。
我该如何修复此类错误?它们似乎没有多大意义,所以我不知道从哪里开始。也许它在我的项目设置中?
例如,这里是第 1018 行,它给出了标准错误:
std::back_insert_iterator<BinaryData> ins = std::back_inserter(*(u.asBinary));
如果有人能给我一些指导,我将不胜感激。我对 C++ 还很陌生,所以我很难弄清楚这个问题。
The following C++ library was successfully compiled in VS2008
http://sourceforge.net/projects/xmlrpcc4win/files/xmlrpcc4win/XmlRpcC4Win1.0.8.zip/download
When I open it in VS2010, it goes through the conversion wizard process without any errors.
Now, when I attempt to compile it in VS2010, I get some weird STL errors like these:
1>TimXmlRpc.cpp(1018): error C2039: 'back_insert_iterator' : is not a member of 'std'
1>TimXmlRpc.cpp(1018): error C2065: 'back_insert_iterator' : undeclared identifier
1>TimXmlRpc.cpp(1018): error C2275: 'XmlRpcValue::BinaryData' : illegal use of this type as an expression
1>TimXmlRpc.cpp(1018): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1018): error C2039: 'back_inserter' : is not a member of 'std'
1>TimXmlRpc.cpp(1018): error C3861: 'back_inserter': identifier not found
1>TimXmlRpc.cpp(1019): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2039: 'back_insert_iterator' : is not a member of 'std'
1>TimXmlRpc.cpp(1031): error C2065: 'back_insert_iterator' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2275: 'std::vector<_Ty>' : illegal use of this type as an expression
1> with
1> [
1> _Ty=char
1> ]
1>TimXmlRpc.cpp(1031): error C2065: 'ins' : undeclared identifier
1>TimXmlRpc.cpp(1031): error C2039: 'back_inserter' : is not a member of 'std'
1>TimXmlRpc.cpp(1031): error C3861: 'back_inserter': identifier not found
1>TimXmlRpc.cpp(1032): error C2065: 'ins' : undeclared identifier
I'm not sure what to make of some of these. For instance,back_insert_iterator
is in fact a member of std
, but VS doesn't seem to think it is.
How do I fix errors like these? They just don't seem to make much sense so I'm not sure where to begin. Perhaps its something in my project settings?
For example, here is line 1018, which gives the std error:
std::back_insert_iterator<BinaryData> ins = std::back_inserter(*(u.asBinary));
If anyone could give me some direction I'd appreciate it. I'm new enough to C++ that I'm having a tough time figuring out this one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能在某些文件中忘记了
#include
。这就是声明诸如back_insert_iterator
之类的内容的地方。在过去,您可能会忘记该头文件,因为许多其他标准头文件也包含它。 VS2010 重新组织了其库实现的标头,使其更加符合标准。因此,它对丢失标头的容忍度要低得多,并且
是一个经常被忽视的标头。You probably forgot
#include <iterator>
in some of your files. That's where things likeback_insert_iterator
are declared.In the past, you could get away with forgetting that header file, since many of the other standard headers also included it. VS2010 reorganized the headers for its library implementation to be more standards compliant. As a result, it's much less forgiving of missing headers, and
<iterator>
is a commonly overlooked one.来自 MSDN:
许多其他头文件不再自动包含该头。相反,如果您需要支持标头中定义的独立迭代器,请显式包含该标头。
http://msdn.microsoft.com/en-us/library/bb531344.aspx
From MSDN:
The header is no longer included automatically by many other header files. Instead, include that header explicitly if you require support for the standalone iterators defined in the header.
http://msdn.microsoft.com/en-us/library/bb531344.aspx