c – 如何在第三方库中预警C4505?

前端之家收集整理的这篇文章主要介绍了c – 如何在第三方库中预警C4505?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用Crypto进行几个散列函数的项目.最近,我决定清理一些东西,并在MSVC上使用警告级别4.

这是我的资料来源:

#pragma warning(push)
#pragma warning(disable: 4100) //Unreferenced formal parameter
#pragma warning(disable: 4244) //Conversion,possible loss of data
#pragma warning(disable: 4512) //Assignment operator could not be generated
#pragma warning(disable: 4127) //Conditional expression is constant
#pragma warning(disable: 4505) //Unreferenced local function has been removed
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include <cryptopp/md5.h>
#include <cryptopp/sha.h>
#pragma warning(pop)

尽管禁用:4505,我仍然收到此警告:

c:\cppdev\cryptopp561\cryptopp\misc.h(548): warning C4505: 'CryptoPP::StringNarrow' : unreferenced local function has been removed

我的项目没有建立.

我该如何解决这个问题?基本上,我只想禁用第三方代码的警告;我不想编辑cryptopp本身来修复错误,如果我可以避免这样做.

解决方法

完成解析编译的源文件后,编译器只能确定未引用的函数.将相应的#pragma disable移出push / pop范围,使其在文件末尾仍然有效:
#pragma warning(push)
#pragma warning(disable: 4100) //Unreferenced formal parameter
#pragma warning(disable: 4244) //Conversion,possible loss of data
#pragma warning(disable: 4512) //Assignment operator could not be generated
#pragma warning(disable: 4127) //Conditional expression is constant
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include <cryptopp/md5.h>
#include <cryptopp/sha.h>
#pragma warning(pop)
#pragma warning(disable: 4505) //Unreferenced local function has been removed
原文链接:https://www.f2er.com/c/113052.html

猜你在找的C&C++相关文章