无法使用gcc 4.4.7使用boost coroutine构建项目

时间:2014-09-26 20:01:32

标签: c++ boost coroutine gcc4.4

我无法在使用gcc 4.4.7(centos6.4,redhat 6.0,6.1等)的机器上使用boost coroutine构建一个简单的项目。使用运行gcc 4.8.3(fedora 19,centos 7.0)的机器可以很好地构建同一个项目。

由于Boost 1.55 version history确实将gcc 4.4.7列为经过测试的编译器,我做错了什么?

简单测试文件包含以下main.cpp文件:

#include <iostream>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/coroutine/coroutine.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>

using namespace std;

typedef boost::coroutines::coroutine<int()> routine_t;

// The implementation routine of the coroutine.
void xrange_impl(routine_t::caller_type& yield, int limit)
{
    for(int i = 0; i < limit; i++) 
    {
        yield(i); // return results back to the caller
    }
}

int main()
{
    routine_t foo(boost::bind(xrange_impl, _1, 10000));

    return 0;
};

我得到的编译错误是:

Building CXX object corotest/CMakeFiles/corotest.dir/src/main.cpp.o
In file included from /users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:29,
                 from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp: In instantiation of ‘boost::detail::is_function_chooser<false>::result_<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:60:   instantiated from ‘boost::detail::is_function_impl<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:102:   instantiated from ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354:   instantiated from ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480:   instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59:   instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22:   instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:52: error: forming pointer to reference type ‘boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:29,
                 from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp: In instantiation of ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354:   instantiated from ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480:   instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59:   instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22:   instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_function.hpp:102: error: ‘value’ is not a member of ‘boost::detail::is_function_impl<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp: In instantiation of ‘const bool boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480:   instantiated from ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59:   instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22:   instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:354: error: ‘value’ is not a member of ‘boost::is_function<boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:3:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp: In instantiation of ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59:   instantiated from ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22:   instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/type_traits/is_convertible.hpp:480: error: ‘boost::detail::is_convertible_impl<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>::value’ is not a valid template argument for type ‘bool’ because it is a non-constant expression
In file included from /users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:2:
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp: In instantiation of ‘boost::disable_if<boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>, boost::coroutines::coroutine<int(), 0>::dummy*>’:
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22:   instantiated from here
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/utility/enable_if.hpp:59: error: ‘value’ is not a member of ‘boost::is_convertible<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >&, boost::rv<boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > > >&>’
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp: In function ‘int main()’:
/users/mtomer/mike/mysqlcpp_umbrella/corotest/src/main.cpp:22: error: no matching function for call to ‘boost::coroutines::coroutine<int(), 0>::coroutine(boost::_bi::bind_t<void, void (*)(boost::coroutines::coroutine<void(int), 1>&, int), boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >)’
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:600: note: candidates are: boost::coroutines::coroutine<Signature, 0>::coroutine(boost::rv<boost::coroutines::coroutine<Signature, 0> >&) [with Signature = int()]
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:155: note:                 boost::coroutines::coroutine<Signature, 0>::coroutine() [with Signature = int()]
/users/mtomer/mike/mysqlcpp_umbrella/build/externals/boost/boost_build/install/include/boost/coroutine/v1/coroutine.hpp:119: note:                 boost::coroutines::coroutine<Signature, 0>::coroutine(boost::coroutines::coroutine<Signature, 0>&) [with Signature = int()]
make[2]: *** [corotest/CMakeFiles/corotest.dir/src/main.cpp.o] Error 1
make[1]: *** [corotest/CMakeFiles/corotest.dir/all] Error 2
make: *** [all] Error 2

来自&#34; gcc --version&#34;的输出在它不会构建的机器上:

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

来自&#34; gcc --version&#34;的输出在它将构建的机器上:

$ gcc --version
gcc (GCC) 4.8.3 20140624 (Red Hat 4.8.3-1)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 个答案:

答案 0 :(得分:0)

使用-std=c++0x编译代码。
boost::bind()未正确解决的类似情况下,这对我有用。