当前位置:软件学习 > ISA >>

#pragma warning (disable : 4786)

(windows 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;
}
作者 “8023”

补充:软件开发 , C语言 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,