如何在gcc错误消息中隐藏默认模板参数? [英] How to hide defaulted template parameters in gcc error messages?

查看:77
本文介绍了如何在gcc错误消息中隐藏默认模板参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通读g ++生成的错误消息通常很麻烦,因为gcc扩展了

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 like

std::basic_ostream<char, std::char_traits<char> >

错误消息中的

.同样,gcc将std::string扩展为std::basic_string<char>.对于这种扩展,我看不到任何好处,这只会使我很难将错误消息与错误站点相关联.

in the error messages. Similarly, gcc expands std::string into std::basic_string<char>. I don't see any benefit for such expansions, and it only makes it difficult for me to relate the error messages and the error site.

我想知道是否可以告诉gcc禁用此扩展行为,并按原样使用带有默认模板参数的简称?

I was wondering if it is possible tell gcc to disable this expansion behavior and use the shorter names with defaulted template parameters as-is?

此处有一个相关问题,该问题似乎根本没有显示扩展名太长.我在这里问是否可以仅显示我在代码中使用的简称.那里的答案也不能解决问题.

There is a related question here which seems to be about not showing the long expanded name at all. I am asking here if it is possible to just show the short name as I used in the code. The answer there also didn't solve the problem.

推荐答案

我怀疑您现在可以这样做.一种关闭选项是fno-pretty-templates,其作用如下:

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

-fno-pretty-templates
当错误消息涉及功能模板的特殊化时,编译器通常会打印以下内容的签名: 模板,后跟模板参数和任何typedef或 签名中的类型名称(例如void f(T)[with T = int]而不是 void f(int)),以便清楚地涉及到哪个模板.当一个 错误消息指的是类模板的专门化, 编译器将忽略与默认模板匹配的所有模板参数 该模板的参数.如果这些行为之一使之成为现实 较难理解而不是更容易理解错误消息,您可以使用 -fno-pretty-templates禁用它们.

-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.

这篇关于如何在gcc错误消息中隐藏默认模板参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆