AW: [C++-sig] functions whose return type is a pointer

David Abrahams dave at boost-consulting.com
Fri Jan 24 17:05:37 CET 2003


Gottfried.Ganssauge at HAUFE.DE writes:

> Here you are.
> I made a test program in the test directory and ran it successfully with
> msvc.
>
> Unfortunately I wasn't as successful with gcc :-(
> Neither gcc-2.95.2 nor gcc-3.2 would accept the code:
> With gcc-3.2 the following messages were generated:

Gottfried,

I appreciate your efforts, but please don't dump reams of unreadable
error messages on the other list participants!

> cd /home/gotti/temp/boost/libs/python/test/
> bjam opaque
> ...found 1773 targets...
> ...updating 4 targets...
> gcc-C++-action
> ../../../libs/python/test/bin/opaque_ext.so/gcc3.2/debug/runtime-link-dynami
> c/shared-linkable-true/opaque.o
> /home/gotti/temp/boost/boost/python/type_id.hpp: In function 
>    `boost::python::type_info boost::python::type_id(boost::type<T>*) [with T
> = opaque_]':
> /home/gotti/temp/boost/boost/python/lvalue_from_pytype.hpp:22:
> instantiated from `boost::python::type_info
> boost::python::detail::extractor_type_id(T&(*)(U)) [with T = opaque_, U =
> boost::python::convert_opaque_pointer<opaque_*>::instance&]'
> /home/gotti/temp/boost/boost/python/lvalue_from_pytype.hpp:87:
> instantiated from `boost::python::lvalue_from_pytype<Extractor,
> python_type>::lvalue_from_pytype() [with Extractor =
> boost::python::convert_opaque_pointer<opaque_*>, const
> PyTypeObject*python_type =
> (&boost::python::convert_opaque_pointer<opaque_*>::type_object)]'
> /home/gotti/temp/boost/boost/python/opaque_pointer_converter.hpp:40:
> instantiated from
> `boost::python::convert_opaque_pointer<Pointer>::convert_opaque_pointer(cons
> t char*) [with Pointer = opaque_*]'
> opaque.cpp:26:   instantiated from here
> /home/gotti/temp/boost/boost/python/type_id.hpp:56: invalid use of undefined
> type `struct opaque_'

<snip>

This means serious trouble for your approach, and probably also that
an architectural change in Boost.Python is called for.  Basically,
typeid(X) is illegal when X is a pointer type.

We'll have to re-think this :(


-- 
                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution





More information about the Cplusplus-sig mailing list