--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:/1prg/Microsoft Visual Studio/prg/menu/Cpp1.cpp(13) : warning C4786: 'std::reverse_iterator<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; const *,std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >;,std::basi
c_string<char,std::char_traits<char>;,std::allocator<char>; >; const &,std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; const *,int>;' : identifier was truncated to '255' characters in the debug information
D:/1prg/Microsoft Visual Studio/prg/menu/Cpp1.cpp(13) : warning C4786: 'std::reverse_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_stri
ng<char,std::char_traits<char>;,std::allocator<char>; >; &,std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; *,int>;' : identifier was truncated to '255' characters in the debug information
d:/1prg/microsoft visual studio/common/vc98/include/vector(47) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >;,std::allocator<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; >; >;
::vector<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >;,std::allocator<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; >; >;' : identifier was truncated to '255' characters in the debug information
d:/1prg/microsoft visual studio/common/vc98/include/vector(60) : warning C4786: 'std::vector<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >;,std::allocator<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; >; >;
::~vector<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >;,std::allocator<std::basic_string<char,std::char_traits<char>;,std::allocator<char>; >; >; >;' : identifier was truncated to '255' characters in the debug information
Linking...
Cpp1.exe - 0 error(s), 4 warning(s)
在VC 6.0 上使用 STL 的时候会出现这种警告。是由于C++在内部生成的变量名超过了 255 个字符所致,在测试(Debug)版本中编译器限制生成的变量名的最大长度。一般可以忽略这类错误,想屏蔽它可以使用 #pragma warning (disable: 4786)。
你其实不用理会这个警告,因为它只会影响到Debugger,而不会影响到真实的代码。实际上,如果你编译一个Release版本的话,就会发现这个警告已经完全消失了。
消除这个警告可能有一点难度,因为这属于预处理器的行为。
一般建议你这么做:
#pragma warning(disable : 4786)
#include <string>
#include <vector>
注意这个pragma声明一定要放在stl头文件之前!否则不起作用!
这个pragma也不是总能够发生效力的!有时候,并不能消除所有的这种C4786警告。
详情参见:
http://support.microsoft.com/support/kb/articles/Q167/3/55.ASP
微软声称,将在Microsoft Visual C++ .NET中解决这个问题。