问题
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)
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?
回答1:
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.
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.
来源:https://stackoverflow.com/questions/28876621/find-code-causing-warning-4503-in-vc