VC6使用STL时很多C4786警告
2011-02-17 17:38
288 查看
http://www.cnitblog.com/cockerel/archive/2006/06/12/12069.html
下面的代码编译时报告了一大堆愚蠢的 C4786 编译警告,足有十四个: f:/program files/microsoft visual studio/vc98/include/list(125) : warning C4786: '?$reverse_bidirectional_iterator@Viterator@?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@AAV43@PAV43@H' : identifier was truncated to '255' characters in the browser information E:/ /Exercise4/Exercise4.cpp(195) : see reference to class template instantiation 'std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >' being compiled 代码如下: #include <list> #include <string> using namespace std; list<string> myList; void main() { } 再比如, map<string,int> myMap 。 |
Answer:
这个警告的意思就是说, list<string> 的构造生成的 Symbols 太长了,超过了255个字符。 你其实不用理会这个警告,因为它只会影响到 Debugger ,而不会影响到真实的代码。实际上,如果你编译一个 Release 版本的话,就会发现这个警告已经完全消失了。 消除这个警告可能有一点难度,因为这属于预处理器的行为。 一般建议你这么做: #pragma warning(disable : 4786) #include <list> #include <string> 注意这个 pragma 声明一定要放在 stl 头文件之前!否则不起作用! 这个 pragma 也不是总能够发生效力的!有时候,并不能消除所有的这种 C4786 警告。 |
相关文章推荐
- VC6 STL使用时候很多warning, stl使用以及消除warning的方法如下
- VC6下使用STL注意:不要让内存分配失败导致您的旧版 STL 应用程序崩溃
- 屏蔽vc6使用STL容器时的warning
- VC6中使用STLPort4.6.2
- 对于很多公司不使用STL 引发的思考
- VC中使用STL出现的警告.
- VC6 之C4786 警告
- 当在使用STL时,VC有时会提出类似以下的警告:
- 在EVC下使用STL时的警告处理方法
- 避免VC报很多关于stl的警告
- 如何在VC6中使用SGI-STL
- VC6中使用STLPort4.6.2
- 不要使用VC6自带的STL
- wince下使用STL出现4786编译警告
- VC++ 如何隐藏使用STL而带来的大量警告
- STL 标准模板库 中栈stack 容器的使用
- STL中的list和vector使用(一)更正
- STL 优先队列、队列、栈的使用
- STL学习之stack使用
- STL中queue的使用