使用 qmake/gcc 有条件地禁用警告?

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)