使用 qmake/gcc 有条件地禁用警告? [英] Conditionally disable warnings with qmake/gcc?

查看:66
本文介绍了使用 qmake/gcc 有条件地禁用警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参与了一个用 Qt 编写并在 Linux 上使用 qmake 和 gcc 构建的软件项目.我们必须链接到一个质量相当低并且会发出大量警告的第三方库.我想在我们的源代码上使用 -W -Wall,但是将 -w 传递给讨厌的第三方库,以保持控制台没有噪音和混乱,这样我们就可以专注于我们的代码质量.

I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality.

在 qmake 中,有没有办法有条件地将 CFLAGS/CXXFLAGS 添加到某些文件和库中?

In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries?

推荐答案

Jonathan,我认为问题在于您的源文件包含来自 3rd 方库的头文件,并且您想关闭后者的警告.

Jonathan, I think the problem is where your source files are including header files from 3rd party libraries, and you want to switch off the warnings for the latter.

Kevin,我认为您可以使用编译指示来控制警告:gcc 诊断编译指示

Kevin, i think you can use pragmas to control warnings : gcc diagnostic pragmas

您可以在任何#includes 之前和之后为 3rd 方库添加这些内容.

You could add these before and after any #includes for 3rd party libs.

这篇关于使用 qmake/gcc 有条件地禁用警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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