c – GCC:减少输出中的模板名称

c – GCC:减少输出中的模板名称,第1张

概述在我的C代码中,我经常使用模板..这可能是轻描淡写.最终结果是类型名称占用超过4096个字符,并且至少可以看到GCC输出是痛苦的. 在像GDB或Valgrind这样的几个调试包中,可以请求不对C类型进行解码.有没有类似的方法强制G只输出损坏的类型名称,削减所有不必要的输出? 澄清 由于给出了第一个答案,我发现问题不明确.考虑以下MWE: template <typename T>class A 在我的C代码中,我经常使用模板..这可能是轻描淡写.最终结果是类型名称占用超过4096个字符,并且至少可以看到GCC输出是痛苦的.

在像GDB或Valgrind这样的几个调试包中,可以请求不对C类型进行解码.有没有类似的方法强制G只输出损坏的类型名称,削减所有不必要的输出?

澄清

由于给出了第一个答案,我发现问题不明确.考虑以下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;};

行中的错误 – > bar = T(2);仅当类型为C< myType>的对象时才会出错实例化并调用方法C :: f().因此,G沿这些行返回错误消息:

test.cpp: In instantiation of ‘voID C<T>::f() [with T = B<B<B<B<A<int> > > > >]’:test.cpp:33:8:   required from heretest.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 provIDedtest.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 provIDedtest.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);

类型名称在这里很烦人,但是当完整的类型名称需要数百个字符时,无法读取.有没有办法向GCC询问损坏的类型名称而不是全名,或以某种方式限制其长度?

STLFilt

不幸的是,STLFilt只使输出更漂亮;长度不变.事实上,输出被分成多行的事实使整个事情变得更糟,因为输出占用更多空间.

解决方法 人们正在遭受C错误报告的这一特殊缺点. 总结

以上是内存溢出为你收集整理的c – GCC:减少输出中的模板名称全部内容,希望文章能够帮你解决c – GCC:减少输出中的模板名称所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1240317.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存