找到导致VC ++中的警告4503的代码 [英] find code causing warning 4503 in VC++

查看:361
本文介绍了找到导致VC ++中的警告4503的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to track down the source of this large warning in a big code base:

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>>>>>>>
        ]

我打算放入以下内容使其沉默:

I am planning on putting in the following to silence it:

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

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

However, I keep putting this in the code base and the warning still pops up. The warning, unfortunately, does not specify what line, file or even class or variable the problem is found in, so I am completely lost. I tried using dumpbin /ALL, but when I searched the file I did not find _Tree anywhere.

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

How can I locate the source of this warning in my code base?

推荐答案

我的问题是如何找到哪一行代码导致问题,但这实际上不会解决我的问题。由于违规代码涉及到模板,因此在之后生成 cl 警告的装饰名称,处理翻译单元中的其余代码,所以我无法使用警告(push) / warning(pop)环绕任何给定的代码段对

My question was how to find which line of code is causing the problem, but that wouldn't actually solve my problem. Since the offending code involves templating, the decorated name which cl warns about is generated after the rest of the code in the translation unit is processed, and so I would not be able to surround any given piece of code with a warnings(push)/warning(pop) pair.

我的解决方案是在末尾添加 #pragma warning(disable:4503)文件(我把它放在包围守卫的 #endif 之前)。这样就可以使用tempaltes文件中的结构生成的所有装饰名字的警告。 警告(...) pragma的范围只是当前的翻译单位,所以这不影响任何其他文件。

The solution for me was to put #pragma warning(disable:4503) at the end of the file (I put it just before the #endif of the include guard). This silences the warning for all decorated names generated from structures in the file which use tempaltes. The scope of a warning(...) pragma is just to the current translation unit, so this doesn't affect any other files.

这篇关于找到导致VC ++中的警告4503的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆