STL编译告警,求帮助

lxb365 2010-07-29 06:57:46
在VC6里,输入了一段很简单的代码


#include "stdafx.h"
#include "stdio.h"

#include <map>

using std::map;

map<int,int> counter;
void main()
{
}


但是编译却出了很多告警,大家帮我看看,是怎么回事?

--------------------Configuration: test pro - Win32 Debug--------------------
Compiling...
test pro.cpp
F:\test pro\test pro.cpp(11) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::iterator,std::pair<int cons
t ,int>,std::pair<int const ,int> &,std::pair<int const ,int> *,int>' : identifier was truncated to '255' characters in the debug information
F:\test pro\test pro.cpp(11) : warning C4786: 'std::reverse_bidirectional_iterator<std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator,std::pair<in
t const ,int>,std::pair<int const ,int> const &,std::pair<int const ,int> const *,int>' : identifier was truncated to '255' characters in the debug information
F:\test pro\test pro.cpp(11) : warning C4786: 'std::pair<std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::iterator,std::_Tree<int,std::pair<int const ,int>,std
::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::iterator>' : identifier was truncated to '255' characters in the debug information
F:\test pro\test pro.cpp(11) : warning C4786: 'std::pair<std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator,std::_Tree<int,std::pair<int const ,in
t>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::const_iterator>' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(182) : warning C4786: 'std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::~_Tree<int,std::pair<int co
nst ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
c:\program files\microsoft visual studio\vc98\include\xtree(162) : warning C4786: 'std::_Tree<int,std::pair<int const ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >::_Tree<int,std::pair<int con
st ,int>,std::map<int,int,std::less<int>,std::allocator<int> >::_Kfn,std::less<int>,std::allocator<int> >' : identifier was truncated to '255' characters in the debug information
Linking...

test pro.exe - 0 error(s), 6 warning(s)
...全文
144 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxlovec 2010-07-30
  • 打赏
  • 举报
回复
这个我会
这招很灵的
在StdAfx.h中添加#pragma warning(disable: 4786)
ForestDB 2010-07-30
  • 打赏
  • 举报
回复
这就是为什么“珍惜生命,远离VC(6)”的原因。
(VC6.0做别的还是可以的。)
Kevin_Perkins 2010-07-29
  • 打赏
  • 举报
回复
使用STL需要很多经验和很深的功底。一般情况下,报告的错误和警告都没有什么参考意义,只能自己分析逻辑。
skyworth98 2010-07-29
  • 打赏
  • 举报
回复
sp, 都啥年代了,还在用那个老掉牙的东西,当然,总比那些还在用TC的好

[Quote=引用 9 楼 taodm 的回复:]
珍惜生命,远离vc6
[/Quote]
taodm 2010-07-29
  • 打赏
  • 举报
回复
珍惜生命,远离vc6
genlic 2010-07-29
  • 打赏
  • 举报
回复
学习了~
dawei_sun 2010-07-29
  • 打赏
  • 举报
回复
不用管它。DEBUG信息里面标识符最大只支持255个。而STL超过了这个数,所以报警,不用管它。
也可以在前面加上
#pragma warning(disable: 4786)
黑泡泡选手 2010-07-29
  • 打赏
  • 举报
回复
都是警告信息啊·~~
太乙 2010-07-29
  • 打赏
  • 举报
回复
#pragma warning(disable: 4786)

放在第一行~~~~~~~
  • 打赏
  • 举报
回复
VC出来的时候,STL还不是很完善,所以VC6对STL的支持不是很好,建议楼主换个编译器
pengzhixi 2010-07-29
  • 打赏
  • 举报
回复
你最好换个编译器
Longerandlonger 2010-07-29
  • 打赏
  • 举报
回复
模板类的信息就是复杂
ayw215 2010-07-29
  • 打赏
  • 举报
回复
vc6 对stl支持的非常不好
换vs2008
代码静态分析工具PC-LINT安装配置 PC-Lint是C/C++软件代码静态分析工具,你可以把它看作是一种更加严格的编译器。它不仅可以检查出一般的语法错误,还可以检查出那些虽然符合语法要但不易发现的潜在错误。 C语言的灵活性带来了代码效率的提升,但相应带来了代码编写的随意性,另外C编译器不进行强制类型检查,也带来了代码编写的隐患。PCLint识别并报告C语言中的编程陷阱和格式缺陷的发生。它进行程序的全局分析,能识别没有被适当检验的数组下标,报告未被初始化的变量,警告使用空指针,冗余的代码,等等。软件除错是软件项目开发成本和延误的主要因素。PClint能够帮你在程序动态测试之前发现编码错误。这样消除错误的成本更低。 使用PC-Lint在代码走读和单元测试之前进行检查,可以提前发现程序隐藏错误,提高代码质量,节省测试时间。并提供编码规则检查,规范软件人员的编码行为。 由于PC-LINT对于一般程序员来说可能比较陌生,有好多人安装了也不知道怎样配置和使用。 下面我就根据自己的安装和配置心得对PC-Lint的安装、配置及使用进行下详细说明.本人主要介绍了将PC-Lint集成到VC++6.0和SourceInsight的方法和步骤。 (一)Windows下C/C++开发工具中,VC6使用较为普遍,因此这里先讲下VC6.0环境中集成pclint的步骤. 首先, 当然要下载软件,正版软件要200多$呢,买不起!所以只好网上找免费的拉。从http://www.61ic.com/down/othe/pclint.rar处可以下载到一个8.0版本的pclint. 1.将pclint.rar解压至c:\, 这样lint文件就位与c:\pclint(安装目录)下了。 2.将c:\pclint\lnt 下的3个文件lib-w32.lnt,env-vc6.lnt,co-msc60.lnt拷贝至c:\pclint下, 再在安装目录下创建std.lnt和options.lnt两个文件,其中std.lnt的内容如下 // contents of std.lnt c:\pclint\co-msc60.lnt c:\pclint\lib-w32.lnt c:\pclint\options.lnt -si4 -sp4 -i"D:\Program Files;D:\Program Files\Microsoft Visual Studio\VC98\Include" //end 其中-i后面的路径名为VC的安装路径和VC Include 文件路径,根据自己的修改便可。 options.lnt 内容可为空,为定制内容,以后需要时再添加。 准备工作做完了,下一步就是要将pclint集成到VC6中去,先配置lint使之能对单个C或C++文件进行检查。 1.打开VC6,tools--->customize-->tools 新建一个名为pclint的项,在下面填入 command: C:\pclint\lint-nt.exe arguments: -u c:\pclint\std.lnt c:\pclint\env-vc6.lnt "$(FilePath)" Use Output Window 打上勾 close 完成。 这个在你VC窗口tools菜单下应该多了一个pclint选项,可以用它来运行lint程序,对你的c/c++代码进行静态检查了。 现在就可以用个小程序测试一下pclint了 //test1.cpp #include class X { int *p; public: X() { p = new int[20]; } void init() { memset( p, 20, 'a' ); } ~X() { delete p; } }; 编译这个文件,看下你的编译器给你多少警告,再运行下lint, 可以自己对比一下。 我的机器上,VC产生0 errors 0 warnings, 而lint程序产生了如下8条警告信息,有些还是很有用处的提示,这里就不一一分析了. test.cpp(12): error 783: (Info -- Line does not end with new-line) test.cpp(7): error 1732: (Info -- new in constructor for class 'X' which has no assignment operator) test.cpp(7): error 1733: (Info -- new in constructor for class 'X' which has no copy constru

64,643

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧