Making STL error messages understandable

Started by
17 comments, last by Qw3r7yU10p! 20 years ago
Newbies are often overwhelmed by the enormous and incomprehensible errors that can be reported from making a mistake using STL. I'm sometimes at a loss too but usually have a clue as to what documentation I need to be looking at to work it out. I thought I'd point you in the direction of STLFilt: An STL Error Message Decryptor for C++. You can integrate it into VC++6 and 7 quite easily (it'll work with many other platforms too) If you get a tricky error message you can just hit a button and it strips out all the non-essential stuff which usually isn't the cause of the error. Leor Zolman, who developed it, used it while helping Scott Meyers with the code examples for his book, Effective STL. This tool is helpful for everyone I think. Pete [edited by - petewood on March 30, 2004 4:25:38 AM]
Advertisement
STL error messages arn''t that bad, the details are there for a reason.
Mostly STL errors ar full of redundant information. The first few words are the only important ones. The rest are usually nested templated defintions which can easily run over 255 characters.

-ddn
quote:Original post by Anonymous Poster
STL error messages arn't that bad, the details are there for a reason.


Can we get rid of anonymous posters? I'd like to have a conversation with someone I know. It will help to develop more of a sense of respect, help us see how people are developing, give us confidence in each others replies and a history together on the site.

Or, would it be possible for a topic starter to choose whether or not anonymous posters are able to post replies to their topic.

#include <map>#include <string>int main(){    using namespace std;    multimap<string, int> mm;    mm.insert(0);    return 0;}


gives this error message:
error.cpp(16) : error C2664: 'class std::_Tree<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>,struct std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::_Kfn,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::iterator __thiscall std::multimap<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<int> >::insert(const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &)' : cannot convert parameter 1 from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &' Reason: cannot convert from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>' No constructor could take the source type, or constructor overload resolution was ambiguous


In reply to the AP, the details are there because the compiler writers haven't caught up yet with what the pertinent details are that will help people find the cause of the error. They just dump out everything. It is the easiest thing they can do.

[edited by - petewood on March 31, 2004 3:36:07 AM]
quote:Original post by petewood

Can we get rid of anonymous posters? I''d like to have a conversation with someone I know.


You feel you know someone just because they have a board name?

quote:

gives this error message:
   error.cpp(16) : error C2664: ''class std::_Tree&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt;,struct std::multimap&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::_Kfn,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::iterator __thiscall std::multimap&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int,struct std::less&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; &gt;,class std::allocator&lt;int&gt; &gt;::insert(const struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &)'' : cannot convert parameter 1 from ''const int'' to ''const struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt; &'' Reason: cannot convert from ''const int'' to ''const struct std::pair&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const ,int&gt;'' No constructor could take the source type, or constructor overload resolution was ambiguous



The error message is simple enough, just ignore the bits you do not need.

cannot convert parameter 1 from ''const int'' to ''const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &'' Reason: cannot convert from ''const int'' to ''const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>'' No constructor could take the source type, or constructor overload resolution was ambiguous


quote:Original post by Anonymous Poster
quote:Original post by petewood

Can we get rid of anonymous posters? I'd like to have a conversation with someone I know.


You feel you know someone just because they have a board name?



You've said a lot of stupid things in the past but that beats them all.

quote:The error message is simple enough, just ignore the bits you do not need.
cannot convert parameter 1 from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int> &' Reason: cannot convert from 'const int' to 'const struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,int>' No constructor could take the source type, or constructor overload resolution was ambiguous


Right...

STLFilt produces this
error.cpp(16) : error C2664: 'iter multimap<string,int>::insert(pair<string,int> &)': cannot convert parameter 1 from 'const int' to 'pair<string,int> &'Reason: cannot convert from 'const int' to 'const pair<string const,int>'No constructor could take the source type, or constructor overload resolution was ambiguous


[edited by - petewood on March 31, 2004 4:48:01 AM]
quote:You''ve said a lot of stupid things in the past but that beats them all.


How so?


quote:
STLFilt produces this


Whats the point in it then? doesn''t add anything to the compiler error message. It also takes away information which others may find useful.
quote:Original post by Anonymous Poster
quote:
STLFilt produces this


Whats the point in it then?


Moderators, what should I do about this AP? They''re pretending to not understand why I''ve started this thread and are making out that there is nothing helpful in what I am talking about. They''re being deliberately provocative. I know the general rule is to just ignore them. But the thing is there is a person hiding behind the Anonymous Poster who I want to treat with respect. I don''t like being ignored and I believe in community. I don''t believe in just pretending something isn''t there. I believe in dealing with things.

AP, use STLFilt if you find it helpful. If you don''t then maybe others will. It only filters the error messages if you want it to (by clicking on the button for example). If you want the detail just don''t push the button.
I dunno, this is sort of akin to how folks up in arms over Mel Gibson''s movie just help increase his box office numbers...

And I''ll take someone obviously clueless any day over the ones who complain about STLFilt crashing their machines, only to disappear without a trace when I try to track them down in order to get more information so that I might have a chance to help them with their problem... ;-)

Thanks for helping to spread the word.
-leor


--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software''''s free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
-- Leor Zolman --- BD Software --- www.bdsoft.comOn-Site Training in C/C++, Java, Perl and Unix C++ users: Download BD Software''s free STL Error Message Decryptor at: www.bdsoft.com/tools/stlfilt.html
quote:Original post by petewood
Moderators, what should I do about this AP? They''re pretending to not understand why I''ve started this thread and are making out that there is nothing helpful in what I am talking about. They''re being deliberately provocative. I know the general rule is to just ignore them. But the thing is there is a person hiding behind the Anonymous Poster who I want to treat with respect. I don''t like being ignored and I believe in community. I don''t believe in just pretending something isn''t there. I believe in dealing with things.


Why do you keep talking to moderators in your posts? If you have something to say then message them directly.

It''s not that im pretending not to understand why you started this thread, its that i really don''t understand. If someone had asked for a tool that helps decode STL messages, then i could see the point. But what is the purpose of this thread? To help ''Newbies'' with something that they have not even asked for help with? If everyone posted advice about something that ''Newbies'' would have trouble with then the board would be flooded with 100000s of posts.

If people were really that interested in decoding STL errors, they would search google, we do not need you posting advice that noone has asked for IMHO.

This topic is closed to new replies.

Advertisement