Archived

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

Compilation warnings

This topic is 5771 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have a class: class CID { string sName, sType; int iID; static int iCount; static map mIDRegistry; (...) and then: map CID::mIDRegistry; When I compile I get these warnings: c:\program files\microsoft visual studio\vc98\include\map(97) : warning C4786: ''std::reverse_bidirectional_iterator,std::map,std::allocator >::_Kfn,std::less,std::alloca tor >::iterator,std::pair,std::pair &,std::pair *,int>'' : identifier was truncated to ''255'' characters in the debug information c:\program files\microsoft visual studio\vc98\include\map(96) : while compiling class-template member function ''std::pair,std::map,std::allocator >::_Kfn,std::less,std::allocator >::iterator,bool> __thiscall std::map,std::allocator >::insert(const std::pair &)'' c:\program files\microsoft visual studio\vc98\include\map(97) : warning C4786: ''std::reverse_bidirectional_iterator,std::map,std::allocator Someone knows why this happens?? I would appreciate an awnser. Tks

Share this post


Link to post
Share on other sites
Heavily templated code results in long debug symbols being generated by the compiler. Since the debugger can''t handle debug symbols longer than 255 bytes, the compiler truncates them. That''s what the warning is about. There''s nothing you can do about it, so switch it off.

--
The placement of a donkey''s eyes in its head enables it to see all four feet at all times.

Share this post


Link to post
Share on other sites
I think this is possibly the most annoying warning MSVC can give you. (Who cares about that particular identifier being truncated, anyway?) To disable the warning, insert the following pragma at the top of the file you get it in (before any header includes):

#pragma warning ( disable : 4786 )

Be warned (no pun intended), though. MSVC doesn''t always disable the warning. I''ve had several cases where the error just wouldn''t go away and die...

Share this post


Link to post
Share on other sites
quote:
Original post by Kippesoep
(Who cares about that particular identifier being truncated, anyway?)


If you get that error, you will be unable to look at the symbol in the debugger. So if you have a vector of vector of vectors (that should get you over 255 characters), and you have an iterator going through the inner vector, you can''t watch it in the debugger. It''s a pain. So what I always do is dereference all iterators (using either a const reference or reference) and operate on that--it compiles-out in release and gives you visibility in debug.

quote:

Be warned (no pun intended), though. MSVC doesn''t always disable the warning. I''ve had several cases where the error just wouldn''t go away and die...



Known bug:
http://support.microsoft.com/support/kb/articles/Q167/3/55.ASP

Very annoying nonetheless. I think it has to do with having STL templates used in the precompiled headers in debug builds. We''ve had it in our bug list here for ages.

Share this post


Link to post
Share on other sites
Some of the standard headers, including Windows headers, turn warnings on and off themselves. They do it in an unfriendly way, which means that if you had a warning disabled, they may disable it again at the beginning of the header and then re-enable it at the end.

To avoid this, I include all my system headers in one master header file and use the ''push'' option on the warning pragma to save and restore my warning level:


// Disable annoyance warnings
#pragma warning( disable: 4786 ) // ID trunc''d to 255 chars
... // Disable other warnings
// Set warning level to 1 to avoid most warnings in sys headers
#pragma warning( push, 1 )
#include <windows.h>
... // Include whatever other headers
// Reset warning level to whatever I had it set to before
#pragma warning( pop )



--
Eric

Share this post


Link to post
Share on other sites