【问题标题】:Why does -Wfatal-errors turn off notes about the error, and how do I turn notes back on?为什么 -Wfatal-errors 会关闭有关错误的注释,以及如何重新打开注释?
【发布时间】:2020-08-28 18:19:14
【问题描述】:

我经常使用-Wfatal-errors 进行构建,因为我不需要额外的 100 个无意义的错误,而编译器会英勇地尝试在拼写错误后解析源文件的其余部分,使其变得毫无意义。

但是,我注意到这也会关闭有关致命错误本身的诊断说明。例如,-Wfatal-errors 我会得到,说,

main.cpp:10:2: error: invalid new-expression of abstract class type 'C'
  new C();

如果我没有打开-Wfatal-errors,我会收到一条说明,告诉我忘记实现哪个虚拟方法:

class.hpp:15:2 note: because the following virtual functions are pure within 'C':
class.hpp:28:6   void C::f()

我能否取回这些注释,同时仍保持在单个错误后终止的行为?

【问题讨论】:

    标签: c++ compilation g++


    【解决方案1】:

    您正在寻找-fmax-errors=1。这将在第一个错误后终止编译,但仍会显示该错误的注释。

    这里有一个demo 来比较这些标志的效果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-22
      • 2014-02-09
      • 2013-10-05
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 2010-09-24
      • 1970-01-01
      相关资源
      最近更新 更多