Conditionally disable warnings with qmake/gcc?(使用 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 有条件地禁用警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 qmake/gcc 有条件地禁用警告?


基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 初始化列表*参数*评估顺序 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01