【发布时间】:2014-06-11 08:33:39
【问题描述】:
所以之前我尝试在 C++ 中编译一个 lambda 表达式,我的默认编译器是 gcc-4.4,你知道它不支持 lambda 表达式,所以我尝试安装更新版本的 gcc-4.7,安装成功成功,但之后我无法编译任何程序。
我试图恢复以前版本的 gcc,但 update-alternatives 对我不起作用。
-错误:
In file included from /usr/local/include/htmlcxx/html/ParserDom.h:5:0,
from urlServer.cpp:7:
/usr/local/include/htmlcxx/html/tree.h:118:21: error: ‘ptrdiff_t’ does not name a type
urlServer.cpp: In lambda function:
urlServer.cpp:148:29: error: ‘urlHash’ is not captured
urlServer.cpp:148:38: error: return-statement with a value, in function returning 'void' [-fpermissive]
In file included from /usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/algorithm:63:0,
from urlServer.cpp:5:
/usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h: In instantiation of ‘_InputIterator std::__find_if(_InputIterator, _InputIterator, _Predicate, std::input_iterator_tag) [with _InputIterator = std::istream_iterator<std::basic_string<char> >; _Predicate = writeAllLinks(std::list<std::basic_string<char> >)::<lambda(const string&)>]’:
/usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h:4490:41: required from ‘_IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = std::istream_iterator<std::basic_string<char> >; _Predicate = writeAllLinks(std::list<std::basic_string<char> >)::<lambda(const string&)>]’
urlServer.cpp:148:39: required from here
usr/local/lib/gcc/i686-pc-linux- gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_algo.h:146:7: error: void value not ignored as it ought to be
我正在使用 debian
问题:如何恢复以前版本的 gcc?
我知道这个问题已经被问过了,但我找不到答案,我尽我所能,谢谢;
【问题讨论】:
-
当你说你“不能编译我的任何程序”时,你能详细说明一下吗?你得到什么错误?也许帮助你解决这个问题比回到旧的编译器更容易?
-
您的标题提出了一个与实际问题不同的问题(新编译器“不起作用”与降级到旧编译器)。
-
为你们的帮助,我更新了问题并将我遇到的错误放入其中; htmlcxx 是一个从 html 文件中提取 url 的库。
-
第一个错误(关于
ptrdiff_t)是因为4.6中C++库的变化。请参阅this text here(通过简单的搜索很容易找到)以了解更改的内容以及如何修复它的提示。第二个错误是因为您的代码中有某些内容,除非您显示您的代码,否则我们无法帮助您。 -
它没有作为系统编译器安装(你可能没有使用 Debian 包管理器来安装它)所以它安装在
/usr/local而不是/usr。但是,我敢打赌,它已正确安装在原处,您只需进行一些小改动(查看我之前的评论,然后点击链接)。