首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为什么小弟我这样写vector<string> vec的时候,运行的时会有四个警告

2012-04-05 
为什么我这样写vectorstring vec的时候,运行的时会有四个警告?为什么我这样写vectorstring vec的时候,

为什么我这样写vector<string> vec的时候,运行的时会有四个警告?
为什么我这样写vector<string> vec的时候,运行的时会有四个警告?
这些警告分别为:

1.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::basic_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

2.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_string<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

3. 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

4.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

但是我这么写vector<char> vec的时候就不会有这样的警告,难道这么定义vector<string>不对吗?

[解决办法]
并不是错误,只是 Visual C++ 6 太陈旧了,无法在debug信息中保存超过256字节的变量名

在头文件中加上一行

#pragma warning(disable: 4786)

就可以关掉这些警告。
[解决办法]
珍惜生命,远离VC6
[解决办法]
from msdn
VC6的调试器不能处理长于255个字符的标识符。 
STL往往会自己产生一些长于255字符的标识符,所以会产生警告。 
如果要把这个警告禁用可以在程序开始处加上 
#pragma warning(disable:4786) 
你的标识符确实只有3个字符,但string和vector这两个STL模版会产生很长的标识符!
[解决办法]
珍惜生命,远离VC6.

热点排行