[C++-sig] example in lvalue_from_pytype won't compile
Mark Russell
mrussell8081 at pacbell.net
Thu Nov 21 01:05:04 CET 2002
I am working with the lvalue_from_pytype example and can't get it to
compile. My code and the errors are as follows:
#include <boost/python.hpp>
//defines
extern "C" _declspec(dllimport) PyTypeObject noddy_NoddyType;
typedef struct {
PyObject_HEAD
long magicNum;
} noddy_NoddyObject;
using namespace boost::python;
static handle<> cache;
bool is_cached(noddy_NoddyObject* x)
{
return x == cache.get();
}
void set_cache(noddy_NoddyObject* x)
{
cache = handle<>(borrowed(x));
}
BOOST_PYTHON_MODULE(noddy_cache)
{
def("is_cached", is_cached);
def("set_cache", set_cache);
// register Noddy lvalue converter
lvalue_from_pytype<extract_identity<noddy_NoddyObject>,&noddy_NoddyType>();
}
Compiling...
nc.cpp
C:\developer\com-hacking\boost hacking\noddy cache\nc.cpp(15) : error C2446:
'==' : no conversion from 'struct _object *' to 'noddy_NoddyObject *'
Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
C:\developer\com-hacking\boost hacking\noddy cache\nc.cpp(15) : error C2230:
'==' : indirection to different types
Error executing cl.exe.
noddy cache.dll - 2 error(s), 0 warning(s)
Apparently the converter is not getting registered but I can't see where.
Also the code in the example does not declare noddy_NoddyType -- I exported
the type from my noddy dll but am wondering if I am missing something here.
Many thanks. --Mark
More information about the Cplusplus-sig
mailing list