Link to home
Start Free TrialLog in
Avatar of anasagasti
anasagasti

asked on

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.
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

try with this:

typedef map<string, string> MyMapClass;
map<string, MyMapClass> whatever;
 
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of anasagasti
anasagasti

ASKER

Thanks to all of you.
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.
Thanks for your advice. It was a mistake typing the example. Anyway, why is better not to put this in a header file?
>>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.