Solved

STL warning messages

Posted on 1998-11-18
2
331 Views
Last Modified: 2013-12-14
I am trying to compile this simple program I got from one
of the STL tutorail sites. The program compiles and runs, but I get a lot of warning messages which I simply do not want to ignore, but can't find a explanation. I am using MS VC++ 4.0. Here is the program:

#include <map.h>
#include <iostream.h>
#include <string.h>



struct ltstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) < 0;
  }
};

void main()
{
  map<const char*, int, ltstr > months;
 
  months["january"] = 31;
  months["february"] = 28;
  months["march"] = 31;
  months["april"] = 30;
  months["may"] = 31;
  months["june"] = 30;
  months["july"] = 31;
  months["august"] = 31;
  months["september"] = 30;
  months["october"] = 31;
  months["november"] = 30;
  months["december"] = 31;
 
  cout << "june -> " << months["june"] << endl;
  map<const char*, int, ltstr>::iterator cur  = months.find("june");
  map<const char*, int, ltstr>::iterator prev = cur;
  map<const char*, int, ltstr>::iterator next = cur;    
  ++next;
  --prev;
  cout << "Previous (in alphabetical order) is " << (*prev).first << endl;
  cout << "Next (in alphabetical order) is " << (*next).first << endl;
}

Here are the error messages:
Compiling...
Text1.cpp
D:\development\c\stl\Text1.cpp(40) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator,rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator>' : identifier was truncated to '255' characters in the debug information
D:\MSDEV\STL\tree.h(840) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator,rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator>' : identifier was truncated to '255' characters in the debug information
D:\MSDEV\STL\tree.h(840) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator,rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator' : identifier was truncated to '255' characters in the debug information
D:\MSDEV\STL\tree.h(840) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator,rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator>' : identifier was truncated to '255' characters in the debug information
D:\MSDEV\STL\pair.h(26) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::iterator,int>::pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::iterator,int>' : identifier was truncated to '255' characters in the debug information
D:\MSDEV\STL\defalloc.h(78) : warning C4786: 'pair<rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator,rb_tree<char const *,pair<char const * const,int>,select1st<pair<char const * const,int>,char const *>,ltstr>::const_iterator>' : identifier was truncated to '255' characters in the debug information
Text1.obj - 0 error(s), 6 warning(s)

What is going on here?
0
Comment
Question by:misha051797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
yonat earned 50 total points
ID: 1178175
The Visual C++ debugger has problems with identifier longet than 255 characters, so the compiler trucncates such identifiers. This is harmless. Add the line
    #pragma warning (disable : 4786)
in the beginning of the file to avoid seeing these warnings, and rebuild all (so that the precompiled headers will also get rebuilt).
0
 
LVL 1

Expert Comment

by:payn
ID: 1178176
If you're using a "StdAfx.h" or similar file that is always included first in all .cpp files, and specifies all of your precompiled headers, make sure to put the #pragma in that file, not just in each file that #includes <map> or whatever. Otherwise the warning may still appear.

I think the problem's actually in the file format. While Microsoft uses COFF for object files, rather than the COFF debugger format, they use their own. I have no idea why. And I think that the debugger labels in their format are Pascal-style length-first strings with one-byte lengths.

Of course the debugger can't display 255 character types or other identifiers in the vast majority of places anyway. It has some problems with word wrap, and in a few places it stores identifiers in an 80-byte slot, and in general the GUI design doesn't give enough space for really long names.

Anyway, because the compiler truncates the names, when the debugger goes to look for names it won't find them. This is why you get that scary warning saying "The debugger cannot debug code with symbols longer than 255 characters. In the debugger, you cannot view, evaluate, update, or watch the truncated symbols."

Well, if you have a variable or function whose unqualified name is over 255 characters, then yes, you're in trouble. But if you have a variable or function whose type is over 255 characters, everything will be fine, even though you get the same warning.

Nearly every time you use a map, you'll get a typename over 255 characters, and you'll get this warning, but you'll never notice any problems if you disable it.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

624 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