" to th...">

GCC, C: Defining a Default Warning Name for Use in #pragma ignore

I found out that I can put

#pragma GCC diagnostic ignored "<warning>" 

to the top of the source file to suppress warnings associated with this particular source file. However, it seems that some names are not specific enough. For example,

 #pragma GCC diagnostic ignored "-Wwrite-strings" 

gcc (4.7.2) doesnโ€™t stop displaying warning messages whose exact names are not specified; instead, these messages are executed only with [enabled by default]. I think I need to know the correct warning names, so I can use them in the #pragma line. I tried

 -fdiagnostics-show-option, 

but warnings still display as [enabled by default].

Is there a way to identify these warnings, or alternatively suppress warnings associated with a specific source file?

Many thanks!

+7
source share
1 answer

You must click and place the 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 
+2
source

All Articles