[C++-sig] problems with typedef void *
Howdy!
I'm wrapping a C libary with Boost Python and having a really difficult time
with void * typedefs. For example, here's a typedef and the function header
that uses it:
typedef void * EmoEngineEventHandle;
EmoEngineEventHandle EE_EmoEngineEventCreate();
And my undoubtedly overly simplistic wrapper for the function:
def("EE_EmoEngineEventCreate", EE_EmoEngineEventCreate);
The compiler complains with lots of similar messages:
1>C:\boost_1_45_0\boost/python/detail/caller.hpp(223) : error C2027: use of
undefined type
'boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning'
1>with
1>[
1>T=result_t
1>]
1>C:\boost_1_45_0\boost/python/detail/caller.hpp(200) : while
compiling class template member function 'PyObject
*boost::python::detail::caller_arity<0>::impl::operator
()(PyObject *,PyObject *)'
1>with
1>[
1>F=void (__cdecl *)(void),
1>Policies=boost::python::default_call_policies,
1>Sig=boost::mpl::vector1
1>]
There are also functions that pass these typedefs as args, and I expect I'll
have problems with these, too. i.e.:
void EE_EmoEngineEventFree(EmoEngineEventHandle hEvent);
There are a *lot* of these functions in the library I'm wrapping that use
and return void * typedefs. Is there a way to translate the typedefs to get
all of my function wrappers to pass them properly? Failing that, how do I
modify my wrappers to support the typedefs?
Much obliged,
Jacob Davis
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Re: [C++-sig] problems with typedef void *
On Sun, Dec 12, 2010 at 3:04 PM, Jim Bosch wrote: > I think you'll want to define a custom wrapper class for each of these > typedefs with a distinct type. From your example, it looks like many of > these might be similar enough that you could use a template: > > [snip] > > Now, for all the other (non-constructor/destructor) functions that take > these, you'll need to write a function wrapper that takes arguments by the > wrapper classes, calls the C function, and returns using the wrapper classes > (you'll have to think about ownership semantics in that case, of course). > Then you can use Boost.Python to wrap the wrapper functions. > [snip] > > Finally, I wouldn't normally recommend SWIG, because I think Boost.Python > is generally much better, especially for wrapping C++ code. But in this > case, since you're wrapping pure C using a lot of opaque pointers, SWIG's > approach might be a better fit, since its code generation naturally > considers everything an opaque pointer. If you don't have to use > Boost.Python for other reasons, it might be worth a look, at least. > > Thanks Jim! I kind of expected that I would need to do wrapper classes and functions, but was hoping it wouldn't quite come to that. I Niall's patch doesn't work out well, I might just do this. As for SWIG, I considered it, but chose Boost for the sake of learning a bit more about it. Maybe it would be wise to just scrap it and go with SWIG though. - Jacob ___ Cplusplus-sig mailing list [email protected] http://mail.python.org/mailman/listinfo/cplusplus-sig
