Title: Re: [msvc] std::map and strings

Hi

> I have a group of data that is made up of pairs of strings.  I want to
read
> these pairs from a file, sort them into alphabetical order and then write
> them to a new file.  std::map seemed to be the perfect choice, but when I
> create a std::map<std::string, std::string> variable I get a bazillion
C4786
> warnings regarding identifiers being truncated to 255 characters in either
> debugging info or browser info.  Granted the code compiles, but all the
> warnings must indicate something that I should be doing differently.  Is
> there a better STL choice for what I am trying to accomplish?

To get rid of the warnings, create a file called disable4786.h and paste the
following into it:

/////////////////////////////
// disable4786.h

/*! \file disable4786.h
 * \brief disable4786 declaration file.
 */


#pragma warning(disable:4786)
/*! \class msVC6_4786WorkAround
 * \brief From Paul Hollingsworth, contributed to boost.org distribution
list
 * Added here by Phil Nash 31/10/2001
 *
 * http://support.microsoft.com/support/kb/articles/Q167/3/55.ASP
 * states that yes, it's a compiler bug that #pragma warning(disable: 4786)
 * doesn't always work.
 * They don't, however, list a workaround.
 * I found that, very strangely, #including <iostream> made the
 * remaining 4786 warnings go away!
 * Of course, #including <iostream> is inefficient and
 * slows compilation - so I whittled away most of what's in
 * <iostream> and discovered that the "active ingredient" in <iostream>
 * appears to be a declaration of a static class, complete with
 * default constructor.
 * For some reason, this works around the bug!
 * Why does this work? Beats me, ask those smart guys at MS who wrote the
 * compiler.
 */

class msVC6_4786WorkAround
{
public:
 //! MSVC6 4786 WorkAround
 msVC6_4786WorkAround() {}
};

static msVC6_4786WorkAround
 WowIWonderWhatCrapCodeMustBeInTheCompilerToMakeThisWorkaroundWork;

Then include the file at the top of each file which gives you the warning.

Regards
Paul

Paul Grenyer
Email: [EMAIL PROTECTED]
Web: www.paulgrenyer.co.uk

What do you mean you've never heard of Karnataka?

http://www.karnataka.org.uk

Reply via email to