Solved

STL warning messages

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

772 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