Andreas
Andreas

Reputation: 177

How can I suppress a "-fpermissive" error using modern GCC?

I am trying to compile some nonconforming code in C++17, but I am stuck with the following issue.

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-fpermissive"

Some code that compiles only when with -fpermissive flag is set:

#pragma GCC diagnostic pop

It compiles fine on GCC version 4.6.4 through 4.7.4, but all later versions of GCC are giving me the following warning and don't suppress the error.

warning: ‘-fpermissive’ is not an option that controls warnings [-Wpragmas]
#pragma GCC diagnostic ignored "-fpermissive"
When I write (out of desperation)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-fpermissive"

Some code that compiles only when with -fpermissive flag is set:

#pragma GCC diagnostic pop

I am back at square one. Currently I'd like to continue using GCC 7.1 for the project. I can compile the entire project with -fpermissive flag set as a compile option, but this means that some other section of code causing a -fpermissive error could compile.

Condensed example https://godbolt.org/g/KFd5Ke

This question is not a duplicate of In GCC, how can I mute the '-fpermissive' warning? as this is directed toward newer versions of GCC where the solution provided in the aforementioned Stack Overflow question does not work. I even included an example.

Upvotes: 3

Views: 7683

Answers (0)

Related Questions