mnshsnghl
mnshsnghl

Reputation: 61

g++ or gcc option to get warning message with warning id

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)

Upvotes: 6

Views: 8902

Answers (4)

JesperE
JesperE

Reputation: 64404

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

Upvotes: 6

John Millikin
John Millikin

Reputation: 200746

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.

Upvotes: 1

ypnos
ypnos

Reputation: 52317

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.

Upvotes: 2

Jonathan Leffler
Jonathan Leffler

Reputation: 753465

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

Upvotes: 1

Related Questions