gpt4 book ai didi

c++ - 在 VC++ 中查找导致警告 4503 的代码

转载 作者:行者123 更新时间:2023-11-30 03:55:48 26 4
gpt4 key购买 nike

我正试图在大型代码库中追踪此大型警告的来源:

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

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

最佳答案

我的问题是如何找到导致问题的代码行,但这实际上并不能解决我的问题。由于有问题的代码涉及模板,cl 警告的修饰名称​​在翻译单元中的其余代码被处理后生成,所以我无法用 warnings(push)/warning(pop) 对包围任何给定的代码。

我的解决方案是将 #pragma warning(disable:4503) 放在文件末尾(我把它放在 include 的 #endif 之前 guard )。这将使所有从使用模板的文件中的结构生成的修饰名称的警告静音。 warning(...) pragma 的范围仅限于当前翻译单元,因此这不会影响任何其他文件。

关于c++ - 在 VC++ 中查找导致警告 4503 的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28876621/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com