[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1500
  • Last Modified:

warning 4503 in VC++

With VC++ 6.0

I'm doing something like this:

map<string, map<string, string>> whatever;

and the compiler tell  me the following, even in release:

warning C4503: 'insert' : decorated name length exceeded, name was truncated

I don't know exactly the meaning of this and if it's important or not or how to avoid it.
0
anasagasti
Asked:
anasagasti
1 Solution
 
Jaime OlivaresCommented:
try with this:

typedef map<string, string> MyMapClass;
map<string, MyMapClass> whatever;
 
0
 
jkrCommented:
>>I don't know exactly the meaning of this and if it's important or not or how to avoid it.

It isn't "dramatic", and you can easily remove it using a #pragma directive:

#pragma warning(disable: 4786)

The meaning is: "The decorated name was longer than the maximum the compiler allows (247), and was truncated"

"Name decoration" means:

Functions in C and C++ programs are known internally by their decorated names. A decorated name is a string created by the compiler during compilation of the function definition or prototype.

A decorated name is sometimes required when you specify a function name to LINK or other tools. For details about the situations that require decorated names, consult the documentation for the tool you are using.

0
 
itsmeandnobodyelseCommented:
That's a bug in VC6.

You could suppress this warning (and C4786) by

#pragma warning (disable: 4503 4786 )

as very first statement in cpp files (or in a common header included first by all cpp files, e. g. stdafx.h).

Regards, Alex
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
anasagastiAuthor Commented:
Thanks to all of you.
0
 
AxterCommented:
FYI:
map<string, map<string, string>> whatever;

Make sure there is a space betwee >>, as in the following:
map<string, map<string, string> > whatever;

Also, I recommend you try to avoid putting this in a header file.
0
 
anasagastiAuthor Commented:
Thanks for your advice. It was a mistake typing the example. Anyway, why is better not to put this in a header file?
0
 
AxterCommented:
>>Thanks for your advice. It was a mistake typing the example. Anyway, why is better not to put this in a header file?

Because it gets harder to avoid the 4503 and 4786 warnings that VC++ produces.
This is especially true in a large project.
What I usually do is create a pimpl object in the header, and then create the actuall map object in the *.cpp source file so that it doesn't have to get exposed in the header.

class pimpl_foo;
class foo
{
  pimpl_foo* m_mymap;
};

Then in your *.cpp file.

class pimpl_foo
{
  public:
  //Put map here
  map<string, map<string, string> > whatever;
};

foo::foo()
{
  m_mymap = new pimpl_foo;
}

foo::~foo()
{
  delete m_mymap;
}

This is an easy method to use to hide all your complex objects or any object that might cause you problems if you put it in the header.
Using this method, it also makes it easier for you to modify your class objects without effecting the interface, and without requiring all other links to that object to have to recompile.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now