Compiler warnings with STL maps

Started by
8 comments, last by RTH 20 years, 11 months ago
This is my first attempt at using anything from the STL library. When I try to use maps, I get about 100 warnings when I compile. I am using Visual Studio 6.0 and haven't changed any project settings. I tried to compile some code I found on a tutorial and it gave me the same warnings. Even this simple code gives me warnings: #include <iostream> #include <map> #include <string> using namespace std; int main() { map < string, int > myMap; return 0; } Anyone have any thoughts as to why this is happening? [edited by - RTH on April 28, 2003 12:37:57 AM]
Advertisement
Not if you don't tell us what the warnings are.

EDIT: well, actually, yeah, I do. But first I want to verify; and besides, you could use the experience.

How appropriate. You fight like a cow.

[edited by - sneftel on April 28, 2003 12:38:50 AM]
It''s this one over and over:

warning C4786:
''std::_Tree,std::allocator >,std:air,std::allocator > const ,
int>,std::map,std::allocator >,int,std::less,std::allocator > >,std::allocator >::_Kfn,std::lessr>,std::allocator > >,std::allocator >'' : identifier was truncated to ''255'' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation ''std::_Tree,std::allocator >,std:airchar>,std::allocator > const ,int>,std::map,std::allocator >,int,std::less,std::allocator > >,std::allocator >::_Kfn,std::lesssic_string,std::allocator > >,std::allocator >'' being compiled
h:\compsci\textrpg\myrpg.cpp(11) : see reference to class template instantiation ''std::map,std::allocator >,int,std::less,std::allocator
> >,std::allocator >'' being compiled
Yup, that''s what I figured.

This isn''t really a problem. It simply means that the template arguments for the map expanded to a hugely long string (mostly because of all the traits and allocators). You don''t really have to worry about it. If it bugs you, put this in your source file, before you declare your map:

#pragma warning(disable:4786)

How appropriate. You fight like a cow.
This question comes up so many times.

The way I found out what this warning meant and how to deal with it was by reading the documentation. In the editor highlight the error number by double clicking on it and press F1. If you don''t have the MSDN documentation on your machine go to msdn.microsoft.com and type it in there

How else do you think people know what these messages mean? It''s not as though some people ''just know''.
I guess you''re using MS Visual Studio C++ 6.0, I did too when I learned C++. I had a standard C++ book and had a lot of problems to compile the code, but you learn a lot from this, at least I did :D
You will get the same type of strange errors if you use for example the vector.
If you can try to get a copy of 7.0 instead, they have fixed a lot of these annoying warnings there and it follows the standard much better.
It''s not that easy to understand for example warning C4786 if you''re new to C++ even if you find the entry inte the documentation. For example how many beginners know what "symbols with decorated names" are? At least I didn''t know when I was a beginner...
quote:For example how many beginners know what "symbols with decorated names" are? At least I didn''t know when I was a beginner...


And how did you find out? Did you read it somewhere?
Yes I read it somewhere... But my point was that when you''re a beginner there are a lot of concepts to grasp and you''ll not always have all the knowledge you need to understand what you find in the documentation, don''t you agree?
Being a beginner can be overwhelming. One of the main lessons to learn is that you are capable of learning, that you can find information yourself. I remember being eight years old and being taught how to use the school library. That was an amazing experience - I was no longer overwhelmed by this room of books.

RTH has only just registered and this is his or her first post to the forums. Maybe I should have been a little gentler.

There is a beginners forum if you really are a beginner.
I agree petewood,
one of the most important thing you need to learn as a programmer is to find the information

This topic is closed to new replies.

Advertisement