Eclipse возвращает ошибку для кода, для которого g ++ не - PullRequest
7 голосов
/ 08 сентября 2011

Создание простого кода (пример ниже) возвращает ошибку при затмении, а g ++ из командной строки - нет.И eclipse, и выходной исполняемый файл g ++, которые действуют одинаково (и результат соответствует моим ожиданиям).Это больно, когда код не такой простой, как в примере, который я показываю.Любая идея приветствуется.

Env: Eclipse Indigo CDT, Ubuntu 10.10

Пример кода:

//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();
}

Результат запуска exec:

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

Результат компоновки ввкладка «Проблема» в 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

1 Ответ

4 голосов
/ 23 сентября 2011

Я не решил эту проблему (это часто случается, особенно когда я использую boost), но основная причина может лежать в плагине Eclipse 'CDT в соответствии с этой веткой . Жестокий обходной путь, как описано на странице, отключает функцию анализа кода.

...