您的位置:首页 > 其它

#pragma warning (disable : 4786)

2013-06-11 15:45 295 查看
参考一

#pragma warning (disable : 4786)

( xp + VC6.0) 编译如下程序,初始化vector,在 容器中放入10个hello: #include stdafx.h #include vector using namespace std; int main(int argc, char* argv[]) { vectorstring vecStr(10, hello); return 0; } 编译后出现如下错误: warning C4786: s

( xp + VC6.0)

编译如下程序,初始化vector,在 容器中放入10个“hello”:

#include "stdafx.h"

#include <vector>

using namespace std;

int main(int argc, char* argv[])

{

vector<string> vecStr(10, "hello");

return 0;

}

编译后出现如下错误:

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> >,s

td::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

这是模板展开后名字太长引起的!!!

标识符字符串超出最大允许长度,因此被截断。

调试器无法调试符号超过 255 个字符长度的代码。无法在调试器中查看、计算、更新或监视被截断的符号。

缩短标识符名称可以解决此限制。

解决办法如下:

在#include "stdafx.h"下一行加入

#pragma warning (disable : 4786)

完整程序为:

#include "stdafx.h"

#pragma warning (disable : 4786)

#include <vector>

using namespace std;

int main(int argc, char* argv[])

{

vector<string> vecStr(10, "hello");

return 0;

}

参考二

vc6用map库为什么会有很多warning?#include <iostream>

#include <vector>

#include <string>

#include <map>

void main()

{

using namespace std;

map<string,string> trans_map;

typedef map<string,string>::value_type valType;

trans_map.insert(valType("gratz","grateful"));

trans_map.insert(valType("'em","them"));

trans_map.insert(valType("cuz","cause"));

trans_map.insert(valType("nah","no"));

trans_map.insert(valType("sez","sees"));

//输出map

map<string,string>::iterator it;

cout<<"显示输出map:\n";

for(it=trans_map.begin();it!=trans_map.end();it++)

{

cout<<"key:"<<(*it).first<<"\t"

<<"value:"<<(*it).second<<endl;

}

cout<<endl;

}

#pragma warning(disable:4715)

#pragma warning(disable:4390)

#pragma warning(disable:4786)

vc6对stl的支持不好。

基本上都是报4786警告。

可以用#pragma warning(disable:4786)把警告去掉。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: