warning 4503 in VC++

Posted on 2005-05-17
Last Modified: 2010-07-27
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.
Question by:anasagasti
    LVL 55

    Expert Comment

    by:Jaime Olivares
    try with this:

    typedef map<string, string> MyMapClass;
    map<string, MyMapClass> whatever;
    LVL 86

    Accepted Solution

    >>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.

    LVL 39

    Expert Comment

    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

    Author Comment

    Thanks to all of you.
    LVL 30

    Expert Comment

    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.

    Author Comment

    Thanks for your advice. It was a mistake typing the example. Anyway, why is better not to put this in a header file?
    LVL 30

    Expert Comment

    >>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
      //Put map here
      map<string, map<string, string> > whatever;

      m_mymap = new pimpl_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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
      Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now