[C++-sig] function with void * parameter on MSVC 7, Boost.Python

c++-sig cplusplus-sig at brewer.com
Sat Apr 19 02:37:04 CEST 2003


I am trying to wrap a C++ api that makes use of void *'s internally but
my problem boils down to a very simple example where I get a compiler
error. The error occurs in a section of Boost.Python code where msvc
RTTI type info names are undecorated (this code is only compiled into
MSVC compiler builds). My question can be reduced to what happens if I
remove this undecoration (which makes my compile work).

Ok, now the details:

#include <boost/python.hpp>
#include <prextl.h>

using namespace boost::python;

void dog(void *x);

BOOST_PYTHON_MODULE(test)
{
    def("dog",dog);
}

When I compile using Visual Studio .NET (I am assuming the same problem
exists on VC++ 6), I get the following error:
c:\projects\XPython\boost\boost\python\detail\msvc_typeinfo.hpp(45) :
error C2784: 'boost::python::detail::typeinfo
boost::python::detail::typeid_ref_1(T &(__stdcall *)(void))' : could not
deduce template argument for ' &(__stdcall *)(void)' from 'void
(__stdcall *)(void)'

It appears as though the msvc_typeinfo.hpp file exists for the following
reason in a comment at the top of the file:
// Fix for MSVC's broken typeid() implementation which doesn't strip
// decoration. This fix doesn't handle cv-qualified array types. It
// could probably be done, but I haven't figured it out yet.

And the template on which it dies looks like this:
template <class T>
inline typeinfo msvc_typeid(boost::type<T>* = 0)
{
    return detail::typeid_ref(
        (boost::type<T>*)0, detail::is_ref_tester1(type<T>())
        );
}

If I replace the return statement with return typeid(T); things compile
just fine (this is what happens on other compilers). But I'm wondering
what the effects are of not undecorating the msvc type names? Would it
mean that if Python were compiled with a non-microsoft compiler,
automatic type conversion would not work?

Thank you,

Jeff Brewer






More information about the Cplusplus-sig mailing list