`
aigo
  • 浏览: 2537774 次
  • 性别: Icon_minigender_1
  • 来自: 宜昌
社区版块
存档分类
最新评论

[C++]VS2015 update2的安全检测:decorated name length exceeded, name was truncated

阅读更多

vs2015 update 2对安全检测越来越严格了,以前很多只是warning的接口,现在都会直接给error,今天碰到了这种问题:

 

Error C4503 'std::_Hash<std::_Umap_traits<_Kty,_Ty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,false>>::_Insert': decorated name length exceeded, name was truncated

 

原因是我使用了多层嵌套的std::unordered_map(换成std::map则没有这种问题),嵌套了3层,就出现了上面的编译错误:编译时模版展开后的字符串长度超过了编译器的限制长度(255)。详情见:http://stackoverflow.com/questions/6880045/how-can-i-work-around-visual-c-2005s-decorated-name-length-exceeded-name-wa

 

如果是旧的VS版本,这里只是warning。

这里的error要去掉,头文件中添加:

#pragma warning(disable:4503)

 参考自:http://stackoverflow.com/questions/3994500/c4503-warnings-how-do-i-solve-get-rid-of-them

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics