Gcc 区分诊断
我在解释gcc(4.8.2)警告和错误时遇到问题。更准确地说,很难判断一个问题从哪里结束,另一个问题从哪里开始。我只能通过控制台访问构建机器,所以使用IDE不是一个选项 我真的需要能够快速区分各个问题。有没有办法让GCC在不同的诊断消息之间插入一些内容 下面是我得到的一个示例输出:Gcc 区分诊断,gcc,compiler-errors,compiler-warnings,compiler-options,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
/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]
}
^
/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:在成员函数“virtual bool xmodel::core::DataItemCollection::tryaAdditionalItemRegistration(std::shared\u ptr)const”中:
/usr2/viewstore_some/xy01/xy01_unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66:错误:调用“bind(,const std::_Placeholder&,const quid&)”时没有匹配的函数
,std::bind(&IDataItemCollectionScope::findItemById,_1,id)
^
/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66:注意:候选项包括:
在/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/bits/stl_algo.h:66:0中包含的文件中,
从/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/algorithm:62,
从/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,
从/gl sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qhash.h:45,
从/gl sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/QHash:1,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/rappserv/code/include/concility/stdhash\u quid.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/ItemId.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItem.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/dataitemsdescriptor.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItemCollection.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u 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:注意:模板类型名称std:_Bind_helper::type std::Bind(_Func&,_BoundArgs&…)
绑定(_Func&&u f,_BoundArgs&&…_参数)
^
/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1655:5:注意:模板参数推断/替换失败:
/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66:注意:无法推断模板参数“\u Func”
,std::bind(&IDataItemCollectionScope::findItemById,_1,id)
^
在/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/bits/stl_algo.h:66:0中包含的文件中,
从/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/algorithm:62,
从/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,
从/gl sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/qhash.h:45,
从/gl sync/thirdparty/Qt/4.8.4/lnx_x23.64/include/QtCore/QHash:1,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/rappserv/code/include/concility/stdhash\u quid.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/ItemId.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItem.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/dataitemsdescriptor.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/include/xmodel/core/IDataItemCollection.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.h:11,
来自/usr2/viewstore\u some/xy01/xy01\u 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:注意:模板类型名称std:_Bindres_helper::type std::bind(_Func&,_BoundArgs&&…)
绑定(_Func&&u f,_BoundArgs&&…_参数)
^
/gl sync/compilers/gcc/4.8.2/sle11sp0/include/c++/4.8.2/functional:1682:5:注意:模板参数推断/替换失败:
/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:414:66:注意:无法推断模板参数“\u Result”
,std::bind(&IDataItemCollectionScope::findItemById,_1,id)
^
/usr2/viewstore\u some/xy01/xy01\u unix1/fubar/extensions/xmodel/core/code/src/DataItemCollection.cpp:417:1:错误:控件到达非无效函数的末尾[-Werror=返回类型]
}
^
事实上,这一个甚至没有那么糟糕,因为不涉及宏扩展(我们也使用Boost.Preprocessor)。然而,很难一目了然地看出这个输出是关于两个问题的,第二个问题在最后3行,而第一个问题在这之前占据了整个文本墙
有没有办法在它们之间插入分隔符?即使是一个空行也可以,你可以搜索或grep
查找
我
$ gcc -O3 -g -std=c11 -Wall -Wextra stl.c -o stl
stl.c: In function ‘printStudent’:
stl.c:84:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Wformat=]
printf("Name: %s ", student->first);
^
stl.c:84:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Wformat=]
stl.c:85:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
printf("Grade: %s\n", student->grade);
^
stl.c:85:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
$
$ gcc -O3 -g -std=c11 -Wall -Wextra -Werror stl.c -o stl
stl.c: In function ‘printStudent’:
stl.c:84:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Werror=format=]
printf("Name: %s ", student->first);
^
stl.c:84:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Werror=format=]
stl.c:85:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Werror=format=]
printf("Grade: %s\n", student->grade);
^
stl.c:85:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Werror=format=]
cc1: all warnings being treated as errors
$
#!/bin/sh
#
# Insert markers before GCC warning and error messages
sed -e '
/^.*:[1-9][0-9]*:[1-9][0-9]*: warning: /i\
\
-- WARNING --\
\
/^.*:[1-9][0-9]*:[1-9][0-9]*: error: /i\
\
-- ERROR --\
\
' "$@"
/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’:
-- ERROR --
/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)
^
-- ERROR --
/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]
}
^
'stl' is up to date.
gcc -O3 -g -I/Users/jleffler/inc -std=c11 -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition stl.c -o stl -L/Users/jleffler/lib/64 -ljl
gcc -O3 -g -I/Users/jleffler/inc -std=c11 -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition stl.c -o stl -L/Users/jleffler/lib/64 -ljl
stl.c: In function ‘printStudent’:
-- WARNING --
stl.c:84:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Wformat=]
printf("Name: %s ", student->first);
^
-- WARNING --
stl.c:84:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Wformat=]
-- WARNING --
stl.c:85:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
printf("Grade: %s\n", student->grade);
^
-- WARNING --
stl.c:85:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
gcc -O3 -g -I/Users/jleffler/inc -std=c11 -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Werror stl.c -o stl -L/Users/jleffler/lib/64 -ljl
stl.c: In function ‘printStudent’:
-- ERROR --
stl.c:84:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Werror=format=]
printf("Name: %s ", student->first);
^
-- ERROR --
stl.c:84:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘List’ [-Werror=format=]
-- ERROR --
stl.c:85:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Werror=format=]
printf("Grade: %s\n", student->grade);
^
-- ERROR --
stl.c:85:5: error: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Werror=format=]
cc1: all warnings being treated as errors
-fdiagnostics-color[=WHEN]
-fno-diagnostics-color