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?

  • What you are referring to is not a stack trace. stackoverflow.com/questions/45698710 Describe things properly, using the word note that is right in front of you, and people won't have to infer what you are even talking about by guessing your most probable colour scheme and working from there.
    – JdeBP
    Feb 12, 2018 at 22:58
  • Thank you! I edited the question to reflect that clarification.
    – Jack
    Feb 13, 2018 at 1:32
  • 1
    Possible duplicate of Want to turn off "note" level messages in GCC Oct 29, 2019 at 21:39
  • A lot of what I wanted to ignore were warnings, and I found I could do that with -w if that helps. I can focus on all related, error-only information this way.
    – Pysis
    Dec 25, 2021 at 21:26

2 Answers 2


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.


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

  • You can use an old and no longer supported tool like STLFilt.

  • You can switch to Clang, or use it to report errors only and perform your final compilation in GNU g++.

  • You can become more familiar with STL which will make deciphering easier.

    A good understanding of the STL and how to use it will help you avoid lots of errors in the first place. Secondly, often error messages refer to functions in the STL source - if you have a rough idea how the STL is implemented, this can be extremely helpful in deciphering what the error message is going on about. The newest versions of the g++ compiler sometimes improve the output, making it more helpful and less verbose.

Not exactly what you want but it can shorten the output:

  • Use the -fmax-errors flag or -Wfatal-errors option:


    Limits the maximum number of error messages to n, at which point GCC bails out rather than attempting to continue processing the source code. If n is 0 (the default), there is no limit on the number of error messages produced. If -Wfatal-errors is also specified, then -Wfatal-errors takes precedence over this option.


    This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages.

  • 1
    Thanks for this! The particularly long note sequences are with boost::asio actually. From similar questions, there does not seem to be an exact answer :-(
    – Jack
    Feb 13, 2018 at 1:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .