In my C++ code I use templates a lot.. that might be an understatement. The end result is that the type names take more than 4096 characters and watching the GCC output is painful to say the least.
In several debugging packages like GDB or Valgrind one can request that C++ types not be demangled. Is there a similar way to force G++ to output only mangled type names, cutting on all the unecessary output?
Clarification
Because of the first answer that was given I see that the question isn't clear. Consider the following MWE:
template <typename T>
class A
{
public:
T foo;
};
template <typename T>
class B
{
};
template <typename T>
class C
{
public:
void f(void)
{
this->foo = T(1);
this->bar = T(2);
}
};
typedef C< B< B< B< B< A<int> > > > > > myType;
int main(int argc, char** argv)
{
myType err;
err.f();
return 0;
};
The error in the line this->bar = T(2);
is an error only when an object of type C<myType>
is instantiated and the method C::f()
called. Therefore, G++ returns an error message along these lines:
test.cpp: In instantiation of ‘void C<T>::f() [with T = B<B<B<B<A<int> > > > >]’:
test.cpp:33:8: required from here
test.cpp:21:14: error: no matching function for call to ‘B<B<B<B<A<int> > > > >::B(int)’
this->foo = T(1);
^
test.cpp:21:14: note: candidates are:
test.cpp:11:7: note: B<B<B<B<A<int> > > > >::B()
class B
^
test.cpp:11:7: note: candidate expects 0 arguments, 1 provided
test.cpp:11:7: note: B<B<B<B<A<int> > > > >::B(const B<B<B<B<A<int> > > > >&)
test.cpp:11:7: note: no known conversion for argument 1 from ‘int’ to ‘const B<B<B<B<A<int> > > > >&’
test.cpp:21:14: error: ‘class C<B<B<B<B<A<int> > > > > >’ has no member named ‘foo’
this->foo = T(1);
^
test.cpp:23:14: error: no matching function for call to ‘B<B<B<B<A<int> > > > >::B(int)’
this->bar = T(2);
^
test.cpp:23:14: note: candidates are:
test.cpp:11:7: note: B<B<B<B<A<int> > > > >::B()
class B
^
test.cpp:11:7: note: candidate expects 0 arguments, 1 provided
test.cpp:11:7: note: B<B<B<B<A<int> > > > >::B(const B<B<B<B<A<int> > > > >&)
test.cpp:11:7: note: no known conversion for argument 1 from ‘int’ to ‘const B<B<B<B<A<int> > > > >&’
test.cpp:23:14: error: ‘class C<B<B<B<B<A<int> > > > > >’ has no member named ‘bar’
this->bar = T(2);
The type names are irritating here, but make it impossible to read when the complete type name takes hundreds of characters. Is there a way to ask GCC for mangled type names instead of the full names, or to limit their length somehow?
STLFilt
Unfortunately, STLFilt
only makes the output prettier; the length doesn't change. In fact, the fact that the output is broken into multiple lines makes the whole thing worse, because the output takes more space.