(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;
- }
转载于:https://blog.51cto.com/vfisher/668450