[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Compile warning

Posted on 2004-11-18
10
Medium Priority
?
596 Views
Last Modified: 2013-12-14
When I #include <map> to use a function that needs map<> I get following warning message during compilation.
These are kind of harmless message as I can compile. link and run my program.
But I want to eliminate these messages.
What should I do?



D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\utility(17) : warning C4786: '?$pair@Viterator@?$_Tree@HU?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@U_Kfn@?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$all
ocator@D@2@@std@@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N' : identifier was truncated to '255' cha
racters in the browser information
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : see reference to class template instantiation 'std::pair<class std::_Tree<int,struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::a
llocator<char> > >,struct std::map<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator
<char> > > >::_Kfn,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::iterator,bool>' being compiled
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : while compiling class-template member function 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &__thiscall std::map<int,class std::basic
_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::operator [](const int &)'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\utility(21) : warning C4786: '??0?$pair@Viterator@?$_Tree@HU?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@U_Kfn@?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$
allocator@D@2@@std@@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N@std@@QAE@XZ' : identifier was truncat
ed to '255' characters in the browser information
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : see reference to class template instantiation 'std::pair<class std::_Tree<int,struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::a
llocator<char> > >,struct std::map<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator
<char> > > >::_Kfn,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::iterator,bool>' being compiled
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : while compiling class-template member function 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &__thiscall std::map<int,class std::basic
_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::operator [](const int &)'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\utility(23) : warning C4786: '??0?$pair@Viterator@?$_Tree@HU?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@U_Kfn@?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$
allocator@D@2@@std@@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N@std@@QAE@ABViterator@?$_Tree@HU?$pair
@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@U_Kfn@?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@U?$less
@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@1@AB_N@Z' : identifier was truncated to '255' characters in the browser information
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : see reference to class template instantiation 'std::pair<class std::_Tree<int,struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::a
llocator<char> > >,struct std::map<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator
<char> > > >::_Kfn,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::iterator,bool>' being compiled
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : while compiling class-template member function 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &__thiscall std::map<int,class std::basic
_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::operator [](const int &)'
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\utility(25) : warning C4786: '??0?$pair@Viterator@?$_Tree@HU?$pair@$$CBHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@U_Kfn@?$map@HV?$basic_string@DU?$char_traits@D@std@@V?$
allocator@D@2@@std@@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@U?$less@H@2@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N@std@@QAE@ABU?$pair@$DCAB@$DCAC@@1@@Z'
 : identifier was truncated to '255' characters in the browser information
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : see reference to class template instantiation 'std::pair<class std::_Tree<int,struct std::pair<int const ,class std::basic_string<char,struct std::char_traits<char>,class std::a
llocator<char> > >,struct std::map<int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator
<char> > > >::_Kfn,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::iterator,bool>' being compiled
        D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\map(93) : while compiling class-template member function 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &__thiscall std::map<int,class std::basic
_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<int>,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >::operator [](const int &)'
Linking...
0
Comment
Question by:pbavishi
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1000 total points
ID: 12616187
You can safely igonore these warnings, since they only refer to the symbol name length when debugging your application. From the compiler docs:

Compiler Warning (level 1) C4786
'identifier' : identifier was truncated to 'number' characters in the debug information

The identifier string exceeded the maximum allowable length and was truncated.

The debugger cannot debug code with symbols longer than 255 characters. In the debugger, you cannot view, evaluate, update, or watch the truncated symbols.

This limitation can be overcome by shortening identifier names.  The example code below demonstrates this method.

A trace mechanism can also be used to solve this problem. A trace mechanism is like the printf statements in the code. It keeps track of what is going on in an application during the debugging process. The _ASSERT, _ASSERTE, _RPTn and _RPTFn macros provide concise and flexible ways to perform the trace. These macros are not defined when _DEBUG is not defined. See Using Macros for Verification and Reporting for more information.

The example below demonstrates a situation that would cause this compiler warning to occur, and the solution to this problem.

 //sample1.cpp
 //In this program we have a class of a very long name.
 //We instantiate an object of that class type. We will
 //get multiple C4786 warnings.  The comments below
 //demonstrate the solution to this problem.

 #define a_really_long_class_name a_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really_really//_really_long_class_name

 //SOLUTION: Uncomment the lines below

 //#ifdef _DEBUG
 //#define a_really_long_class_name A_SHORT_CLASS_NAME
 //#endif

 class a_really_long_class_name
 {
 public:
   a_really_long_class_name() {};
   int m_data;
 };

 void main()
 {
    a_really_long_class_name test_obj;
    test_obj.m_data = 12;
 }

The following example demonstrate that templates with some long class names as their parameters can easily exceed the 255 character limit. Solutions to the problem are also provided.

 //sample2.cpp
 //SOLUTION1: uncomment the next 4 lines
 //#ifdef _DEBUG
 //#define VeryLongClassNameA A
 //#define VeryLongClassNameB B
 //#endif

 //SOLUTION2: An alternative solution:
 //uncomment the next 3 lines.
 //#ifdef _DEBUG
 //#define SomeRandomClass SRC
 //#endif

 template <class A1, class A2, class A3, class A4>
 class VeryLongClassNameA{};

 template <class B1, class B2, class B3>
 class VeryLongClassNameB{};

 template <class C1, class C2>
 class VeryLongClassNameC{};

 template <class D1>
 class VeryLongClassNameD{};

 class SomeRandomClass{};

 typedef VeryLongClassNameD<SomeRandomClass> ClassD ;
 typedef VeryLongClassNameC<SomeRandomClass, ClassD> ClassC;
 typedef VeryLongClassNameB<SomeRandomClass, ClassC, ClassD> ClassB;
 typedef VeryLongClassNameA<SomeRandomClass, ClassB, ClassC, ClassD> ClassA;

 void SomeRandomFunction(ClassA aobj){}

 void main()
 {
   ClassA AObj ;
   SomeRandomFunction(AObj) ;
 }
0
 
LVL 86

Expert Comment

by:jkr
ID: 12616209
BTW, this documentation can also be found at http://msdn.microsoft.com/library/en-us/vccore98/html/c4786.asp ("Compiler Warning (level 1) C4786")
0
 
LVL 13

Expert Comment

by:SteH
ID: 12616299
Or you can use
#pragma warning (disable : 4786)
to disable the warning. Put it in a header file which gets included by all files where this occurs. This could be stdafx.h.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:pb_india
ID: 12618039
#pragma warning (disable : 4786)


Putting this didn;t help;
0
 
LVL 13

Expert Comment

by:SteH
ID: 12622723
I am using it succesfully. Is it in the include before the STL headers? If not change the order.
0
 

Author Comment

by:pbavishi
ID: 12628306
#pragma warning (disable : 4786)
#include <time.h>
#include <string>
#include <map>
using namespace std;

Still no good.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12628440
May I ask who is asking that question? pbavishi or pb_india?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question