我如何在第三方库中警告C4505? [英] How can I work around warning C4505 in third party libraries?

查看:1193
本文介绍了我如何在第三方库中警告C4505?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目使用Crypto ++的几个哈希函数。最近,我决定清理一些东西,并在MSVC ++上使用警告级别4.

I've got a project that uses Crypto++ for a few hashing functions. Recently, I decided to clean things up a bit and use warning level 4 on MSVC++.

这里是我的源码:

#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)

尽管 / code>,我仍然收到此警告:

Despite disable: 4505, I still get this warning:

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

我的项目不生成。

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

How can I work around this? Basically, I'd just like to disable the warning for third party code; I don't want to be editing cryptopp itself to fix the error if I can avoid doing so.

推荐答案

编译器只能在完成解析已编译的源文件之后确定未引用的函数。将相应的 #pragma disable 移出推送/弹出范围,以使其仍然在文件结尾处生效:

The compiler can only determine unreferenced functions after it finished parsing the compiled source file. Move the corresponding #pragma disable out of the push/pop scope so it will still be in effect at the end of the file:

#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

这篇关于我如何在第三方库中警告C4505?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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