Reputation: 5336
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.
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
Since GCC usually provides 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>
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).
Can I mimic this behavior?
Upvotes: 30
Views: 55318
Reputation: 210515
I've found one way to mute it, and that is to move the offending code into an -isystem
header.
It's an incredibly unsatisfactory solution, but I thought I'd post it since it may be viable for some folks.
Upvotes: 1
Reputation: 140639
It's maybe a bit late for this, but one of these ought to do what you wanted:
#pragma GCC diagnostic ignored "-fpermissive"
or
#pragma GCC diagnostic ignored "-pedantic"
"ignored" is how you squelch a diagnostic entirely, and the inverse of -fpermissive
is -pedantic
, for historical reasons.
Upvotes: 15
Reputation: 5850
tldr: You cannot turn off the fpermissive output after GCC 4.7.
Just posting this here so it has more visibility: unfortunately, zwol's answer (while well-intentioned, and potentially helpful to those with older GCC versions) does not work for more recent versions of GCC. From GCC 4.8 and beyond, you cannot turn off the fpermissive output. o11c in his comment to the OP helpfully provides the following bug which tracks this:
Bug 81787. [5/6/7/8 Regression] #pragma GCC diagnostic warning "-fpermissive" no longer
Note that it is in the state "RESOLVED INVALID", so the inability to turn it off is the expected behavior and there are no plans to change it.
Upvotes: 20