开发者

How can I work around Visual C++ 2005's "decorated name length exceeded, name was truncated" warning?

开发者 https://www.devze.com 2023-03-24 02:57 出处:网络
For example, say for some reason I had a piece of code that looked lik开发者_如何学JAVAe this: mutable std::vector<std::vector<std::vector<std::vector<

For example, say for some reason I had a piece of code that looked lik开发者_如何学JAVAe 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.


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!


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.

#pragma warning(disable : 4503)

And if you're thinking at all about porting to another compiler, just wrap it in a #ifdef for Visaul C++:

#ifdef MSVC
  #pragma warning(disable : 4503)
#endif
0

精彩评论

暂无评论...
验证码 换一张
取 消