views:

1569

answers:

5

Hi, 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.

+1  A: 

AFAIK, there is no such option - the messages are self-identifying.

Jonathan Leffler
A: 

True the messages are self-identifying. But as I am working on a filter which would eventually filter out some accepted warning messages, and would reject others. It would become really easy if I get the warning ids, and do that instead of parsing the whole warning message against other.

Thanks.

mnshsnghl
GCC offers to filter its warning messages itself. See section "Options to Request or Suppress Warnings" in the manpage of GCC:http://www.manpagez.com/man/1/g++-4.0/ (better use the one on your system!)
ypnos
+1  A: 

GCC does not provide the option to change/add the text of warning messages. See section "Options to Control Diagnostic Messages Formatting" in the Manpage.

GCC also does not provide more verbose warning messages.

Sorry.

ypnos
+1  A: 

GCC doesn't have a warning ID <-> message mapping. If you'd like to filter particular warning messages, use a CFLAG such as -Wno-pragmas or -Wno-oveflow. The full list of flags is documented in the man page.

John Millikin
+2  A: 

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).

JesperE