问题描述
我包括来自第三方库的文件,该文件引发可以降级为 -fpermissive
的警告的错误。但因为我不想污染我的编译日志与这些警告,我想完全禁用此消息。
I am including a file from a third-party library that raises an error that can be downgraded to a warning with -fpermissive
. But because I do not want to "pollute" my compilation log with these warnings, I want to completely disable this messages.
到目前为止,我设置 -fpermissive
选项与当包括文件时;例如:
So far, I set the -fpermissive
option with a diagnostic pragma when including the file; something like:
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-fpermissive"
#include <third-party-file.h>
#pragma GCC diagnostic pop
因为gcc通常提供 和否定版本的 -f
标志,我想到忽略不允许功能:
Since gcc usually provide both a "positive" and "negative" version of the -f
flags, I thought about ignoring the "no-permissive" feature:
#pragma GCC diagnostic ignored "-fno-permissive"
#include <third-party-file.h>
但是似乎没有否定版本的 fpermissive
标志(我使用gcc 4.6.3;但是即使是4.7.0版本)。
But there does not seem to be a "negative" version of the -fpermissive
flag (I am using gcc 4.6.3; but even the version 4.7.0 does not have it).
任何机会,我可以模仿这种行为吗?
Any chance I can mimic this behavior? Thanks!
推荐答案
这可能有点晚了,但其中一个应该做你想要的:
It's maybe a bit late for this, but one of these ought to do what you wanted:
#pragma GCC diagnostic ignored "-fpermissive"
或
#pragma GCC diagnostic ignored "-pedantic"
ignored是如何彻底压制诊断程序,以及 -fpermissive
是 -pedantic
,因为历史原因。
"ignored" is how you squelch a diagnostic entirely, and the inverse of -fpermissive
is -pedantic
, for historical reasons.
这篇关于在gcc,如何静音-fpermissive警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!