How do I disable a gcc warning which has no command line switch?

For a direct answer to the posed question:

As can be seen from GCC's source code, there is no (semi-)specific switch to disable this warning. It seems to only be disabled by disabling all warning (-w) or including the offending code as system header via -isystem, both of which are non-specific in the suppressed warnings.

There is a related open bug report on GCC here and an open meta-bug for similar cases of warnings without switches here.

If you don't want to use the two non-specific suppression mechanisms, then you probably will have to patch in an additional flag to GCC or wait for the bugs to be worked on in order to disable this specific warning.


There're hundreds of instances of this warning and they flood the compiler output. Hard to ignore.

If this is external library there is way to reduce this warning to single warring report. I'm suspecting that you can live with single warning message.

Wrap this library API with your own functions/methods. You can name them 1:1 using different namespace to avoid complex modification of own code where this API is used. This way this warning will be reported only when source including problematic header file is included. Aim is to include problematic header file only once.

Depending how this API looks like it may be harder to do.

Anyway if this is third party library then this approach will make it easier to mock that library and write test for your code.