gcc - 区分 gcc 诊断

标签 gcc compiler-errors compiler-warnings compiler-options

我在解释 gcc (4.8.2) 警告和错误时遇到问题。更准确地说,很难分辨一个问题在哪里结束,另一个问题从哪里开始。我只能通过控制台访问构建机器,因此不能选择使用 IDE。

我真的需要能够快速区分个别问题。有没有办法让 GCC 在不同的诊断消息之间插入一些东西?

这是我得到的示例输出:

/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp: In member function ‘virtual bool xmodel::Core::DataItemCollection::tryAdditionalItemRegistration(std::shared_ptr<xmodel::Core::IDataItem>) const’:
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66: error: no matching function for call to ‘bind(<unresolved overloaded function type>, const std::_Placeholder<1>&, const QUuid&)’
       , std::bind(&IDataItemCollectionScope::findItemById, _1, id)
                                                                  ^
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66: note: candidates are:
In file included from /gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/bits/stl_algo.h:66:0,
                 from /gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/algorithm:62,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qglobal.h:68,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qatomic.h:45,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qhash.h:45,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/QHash:1,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/rappserv/code/include/convenience/stdhash_quuid.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/ItemId.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItem.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/DataItemDescriptor.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItemCollection.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:9:
/gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1655:5: note: template<class _Func, class ... _BoundArgs> typename std::_Bind_helper<std::__or_<std::is_integral<typename std::decay<_Tp>::type>, std::is_enum<typename std::decay<_Tp>::type> >::value, _Func, _BoundArgs ...>::type std::bind(_Func&&, _BoundArgs&& ...)
     bind(_Func&& __f, _BoundArgs&&... __args)
     ^
/gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1655:5: note:   template argument deduction/substitution failed:
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66: note:   couldn't deduce template parameter ‘_Func’
       , std::bind(&IDataItemCollectionScope::findItemById, _1, id)
                                                                  ^
In file included from /gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/bits/stl_algo.h:66:0,
                 from /gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/algorithm:62,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qglobal.h:68,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qatomic.h:45,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qhash.h:45,
                 from /gl-sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/QHash:1,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/rappserv/code/include/convenience/stdhash_quuid.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/ItemId.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItem.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/DataItemDescriptor.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItemCollection.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.h:11,
                 from /usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:9:
/gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1682:5: note: template<class _Result, class _Func, class ... _BoundArgs> typename std::_Bindres_helper<_Result, _Func, _BoundArgs>::type std::bind(_Func&&, _BoundArgs&& ...)
     bind(_Func&& __f, _BoundArgs&&... __args)
     ^
/gl-sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1682:5: note:   template argument deduction/substitution failed:
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66: note:   couldn't deduce template parameter ‘_Result’
       , std::bind(&IDataItemCollectionScope::findItemById, _1, id)
                                                                  ^
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:417:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^

实际上,这个还不错,因为没有涉及宏扩展(我们也使用 Boost.Preprocessor)。尽管如此,很难一眼就看出这个输出是关于两个问题的,第二个在最后 3 行,第一个在此之前占据了整个文本墙。

有没有办法在它们之间插入一些分隔符?即使是空行也可以,您可以搜索或 grep为了。

我已阅读 GCC docs on Options to Control Diagnostic Messages Formatting ,但我找不到任何东西。 [也不能用作搜索 anchor ,因为并非所有消息都有一个(上面的第一个没有)。我没有想法了。

最佳答案

你可以试试 vim 和它的 quickfix功能。我不知道你对 vim 有多熟悉,但它的 :make命令运行构建并捕获产生的错误,然后使用 :cnext (或较短的 :cn )您遍历所有错误,编辑器跳转到包含错误的文件+行。上面的链接中记录了许多其他功能,但这基本上是它的要点。

关于gcc - 区分 gcc 诊断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21905742/

相关文章:

c++ - gcc转储类层次结构问题

C系统函数返回sh : Invoke-Item command not found

android - 覆盖 onCreateDialog() 时类型不兼容

intellij-idea - IntelliJ说 “Warning: java: foo/bar/Baz.java uses unchecked or unsafe operations”,但是没有说它指的是哪一行

multithreading - 什么是正确使用 Vala 线程池?

gcc - Fedora 29 中的 c++config.h

xcode - 为什么 Homebrew 报告 "couldn' t 理解 kern.osversion `14.0.0'”?

ubuntu - gforth 出错,libtool 编译失败

c++ - 错误: operator '&&' has no right operand

C++: 'cout << pointer <<++pointer' 生成编译器警告