How to hide defaulted template parameters in gcc error messages?

后端 未结 2 2071
小鲜肉
小鲜肉 2021-02-13 18:14

Reading through error messages generated by g++ is often a pain because gcc expand names like

std::ostream

in my code into a much longer form

相关标签:
2条回答
  • 2021-02-13 19:10

    I doubt you can right now. A kind of close option is fno-pretty-templates which acts as follows:

    -fno-pretty-templates
    When an error message refers to a specialization of a function template, the compiler normally prints the signature of the template followed by the template arguments and any typedefs or typenames in the signature (e.g. void f(T) [with T = int] rather than void f(int)) so that it's clear which template is involved. When an error message refers to a specialization of a class template, the compiler omits any template arguments that match the default template arguments for that template. If either of these behaviors make it harder to understand the error message rather than easier, you can use -fno-pretty-templates to disable them.

    0 讨论(0)
  • 2021-02-13 19:12

    There is no compiler flag to reduce or change the error messages and the related types/templates.

    • gcc suppports coloring since gcc 4.9 with -fdiagnostics-color={auto, always, never}. See the documentation here.

    A number of third party tools exist to help you decrypt error messages:

    • GCCFilter for coloring and simplification of error messages (Perl script)
    • ColorGCC in the same vein (Perl script), git is here.
    • STLFilt : A message filter designed for STL-related diagnostics. Note that it is not supported/developed anymore.

    Also as a (very good) alternative, the clang compiler is very, very good at diagnosis and error messages.

    0 讨论(0)
提交回复
热议问题