G++ – How to Disable Notes for Errors in GCC

compilingg++gcc

When compiling, errors are often accompanied by a lengthy series of notes (cyan). Is there a g++ flag to disable this, only showing the error itself?

Best Answer

The compiler will not do this for you, but (so far...) the compiler developers are following a longstanding (30+ year) convention adapted from other compilers which gives the essential information on the first line, using error: or warning: to mark the warning. If you grep stderr for those, you will see the minimal warning/error information.

grep is a good starting point (and "grep -n" output is useful by itself). These messages follow a pattern of filename, line number, message which is common to several tools. I used that in vi-like-emacs here.

Fairly recently (in 2014) gcc/g++ started adding a "calling-stack" to the messages, which gives the extra information. That relies upon a change to the preprocessor to track the line-numbers which can be turned off with a -P option (noted here), but that appears to be incompletely integrated in a form which would suppress the calling-stack.

Using clang would not help much with this; it can be very verbose as well. gcc/g++ development has added a lot of messages as noted here.

Related Question