Solved

STL warning messages

Posted on 1998-11-18
2
329 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

738 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