[C++-sig] problems with typedef void *
Stefan Seefeld
seefeld at sympatico.ca
Mon Dec 13 00:23:47 CET 2010
On 12/12/2010 04:02 PM, Jacob Davis wrote:
> 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<T>'
There are a couple of issues with your approach. Note that the line
above is a trick to pass a message through a (very noisy) compiler
error. The "specify_a_return_value_policy..." piece above is telling you
that you can't wrap a function returning a void pointer without
explicitly telling boost.python what to do with the pointer. Normally it
would attempt to pass by-value, but that obviously doesn't work (you
can't dereference a void pointer !).
But, if you want to pass by-reference, how should the pointer be treated
? Who owns the data ?
More importantly, you don't use a strong type system in your API, since
"types" are aliasing void pointers. Thus, the compiler can't help you
distinguish e.g. function overloads, and there is no way to
auto-generate a type registry.
You may wrap your API with a C++ wrapper, though I honestly doubt this
is practical. In fact, I'm in doubt that boost.python is the right
choice for your Python wrapping effort. Have you considered alternatives ?
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list