Archived

This topic is now archived and is closed to further replies.

Kurioes

STL Map giving annoying warnings

Recommended Posts

I'm using a STL map this way (just playing aroud a little bit):
  
#include <map>
#include <stdio.h>

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

typedef std::map tMap;
typedef std::map::iterator tMapItor;

int main(int argc, char **argv)
{
    tMap Map;

    int test = Map["testing1"];
    printf("test: %d\n", test);
    Map["testing1"] = 33;
    test = Map["testing1"];
    printf("test: %d\n", test);
    Map["testing2"] = 666;
    int test2 = Map["testing2"];
    printf("test2: %d\n", test2);

    return 0;
}
   
When compiling, MSVC 6.0 gives me the following error log: ##########################################################

Build Log

--------------------Configuration: stlmap - Win32 Debug--------------------

Command Lines

Creating temporary file "C:\DOCUME~1\Tristan\LOCALS~1\Temp\RSP60F.tmp" with contents [ /nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"Debug/stlmap.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c "C:\BOMBRUN\TESTS\stlmap\main.cpp" ] Creating command line "cl.exe @C:\DOCUME~1\Tristan\LOCALS~1\Temp\RSP60F.tmp" Creating temporary file "C:\DOCUME~1\Tristan\LOCALS~1\Temp\RSP610.tmp" with contents [ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/stlmap.pdb" /debug /machine:I386 /out:"Debug/stlmap.exe" /pdbtype:sept .\Debug\main.obj ] Creating command line "link.exe @C:\DOCUME~1\Tristan\LOCALS~1\Temp\RSP610.tmp"

Output Window

Compiling... main.cpp C:\BOMBRUN\TESTS\stlmap\main.cpp(33) : warning C4786: 'std::reverse_bidirectional_iteratorair,std::map >::_Kfn,ltstr,std::allocator >::iterator,std:air,std:air &,std:air *,int>' : identifier was truncated to '255' characters in the debug information C:\BOMBRUN\TESTS\stlmap\main.cpp(33) : warning C4786: 'std::reverse_bidirectional_iteratorair,std::map >::_Kfn,ltstr,std::allocator >::const_iterator,std:air,std:air const &,std:air const *,int>' : identifier was truncated to '255' characters in the debug information C:\BOMBRUN\TESTS\stlmap\main.cpp(33) : warning C4786: 'std:airair,std::map >::_Kfn,ltstr,std::allocator >::iterator,std::_Treeair,std::map >::_Kfn,ltstr,std::allocator >::iterator>' : identifier was truncated to '255' characters in the debug information C:\BOMBRUN\TESTS\stlmap\main.cpp(33) : warning C4786: 'std:airair,std::map >::_Kfn,ltstr,std::allocator >::const_iterator,std::_Treeair,std::map >::_Kfn,ltstr,std::allocator >::const_iterator>' : 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@PADU?$pair@QADH@std@@U_Kfn@?$map@PADHUltstr@@V?$allocator@H@std@@@2@Ultstr@@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tree@PADU?$pair@QADH@std@@U_Kfn@?$map@PADHUltstr@@V?$allocator@H@std@@@2@Ultstr@@V?$allocator@H@2@@std@@_N@2@ABU?$pair@QADH@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@PADU?$pair@QADH@std@@U_Kfn@?$map@PADHUltstr@@V?$allocator@H@std@@@2@Ultstr@@V?$allocator@H@2@@std@@QAE?AU?$pair@Viterator@?$_Tree@PADU?$pair@QADH@std@@U_Kfn@?$map@PADHUltstr@@V?$allocator@H@std@@@2@Ultstr@@V?$allocator@H@2@@std@@_N@2@ABU?$pair@QADH@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:airair,std::map >::_Kfn,ltstr,std::allocator >::iterator,bool>:airair,std::map >::_Kfn,ltstr,std::allocator >::iterator,bool>' : identifier was truncated to '255' characters in the debug information Linking...

Results

stlmap.exe - 0 error(s), 7 warning(s) ########################################################## What is causing this? For some reason std::list used to do about the same (the long identifiers) but it quit doing so somehow... This message is really annoying. p.s. I tried #pragma warnings to stop the warnings from showing but I must have messed uo. [edited by - Kurioes on May 5, 2003 6:46:23 AM]

Share this post


Link to post
Share on other sites
It''s a known bug in MSVC. There''s nothing you can do in your code to make it go away

Just tell the compiler to shut up with:
#pragma warning(disable: 4786)
(Includes this before you include the stl headers)

Share this post


Link to post
Share on other sites
VS.NET does not suffer from this problem. You can disable the warning by typing:

#pragma warning(disable : 4786)

on the very first line of your .cpp file (before any includes.)

Share this post


Link to post
Share on other sites
Another point: getting rid of this warning in more complex projects is quite tricky. I have found that the following code, in a header file and included at the beginning of all your other headers works, mostly.

#ifndef _4786_h
#define _4786_h

#ifdef _YVALS
#error 4786.h must be included before any STL header
#endif
#pragma warning(disable: 4786)
#include <yvals.h>
#pragma warning(disable: 4786)

#endif

Share this post


Link to post
Share on other sites
quote:
Original post by Digitalfiend
VS.NET does not suffer from this problem. You can disable the warning by typing:

#pragma warning(disable : 4786)

on the very first line of your .cpp file (before any includes.)



I actually enclosed it with
  
#pragma warning ( push )
#pragma warning ( disable : 4786 )
...
#pragma warning ( pop )

In the header file requiring std::map

EDIT: [ source ] -> [ code ]

[edited by - Kurioes on May 5, 2003 11:32:06 AM]

Share this post


Link to post
Share on other sites