By default gcc/g++ prints a warning message with the line number only. I am looking for the option by which g++ or gcc associates the build warning messages with the warning ids, so that the warning messages can be identified easily (without parsing). Also can there be any more option to get a more detailed warning message ? (Though I think each of the warning message is pretty much explanatory by itself, but just curious)
Thanks.
-Wno-coverage-invalid-line-number can be used to disable the warning or -Wno-error=coverage-invalid-line-number can be used to disable the error. Suppress warning messages emitted by #warning directives.
This warning is enabled by -Wall . Warn when a #pragma directive is encountered which is not understood by GCC. If this command line option is used, warnings will even be issued for unknown pragmas in system header files. This is not the case if the warnings were only enabled by the -Wall command line option.
You can use a #pragma warning directive to control the level of warning that's reported at compile time in specific source files. Warning pragma directives in source code are unaffected by the /w option.
In GCC 4.x there is an option "-fdiagnostics-show-option" which displays the option used to switch off the warning:
$ gcc -fdiagnostics-show-option foo.c -Wall -o foo
foo.c: In function ‘main’:
foo.c:3: warning: unused variable ‘x’ [-Wunused-variable]
foo.c:4: warning: control reaches end of non-void function
In case you need to parse the warning, this may simplify things (especially in the presence of localized error messages).
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