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

查看:395
本文介绍了使用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?

推荐答案

p> Jonathan,我想问题是你的源文件包括来自第三方库的头文件,你想关闭后者的警告。

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 ,我想你可以使用pragmas来控制警告: gcc诊断pragmas

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

您可以在第三方库的任何#include之前和之后添加这些。

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

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

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