我如何解决 Visual C++ 2005年的“修饰名称长度超出,名称被截断”警告?
例如,假设出于某种原因,我有一段代码看起来像这样:
mutable std::vector<std::vector<std::vector<std::vector<
std::vector<MyNamespace::MyType> > > > > myFreakingLongVectorThing;
并且我收到了一个看起来像这样的警告:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xstring(1665) : warning
C4503: 'std::vector<_Ty>::operator []' : decorated name length exceeded, name was truncated
with
[
_Ty=std::vector<std::vector<std::vector<std::vector<std::vector<MyNamespace::MyType>>>>>
]
有什么办法可以重写那个该死的长向量而不收到该警告?我仍然希望数据结构相同,但不会收到该警告。我不想禁用警告。可能的?
注意:这是 Visual Studio 2005
....如果您真的很好奇为什么我要使用如此可怕的数据结构,那是由自动生成的代码引起的。
For example, say for some reason I had a piece of code that looked like this:
mutable std::vector<std::vector<std::vector<std::vector<
std::vector<MyNamespace::MyType> > > > > myFreakingLongVectorThing;
and I am getting a warning that looks like this:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\xstring(1665) : warning
C4503: 'std::vector<_Ty>::operator []' : decorated name length exceeded, name was truncated
with
[
_Ty=std::vector<std::vector<std::vector<std::vector<std::vector<MyNamespace::MyType>>>>>
]
is there any way I could rewrite that freaking long vector thing to not get that warning? I still want the data structure to be the same, but not get that warning. I don't want to disable the warning. Possible?
Note: This is Visual Studio 2005
....if you're really curious about why I'm working with such a hideous data structure, it's caused by auto-generated code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想看到警告,则必须禁用它或使用更新的编译器。
该警告是关于类型名称的调试信息限制为 255 个字符。只要这 255 个字符对于两种不同类型不同相同,就可以。如果它们是相同的,你无论如何也无能为力!
只要将其关闭,直到可以升级编译器即可!
If you don't want to see the warning you either have to disable it or use a newer compiler.
The warning is about debug information being limited to 255 characters for the type name. As long as these 255 characters are not identical for two different types, you are ok. And if they are identical, you cannot do much about it anyway!
Just turn it off until you can upgrade the compiler!
这与我以前在 Visual C++ 6 中使用 STL 映射进行任何操作时遇到的错误并没有什么不同。你只需要硬着头皮告诉编译器不要再提这个警告了。它对类型名称的长度有一个基本的内部限制。事实上,这是一个非常无用的警告,只是抱怨编译器/调试器的内部名称限制。
如果您正在考虑移植到另一个编译器,只需将其包装在 Visaul C++ 的 #ifdef 中:
This isn't all that different from the error I used to get in Visual C++ 6 anytime I did just about anything with STL maps. You simply need to bite the bullet and tell the compiler to shut up about that warning. It's got a fundamental internal limit on how long a type name can be. As it is, it's a pretty useless warning, just complaining about the compiler/debugger's internal name limit.
And if you're thinking at all about porting to another compiler, just wrap it in a #ifdef for Visaul C++: