Detailed description of VC ++ warning c4786

Source: Internet
Author: User

When STD: List is used, the compiler reports the following warning:

Warning c4786: 'std: reverse_bidirectional_iterator <STD: List <STD: basic_string <char, STD: char_traits <char>, STD: Allocator <char>, STD:: Allocator <STD: basic_string <char, STD: char_traits <char>, STD: alloca

Tor <char >>>:: iterator, STD: basic_string <char, STD: char_traits <char>, STD: Allocator <char>, STD :: basic_string <char, STD: char_traits <char>, STD: Allocator <char >>&, STD: basic_string <char, STD: char_traits <char>, STD :: allocator <char> *, int> ': iden

Tifier was truncated to '000000' characters in the debug information

This warning is generated because the identifier is too long and exceeds the limit of 255 characters. For example: # 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 _/ Bytes   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;
}
If the class name exceeds 255 characters, 4786 Waring is reported during use. When using STL (C ++ Standard Template Library), it often causes similar errors, especially the template classes such as vector and map. The template contains a set of templates, which is too long if you are not careful. For example: 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 );
}
There are two solutions: one is to define the alias directly:# Ifdef _ debug
# Define verylongclassnamea
# Define verylongclassnameb
# Endif

The other is to block 4786 warning:# Pragma warning (Disable: 4786)Note that the blocking statement must be placed before the reference declaration of the error template class (for example, # include <vector>); otherwise, it still does not work.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.