c++错误更简洁

发布于 2024-12-20 17:09:49 字数 110 浏览 1 评论 0原文

我们都喜欢 C++ 产生跨两个 shell 屏幕的详细错误。特别是在您忘记模板函数定义中的单个&符号之后。您需要的只是错误消息的第一行,也许是最后一行。

如何使 C++ 模板错误不那么冗长?

We all love C++ producing verbose errors spanning two shell screens. Especially after you forget single ampersand in template function definition. And what you need is only first, and maybe last, line of the error message.

How to make C++ template errors less verbose?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吃素的狼 2024-12-27 17:09:49

如果您使用 gcc(或 g++),您可以使用以下选项:

-Wfatal-errors -w

-Wfatal-errors 将使编译在出现第一个错误时停止,-w 将消除警告。

在大多数情况下,我并不建议这样做,但也许对您现在的情况有帮助。

If you are using gcc (or g++) you could use the following options:

-Wfatal-errors -w

The -Wfatal-errors will make compilation stop on the first error, and -w will eliminate the warnings.

Not really something I'd suggest doing in most instances, but perhaps helpful in your case right now.

千笙结 2024-12-27 17:09:49

我不相信你能轻易做到这一点。另一方面,可能的是使用彩色输出。

在 Debian(及相关版本)上,您可以轻松安装 colorgcc 软件包,它正是这样做的。

这很有帮助。不一样,但确实有帮助

I don't believe you can do that easily. What is possible, on the other hand, is to use colored output.

On Debian (and related), you can easily install colorgcc package, which does exactly that.

It helps a lot. It's not the same, but it really helps

演出会有结束 2024-12-27 17:09:49

LLVM clang 这样更好的前端可能是唯一的选择。

A better front-end like LLVM clang is probably the only option.

罗罗贝儿 2024-12-27 17:09:49

您可以使用 STLFilt 来缩短模板错误消息,它有很大帮助!

其过滤示例可以在 Dr.多布斯。

You can use STLFilt to shorten the template error messages, it helps a lot!

An example of the filtering it does can be found at Dr. Dobbs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文