Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 565
Casey Patton Avatar asked Jul 29 '11 23:07

Casey Patton


2 Answers

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!

like image 115
Bo Persson Avatar answered Nov 18 '22 08:11

Bo Persson


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
like image 35
Ryan Shepherd Avatar answered Nov 18 '22 08:11

Ryan Shepherd