I've learned that I can put
#pragma GCC diagnostic ignored "<warning>"
to the top of a source file in order to suppress warnings related to this particular source file. However, it seems that some names are not specific enough. For example,
#pragma GCC diagnostic ignored "-Wwrite-strings"
does not prevent gcc (4.7.2) from displaying warning messages whose exact names are not given, instead, these messages are followed only by [enabled by default]. I guess I need to know the correct warning names so I can use them in the #pragma
line. I've tried
-fdiagnostics-show-option,
but the warnings are then still displayed as [enabled by default].
Is there any way to identiy these warnings or to alternatively suppress warnings related to a specific source file?
Thank you very much!
You have to push and pop diagnostic states. Like this:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
/* ignoring warning */
int unused_function( void ) {
return 1337;
}
#pragma GCC diagnostic pop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With