Zitrax
Zitrax

Reputation: 20255

Simpler c++ template compile error output

When working with templates in C++ any errors cause the compiler to emit a lot of output. In most cases when I am working on something most of that information is noise and I have to scroll around looking for the info I am interested in, for example:

Is it possible in either g++ or clang to reduce any of this for shorter/simpler output?

Obviously the information can be important, but then I would prefer to compile again with more verbosity and keep it short and simple by default.

Upvotes: 9

Views: 479

Answers (1)

The Quantum Physicist
The Quantum Physicist

Reputation: 26276

Unfortunately there's no way to deal with this currently. C++20 solves this problem by introducing concepts, where templates can have abstract definitions that are restricted with everything except for their binary layout. Violating these definitions will provide simple errors.

Currently, I dig into these lines and I got used to it. I'm currently dealing with a program with 5 template parameters at places. It's all about getting used to it and training your eyes to parse the content.

However, if you're really stuck, one solution I may suggest is that you copy all the relevant error output to some editor, and do a find-and-replace to simplify individual expressions, making them smaller and smaller with every replace until it becomes readable for you. Good skills in regex may help as well. In Notepad++ (or Notepadqq on linux), you can find regular expressions and use capture groups in the replacement with \1 for first capture group, \2 for second, etc.

So, bottom line: Until C++20, there's no clean solution for this except what you invent yourself.

Upvotes: 7

Related Questions