Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

std::map

Posted on 2000-03-20
9
Medium Priority
?
541 Views
Last Modified: 2013-12-14
Hi,
I'm trying to use a very simple sample from a Herbert Schildt's book using the stl's map, but it doesnt work. Im using MSDeV Studio 6 and when I compile it gives a lot of hieroglific warnings. Is it something to do with the Micrososft implemetation of STL?

The sample is:

#include  <iostream>
#include  <map>
using namespace std;
int main()
{
  map<char, int> m;
  int i;
  for(i = 0; i <26 ; i++)
    m.insert(pair<char,int('A'+i,65+i));

  char ch;
  cout << "Enter key: ";
  cin >> ch;
 
  map<char, int>::iterator p;
  p = m.find(ch);
  if (p != m.end())
    cout << "Its ASCII value is "  << p->second;
 else
    cout << "key not in map.\n";
  return 0;
}
0
Comment
Question by:nogueira
[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
  • 4
  • 3
  • 2
9 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 225 total points
ID: 2635985
>> Is it something to do with the
>> Micrososft implemetation of STL?
Sometimes this is the problem, but rarely.  More likely itis a mistake in your code.

>>  m.insert(pair<char,int('A'+i,65+i));
There is no ">" at the end of the "pair<"

If that doesn't fix the problem, lost the error messages you are getting.
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2636175
Error messages on templates can be intimidating. If nietods suggestion does not work, try to comment out the major part of the code (leaving only the map's declaration) and uncomment parts until the error reappears.
0
 

Author Comment

by:nogueira
ID: 2636299
well in fact it misses a > in the sample I've posted but thats an error I've made when I 'pasted' in here the code. the warnings that keep appearing me are of the type :

warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<char,s ...'

if it helps...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:KangaRoo
ID: 2636468
Could you give a bit more of the warning message?
0
 

Author Comment

by:nogueira
ID: 2636649
Adjusted points from 50 to 75
0
 

Author Comment

by:nogueira
ID: 2636650
These are the warnings that appear in the MSDevStudio 6 debug window:

--------------------Configuration: mapTeste - Win32 Debug--------------------
Compiling...
MapTeste.cpp
h:\geopilot\src\testes\mapteste\mapteste.cpp(52) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::it
erator,std::pair<char const ,int>,std::pair<char const ,int> &,std::pair<char const ,int> *,int>' : identifier was truncated to '255' characters in the debug information
h:\geopilot\src\testes\mapteste\mapteste.cpp(52) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::co
nst_iterator,std::pair<char const ,int>,std::pair<char const ,int> const &,std::pair<char const ,int> const *,int>' : identifier was truncated to '255' characters in the debug information
h:\geopilot\src\testes\mapteste\mapteste.cpp(52) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,std::_Tree<char,std
::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator>' : identifier was truncated to '255' characters in the debug information
h:\geopilot\src\testes\mapteste\mapteste.cpp(52) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::const_iterator,std::_Tree<ch
ar,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::const_iterator>' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(182) : warning C4786: 'std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::~_Tree<char,std::pair<
char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(162) : warning C4786: 'std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::_Tree<char,std::pair<c
har const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(236) : warning C4786: '__ehhandler$?insert@?$_Tree@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tree@DU
?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@_N@2@ABU?$pair@$$CBDH@2@@Z' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(236) : warning C4786: '__unwindfunclet$?insert@?$_Tree@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tre
e@DU?$pair@$$CBDH@std@@U_Kfn@?$map@DHU?$less@D@std@@V?$allocator@H@2@@2@U?$less@D@2@V?$allocator@H@2@@std@@_N@2@ABU?$pair@$$CBDH@2@@Z$0' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\utility(21) : warning C4786: 'std::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,bo
ol>::pair<std::_Tree<char,std::pair<char const ,int>,std::map<char,int,std::less<char>,std::allocator<int> >::_Kfn,std::less<char>,std::allocator<int> >::iterator,bool>' : identifier was truncated to '255' characters in the debug information
Linking...

mapTeste.exe - 0 error(s), 9 warning(s)
0
 
LVL 7

Expert Comment

by:KangaRoo
ID: 2636731
The warning message is clear enough: "identifier was truncated to '255' characters in the debug information"
The compiler stores information on the C++ source code in the compiled object files (code, identifier names and type), which is used by the debugger to give you readable names and type information. You will probably loose some debugging comfort after this message.
There maybe some compiler option to expand the possible size of debug identifier names, or a switch or pragma to diable this specific warning, something like
#pragma warn -C4786
I don't have VC but nietod does...
0
 

Author Comment

by:nogueira
ID: 2636965
Thanks kangaroo
0
 
LVL 22

Expert Comment

by:nietod
ID: 2637191
Sory for not getting back.  I've been unable to connect reliably to EE all morning.  I've been getting the notificatin e-mails though, an been very impatient to see what was going on here.

As kangroo said, that message is simply a warning and can be ignored--eveyone who uses STL gets it.  

There is no way to expand limit that has been reached, but there doesn't seem to be need either.  Instead you can prevent the warning from printing.

But another problem has creeped in.  I don't have access to VC right now, and I don't remember the exact syntax you need to to dissable the warning.  It is done with a #pragma of some sort.   You can look in the help under #pragma.  If you can't find it, post a message here and I'll be able to look it up.  (In a few hours.)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

670 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