Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-13 08:39:13


----- Original Message -----
From: "Jacek Generowicz" <jmg_at_[hidden]>

> Maybe a naive question, but I've not had much luck in finding the
> answer in the documentation.
>
> Suppose I am creating a python module based around a C++ class.
>
> class foo { . . . };
> ...
> class_builder<foo> foo_class( the_module, "foo" );
>
> How should I go about exposing functions which return objects of type
> foo?
>
> foo bar(...) { foo f; ...; return f; }

my_module.def(bar, "bar");

> Are there any complications when foo is a template class ?

If foo is a template class (instantiation), there are no problems. Of
course, if foo is a /class template/, you can only expose specific
instantiations.

> (My attempts compile, but when the module is imported in python an
> error message like
>
> ImportError: ./foo.so: undefined symbol: __pl__FRCt6foo1ZdT0
>
> appears. If foo-returning functions are avoided, everything seems to
> work as it should.)

I think you'd better try to unmangle that name with whatever
platform-specific C++ unmangler you use (e.g. c++filt on unix). It's pretty
hard to figure anything out otherwise.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk