如何消除GCC中的外部lib /第三方警告 [英] How to eliminate external lib/third party warnings in GCC

查看:295
本文介绍了如何消除GCC中的外部lib /第三方警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在开发的软件项目中,我们使用某些第三方库,不幸的是,产生恼人的gcc警告。
我们正努力清除所有警告代码,并希望在GCC中启用treat-warnings-as-errors(-Werror)标志。
有没有办法使这些第三方生成的警告,我们不能修复,消失?

In the software project I'm working on, we use certain 3rd party libraries which, sadly, produce annoying gcc warnings. We are striving to clean all code of warnings, and want to enable the treat-warnings-as-errors (-Werror) flag in GCC. Is there a way to make these 3rd party generated warnings, which we cannot fix, to disappear?

推荐答案

I假设你正在谈论来自第三方库头文件的警告。

I presume you are talking about the warnings coming from the 3rd party library headers.

GCC特定的解决方案是创建另一个包装头文件,它基本上有两行: / p>

The GCC specific solution would be to create another wrapper header file which has essentially the two lines:

#pragma GCC system_header
#include "real_3rd_party_header.h"

并使用包装器而不是原始的第三方标头。

And use the wrapper instead of the original 3rd party header.

检查另一个SO回复详细说明了pragma伪指令。它本质上告诉GCC这个(使用递归包含的文件)是一个系统头,不应该生成警告消息。

Check another SO response detailing the pragma. It essentially tells GCC that this (with recursively included files) is a system header, and no warning messages should be generated.

否则,我不知道禁用来自第三方代码的警告。除了强力当然:在构建系统配置要建立的警告关闭的文件。

Otherwise, I'm not aware how one can disable warnings coming from the 3rd party code. Except by the brute force of course: in the build system configure the files to be built with warnings off.

这篇关于如何消除GCC中的外部lib /第三方警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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