Eclipse返回错误代码为g ++没有 [英] Eclipse returns error for the code for which g++ doesn't

查看:224
本文介绍了Eclipse返回错误代码为g ++没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建简单的代码(示例如下)在eclipse上返回错误,而来自命令行的g ++没有。 eclipse和g ++输出可执行文件都是一样的(结果符合我的期望)。当代码不像我正在显示的例子那样简单时,这很痛苦。任何想法都赞赏



Env:Eclipse Indigo CDT,Ubuntu 10.10



示例代码:

  //对于test_boostStr()
#include< boost / algorithm / string.hpp>
#include< vector>
#include< iostream>

//对于test_boost_foreach()
#include< boost / algorithm / string / trim.hpp>
#include< boost / foreach.hpp>

void test_boostStr(){
std :: vector< std :: string>可疑交易报告;
boost :: split(strs,string to split,boost :: is_any_of(\t));
std :: cout<<< strs.size()<<的std :: ENDL;
// std :: cout<<< strs.at(1)<的std :: ENDL;
}

void test_boost_foreach(){
// std :: vector< std :: string> namespaces_;
std :: string namespaces_ =tele op eration。
std :: cout<<< 管理命名空间
std :: string out;
std :: string s;
BOOST_FOREACH(s,namespaces_)
{
boost :: trim(s);
out + = s +;
}
std :: cout<<< out.substr(0,out.size() - 1)<<的std :: ENDL;
}

int main(void){
test_boost_foreach();
}

运行exec的结果:

 远程操作。 

在Eclipse的问题选项卡中构建结果:

 说明资源路径位置类型
无效参数
候选者是:
boost :: mpl :: not_<#0> *不_(#0 *)
'Prove.cpp / ProvingGround line 23语义错误
无效参数
候选者是:
boost :: mpl :: not_<#0> *不_(#0 *)
'Prove.cpp / ProvingGround line 23语义错误
无效参数
候选者是:
boost :: mpl :: not_<#0> *不_(#0 *)
'Prove.cpp / ProvingGround line 23语义错误
无效参数
候选者是:
boost :: foreach_detail _ :: auto_any< boost :: foreach_detail _ :: foreach_iterator<#0,#1 GT; ::类型> end(const boost :: foreach_detail _ :: auto_any_base& boost :: foreach_detail _ :: type2type<#0,#1> *,mpl _ :: bool_< 0> *)
boost :: foreach_detail _ :: auto_any< INT> end(const boost :: foreach_detail _ :: auto_any_base& boost :: foreach_detail _ :: type2type<#0 *,#1> *,mpl _ :: bool_< 1> *)
boost :: foreach_detail _ :: auto_any< ;升压:: foreach_detail _ :: foreach_iterator<#0,#1 GT; ::类型> end(const boost :: foreach_detail _ :: auto_any_base& boost :: foreach_detail _ :: type2type<#0,#1> *,mpl _ :: bool_< 1> *)
'Prove.cpp / ProvingGround line 23语义错误
无效参数
候选者是:
boost :: foreach_detail _ :: auto_any< boost :: foreach_detail _ :: foreach_iterator<#0,#1> :: type> begin(const boost :: foreach_detail _ :: auto_any_base& boost :: foreach_detail _ :: type2type<#0,#1> *,mpl _ :: bool_< 0> *)
boost :: foreach_detail _ :: auto_any< #0 *> begin(const boost :: foreach_detail _ :: auto_any_base& boost :: foreach_detail _ :: type2type<#0 *,#1> *,mpl _ :: bool_< 1> *)
boost :: foreach_detail _ :: auto_any< ;升压:: foreach_detail _ :: foreach_iterator<#0,#1 GT; ::类型> begin(const boost :: foreach_detail _ :: auto_any_base& amp; boost :: foreach_detail _ :: type2type<#0,#1> *,mpl _ :: bool_< 1> *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选者是:
boost :: foreach_detail _ :: auto_any<#0 *>包含(#0& mpl _ :: bool_< 0> *)
boost :: foreach_detail _ :: auto_any<#0>包含(const#0& mpl _ :: bool_< 1> *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
boost ::算法::详细:: is_any_ofF<升压:: range_value<#0 GT; ::类型> is_any_of(const#0&)
'Prove.cpp / ProvingGround line 12语义错误
参数无效
候选人是:
#0& split(#0&#1&#2,enum boost :: algorithm :: token_compress_mode_type)
'Prove.cpp / ProvingGround line 12语义错误
参数无效
候选人是:
? *或_(#0 *,#1 *,#2 *)
? *或_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *或_(#0 *,#1 *,#2 *)
? *或_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *或_(#0 *,#1 *,#2 *)
? *或_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? * is_array_(const#0&)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? * is_array_(const#0&)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? * is_array_(const#0&)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误
参数无效
候选人是:
? *和_(#0 *,#1 *,#2 *)
? *和_(#0 *,#1 *)
'Prove.cpp / ProvingGround line 23语义错误


解决方案

我没有解决这个问题(发生很多,特别是当我使用boost似乎),但根本原因可能在于Eclipse的CDT插件根据<一个href =https://stackoverflow.com/questions/6888660/can-not-compile-boostsignal-tutorial-using-gcc-4-5-on-ubuntu-11-04>这个线程。如本页所述,残酷的解决方法是关闭代码分析功能。


Building simple code (example is below) returns error on eclipse, while g++ from commandline doesn't. Both eclipse and g++ output executable that act the same (and the result meets my expectation). This is painful when the code isn't simple like the example I'm showing. Any idea is appreciated.

Env: Eclipse Indigo CDT, Ubuntu 10.10

Sample code:

//For test_boostStr()
#include <boost/algorithm/string.hpp>
#include <vector>
#include <iostream>

//For test_boost_foreach()
#include <boost/algorithm/string/trim.hpp>
#include <boost/foreach.hpp>

void test_boostStr() {
    std::vector<std::string> strs;
    boost::split(strs, "string to split", boost::is_any_of("\t "));
    std::cout << strs.size() << std::endl;
    //  std::cout << strs.at(1) << std::endl;
}

void test_boost_foreach() {
    //std::vector<std::string> namespaces_;
    std::string namespaces_  = " tele op eration. ";
    std::cout << "managing namespaces: ";
    std::string out;
    std::string s;
    BOOST_FOREACH(s, namespaces_)
    {
        boost::trim(s);
        out += s + " ";
    }
    std::cout << out.substr(0, out.size() - 1) << std::endl;
}

int main(void) {
    test_boost_foreach();
}

Result of running the exec :

 t e l e  o p  e r a t i o n . 

Build result in the 'Problem' tab on Eclipse:

Description Resource    Path    Location    Type
Invalid arguments '
Candidates are:
boost::mpl::not_<#0> * not_(#0 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::mpl::not_<#0> * not_(#0 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::mpl::not_<#0> * not_(#0 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::foreach_detail_::auto_any<boost::foreach_detail_::foreach_iterator<#0,#1>::type> end(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0,#1> *, mpl_::bool_<0> *)
boost::foreach_detail_::auto_any<int> end(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0 *,#1> *, mpl_::bool_<1> *)
boost::foreach_detail_::auto_any<boost::foreach_detail_::foreach_iterator<#0,#1>::type> end(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0,#1> *, mpl_::bool_<1> *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::foreach_detail_::auto_any<boost::foreach_detail_::foreach_iterator<#0,#1>::type> begin(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0,#1> *, mpl_::bool_<0> *)
boost::foreach_detail_::auto_any<#0 *> begin(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0 *,#1> *, mpl_::bool_<1> *)
boost::foreach_detail_::auto_any<boost::foreach_detail_::foreach_iterator<#0,#1>::type> begin(const boost::foreach_detail_::auto_any_base &, boost::foreach_detail_::type2type<#0,#1> *, mpl_::bool_<1> *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::foreach_detail_::auto_any<#0 *> contain(#0 &, mpl_::bool_<0> *)
boost::foreach_detail_::auto_any<#0> contain(const #0 &, mpl_::bool_<1> *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
boost::algorithm::detail::is_any_ofF<boost::range_value<#0>::type> is_any_of(const #0 &)
'   Prove.cpp   /ProvingGround  line 12 Semantic Error
Invalid arguments '
Candidates are:
#0 & split(#0 &, #1 &, #2, enum boost::algorithm::token_compress_mode_type)
'   Prove.cpp   /ProvingGround  line 12 Semantic Error
Invalid arguments '
Candidates are:
? * or_(#0 *, #1 *, #2 *)
? * or_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * or_(#0 *, #1 *, #2 *)
? * or_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * or_(#0 *, #1 *, #2 *)
? * or_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * is_array_(const #0 &)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * is_array_(const #0 &)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * is_array_(const #0 &)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error
Invalid arguments '
Candidates are:
? * and_(#0 *, #1 *, #2 *)
? * and_(#0 *, #1 *)
'   Prove.cpp   /ProvingGround  line 23 Semantic Error

解决方案

I haven't solved this issue (happens a lot particularly when I use boost it seems), but the root cause may lie in Eclipse' CDT plug-in according to this thread. Brutal workaround is, as discussed in the page, to turn off code analysis feature.

这篇关于Eclipse返回错误代码为g ++没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆