如何处理太长的STL模板错误报告
How to deal with way too long STL template error report?
当使用c++ STL编程,或大量使用'模板化'时,出现一些编译错误,错误报告往往很长,而且往往给出太多不需要的信息。我说的是gcc,我不知道是否与其他编译器不同,但有时即使只是一个错别字,也需要一段时间才能捕获清除
的错误。<ns::type<ns::type<ns::type, ns::type<...><ns::type<...> > > > >
我正在寻找一些编译器标志,技巧,解决方法或方法(我目前复制过去的错误,并把两行我有什么和什么编译器用来想要和删除变量书签…(有点悲伤的过程对于一个不太常见的ctrl+s不能很好地执行)),可以使这个任务更快或只是帮助我(甚至只是一些IDE错误语法高亮…)
STLFilt:用于c++的STL错误消息解密器是一种流行的工具,用于过滤这些冗长的错误消息并将其转换为更清晰的内容。
来自他们的网站:
STLFilt最初被认为是一个教学辅助工具,允许学生参加c++和/或stl特定的研讨会来理解典型的过度膨胀的STL错误消息。然而,今天,即使是一些c++专家在日常开发中采用了STLFilt。结果可能是并不总是完美的,但大多数时候信息丢失了对于正在调试的应用程序来说,在解密过程中并不重要。其余时间,解密很容易绕过。
每个平台的发行版(编译器/库集)是独立的,并调整到该平台的特性。每一个Perl脚本执行所有标准的基本正则表达式替换(和扩展的,如果在库中存在)STL组件,而脚本的某些版本在消息方面更进一步排序、换行、库头错误处理等单方面认为适合该平台
下面是一个演示,展示了它是如何有用的:
源程序:
#include <map> #include <algorithm> #include <cmath> const int values[] = { 1,2,3,4,5 }; const int NVALS = sizeof values / sizeof (int); int main() { using namespace std; typedef map<int, double> valmap; valmap m; for (int i = 0; i < NVALS; i++) m.insert(make_pair(values[i], pow(values[i], .5))); valmap::iterator it = 100; // error valmap::iterator it2(100); // error m.insert(1,2); // error return 0; }
首先,使用MinGW gcc 3.2编译器进行未过滤的运行:
d:srccldemo>c++2 rtmap.cpp rtmap.cpp: In function `int main()': rtmap.cpp:19: invalid conversion from `int' to ` std::_Rb_tree_node<std::pair<const int, double> >*' rtmap.cpp:19: initializing argument 1 of `std::_Rb_tree_iterator<_Val, _Ref, _Ptr>::_Rb_tree_iterator(std::_Rb_tree_node<_Val>*) [with _Val = std::pair<const int, double>, _Ref = std::pair<const int, double>&, _Ptr = std::pair<const int, double>*]' rtmap.cpp:20: invalid conversion from `int' to ` std::_Rb_tree_node<std::pair<const int, double> >*' rtmap.cpp:20: initializing argument 1 of `std::_Rb_tree_iterator<_Val, _Ref, _Ptr>::_Rb_tree_iterator(std::_Rb_tree_node<_Val>*) [with _Val = std::pair<const int, double>, _Ref = std::pair<const int, double>&, _Ptr = std::pair<const int, double>*]' E:/GCC3/include/c++/3.2/bits/stl_tree.h: In member function `void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::insert_unique(_II, _II) [with _InputIterator = int, _Key = int, _Val = std::pair<const int, double>, _KeyOfValue = std::_Select1st<std::pair<const int, double> >, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, double> >]': E:/GCC3/include/c++/3.2/bits/stl_map.h:272: instantiated from `void std::map<_ Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Input Iterator = int, _Key = int, _Tp = double, _Compare = std::less<int>, _Alloc = st d::allocator<std::pair<const int, double> >]' rtmap.cpp:21: instantiated from here E:/GCC3/include/c++/3.2/bits/stl_tree.h:1161: invalid type argument of `unary * '
和使用特定于gcc的代理c++的过滤运行:
d:srccldemo>c++ rtmap.cpp *** {BD Software Proxy c++ for gcc v3.01} STL Message Decryption is ON! *** rtmap.cpp: In function `int main()': rtmap.cpp:19: invalid conversion from `int' to `iter' rtmap.cpp:19: initializing argument 1 of `iter(iter)' rtmap.cpp:20: invalid conversion from `int' to `iter' rtmap.cpp:20: initializing argument 1 of `iter(iter)' stl_tree.h: In member function `void map<int,double>::insert_unique(_II, _II)': [STL Decryptor: Suppressed 1 more STL standard header message] rtmap.cpp:21: instantiated from here stl_tree.h:1161: invalid type argument of `unary *' STL Decryptor reminder: Use the /hdr:L option to see all suppressed standard lib headers
[注:演示运行是在80列控制台窗口中执行的启用了STLFilt的智能换行,并使用了internal开关设置为产生尽可能简洁的消息。更多细节见[/p]
唯一的缺点是它错误地标记了 c++标准库。(
这是STLFilt作者的相关期刊文章
一些人已经制作了工具来执行此操作,因为没有任何内置工具。在谷歌上大量搜索,但最上面的结果返回:http://www.bdsoft.com/tools/stlfilt.html
应该与visual studio和gcc兼容。
编辑::
我需要更少的输入才能及时得到输入:)
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么这个运算符<重载函数对 STL 算法不可见?
- Android NDK传感器向事件队列报告奇怪的间隔
- 如何在 C 中正确使用 libiconv 使其不会报告"Arg list too long"?
- 使用std::source_location报告错误的最佳实践
- 在C应用程序中运行C++(带有STL)函数
- 使用2个键的cpp-stl::优先级队列排序不正确
- xmake总是报告:错误:无法获取cxx的程序,为什么
- 当用户超过按钮点击限制时报告
- 使用调试/崩溃报告将应用程序部署到客户端
- 在STL容器中使用模板类
- 为什么cudaMemGetInfo报告设备内存总量的变化
- 用C++中的CPerson(类)类型的对象初始化STL矢量
- 将stl字符串缩小到小于15个字符的容量
- 在为LINUX创建共享库时,如何避免STL的私有/弱副本
- 检查函数返回类型是否与STL容器类型值相同
- STL算法函数在多个一维容器上的使用
- 如何处理太长的STL模板错误报告
- 我如何解决内存泄漏,报告驻留在STL字符串
- FastMM报告c++ Builder 6中STL容器的内存泄漏