在VC ++中找到导致警告4503的代码

时间:2015-03-05 11:18:23

标签: c++ debugging visual-studio-2012 warnings pragma

我试图在一个大代码库中追踪这个大型警告的来源:

C:\Program Files (x86)\Microsoft Visual Studio 12.\VC\INCLUDE\xmemory0(592) : 
warning C4503: 
'std::_Tree<std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,false>>::_Insert_at' : decorated name length exceeded, name was truncated
        with
        [
            _Kty=epmem_node_id,
            _Ty=std::map<std::string,std::list<std::string,std::allocator<std::string>>,std::less<std::string>,std::allocator<std::pair<const std::string,std::list<std::string,std::allocator<std::string>>>>>,
            _Pr=std::less<epmem_node_id>,
            _Alloc=std::allocator<std::pair<const epmem_node_id,std::map<std::string,std::list<std::string,std::allocator<std::string>>,std::less<std::string>, std::allocator<std::pair<const std::string,std::list<std::string,std::allocator<std::string>>>>>>>
        ]

我打算放下以下内容来保持沉默:

#pragma warning(push)
#pragma warning(disable:4503)
... code here
#pragma warning(pop)

但是,我一直把它放在代码库中,警告仍会弹出。不幸的是,警告没有指定问题所在的行,文件甚至类或变量,所以我完全迷失了。我尝试使用dumpbin /ALL,但是当我搜索文件时,我没有在任何地方找到_Tree

如何在我的代码库中找到此警告的来源?

1 个答案:

答案 0 :(得分:2)

我的问题是如何找到导致问题的代码行,但这实际上并不能解决我的问题。由于违规代码涉及模板化,{<1}}警告的修饰名称是在翻译单元中的其余代码处理后生成的,因此我无法包围任何给定一段带有cl / warnings(push)对的代码。

我的解决方案是将warning(pop)放在文件的末尾(我把它放在包含守卫的#pragma warning(disable:4503)之前)。这使得对使用tempaltes的文件中的结构生成的所有装饰名称的警告保持沉默。 #endif pragma的范围仅适用于当前的翻译单元,因此不会影响任何其他文件。