problem compiling boost.function w/ g++ 2.95.3

when trying to compile the following code (cut from the boost.function test suite): #include <boost/bind.hpp> #include <boost/function.hpp> #include <iostream> #include <string> #include <functional> struct X { X(int v) : value(v) {} int twice() const { return 2*value; } int plus(int v) { return value + v; } int value; }; int main() { using namespace boost; boost::function<int, X*> f1(&X::twice); X one(1); cout << "f1(one) = " << f1(&one) << endl; return 0; } _____________________________________________ i get the following errors: /usr/local/include/boost/function/function_template.hpp: In function `static int boost::detail::function::function_obj_invoker1<int (X::*) () const,int,X *>::invoke(boost::detail::function::any_pointer, X *)': /usr/local/include/boost/function/function_template.hpp:689: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)() const, boost::detail::function::function_obj_tag)' /usr/local/include/boost/function/function_template.hpp:618: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)() const)' /usr/local/include/boost/function/function_template.hpp:463: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::function1<int (X::*)() const>(int (X::* &)() const)' /usr/local/include/boost/function.hpp:459: instantiated from `boost::function<int,X *,boost::detail::function::unusable,boost::detail::function::unusable, boost::detail::function::unusable,boost::detail::function::unusable,bo ost::detail::function::unusable,boost::detail::function::unusable,boos t::detail::function::unusable,boost::detail::function::unusable,boost: :detail::function::unusable>::function<int (X::*)() const>(int (X::* &)() const)' hello.C:21: instantiated from here /usr/local/include/boost/function/function_template.hpp:272: pointer to member function called, but not in class scope /usr/local/include/boost/function/function_template.hpp:272: warning: control reaches end of non-void function `boost::detail::function::function_obj_invoker1<int (X::*)() const,int,X *>::invoke(boost::detail::function::any_pointer, X *)' /usr/local/include/g++-3/stl_alloc.h: At top level: /usr/local/include/g++-3/stl_alloc.h: In instantiation of `allocator<int (X::*)() const>': /usr/local/include/boost/function/function_base.hpp:131: instantiated from `boost::detail::function::functor_manager<int (X::*) () const,allocator<boost::function_base> >' /usr/local/include/boost/function/function_template.hpp:691: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)() const, boost::detail::function::function_obj_tag)' /usr/local/include/boost/function/function_template.hpp:618: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::assign_to<int (X::*)() const>(int (X::* &)() const)' /usr/local/include/boost/function/function_template.hpp:463: instantiated from `boost::function1<int,X *,boost::empty_function_policy,boost::empty_function_mixin,allocator<b oost::function_base> >::function1<int (X::*)() const>(int (X::* &)() const)' /usr/local/include/boost/function.hpp:459: instantiated from `boost::function<int,X *,boost::detail::function::unusable,boost::detail::function::unusable, boost::detail::function::unusable,boost::detail::function::unusable,bo ost::detail::function::unusable,boost::detail::function::unusable,boos t::detail::function::unusable,boost::detail::function::unusable,boost: :detail::function::unusable>::function<int (X::*)() const>(int (X::* &)() const)' hello.C:21: instantiated from here /usr/local/include/g++-3/stl_alloc.h:750: `allocator<int (X::*)() const>::address(int (X::* &)() const) const' has already been declared in `allocator<int (X::*)() const>' make: *** [hello.o] Error 1 ___________________________________ this code should compile (its just copied from the test code) and my compiler setup should work according to the boost compiler status page. Any ideas what i'm doing wrong? -Darin Buck

On Wednesday 28 November 2001 09:25 pm, you wrote:
when trying to compile the following code (cut from the boost.function test suite):
i get the following errors:
this code should compile (its just copied from the test code) and my compiler setup should work according to the boost compiler status page.
Any ideas what i'm doing wrong?
I've just checked the code on GCC 2.95.3 and GCC 3.0.2 and have had no problems. Are you using at least Boost 1.25.1? Support for member functions was added in that release. Doug

Thanks for the help. I had both 1.25.0 and 1.25.1 installed in different locations, and guess which one was in my include path. Doh! -Darin --- Douglas Gregor <gregod@cs.rpi.edu> wrote:
On Wednesday 28 November 2001 09:25 pm, you wrote:
when trying to compile the following code (cut from the boost.function test suite):
i get the following errors:
this code should compile (its just copied from the test code) and my compiler setup should work according to the boost compiler status page.
Any ideas what i'm doing wrong?
I've just checked the code on GCC 2.95.3 and GCC 3.0.2 and have had no problems. Are you using at least Boost 1.25.1? Support for member functions was added in that release.
Doug
------------------------ Yahoo! Groups Sponsor
Info: <http://www.boost.org> Wiki:
<http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe@yahoogroups.com>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
__________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1
participants (2)
-
Darin Buck
-
Douglas Gregor