Solved

STL warning messages

Posted on 1998-11-18
2
321 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
2 Comments
 
LVL 5

Accepted Solution

by:
yonat earned 50 total points
Comment Utility
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
Comment Utility
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

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

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

743 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

9 Experts available now in Live!

Get 1:1 Help Now