[C++-sig] In a C++ extension, how to use a C++ class exported in another extension

David Abrahams dave at boost-consulting.com
Fri May 13 19:16:31 CEST 2005


Hua Su <suh at mails.tsinghua.edu.cn> writes:

> Hi,
>
> I'v learnt Boost.Python for two weeks and now encounter some
> problems :( In brief, I can't find the way to use a C++ class, which
> is exported in an existing extension, in another extension written
> by myself.  

If you are building with bjam per the recommendations at
http://www.boost.org/libs/python/doc/building.html it should "just
work."  

> In detail, I'm writing a paint program with wxPython
> which is an extension for GUI library wxWidgets (wxWindows). I use
> wxPython to implement GUI, and use C++ to implement paint
> operations.  ( In my application the paint operations is a
> bottleneck so I have to implement is in C++ ) When painting, I need
> to pass a pointer of DC from Python to my C++ code.  The problem is,
> the class "wxDC" is a real C++ class writen in wxWidgets, and is
> exported in wxPython as Python class "DC", but I need use it in my
> code as C++ class "wxDC". 

So... just use it.  What's the problem?

> I can't find support from Boost.Python for this problem. 

Are you seeing error messages?  Does compilation fail? Linking?
Runtime?

Could you reduce your example to some simple code (2 C++ files -- one
for each extension module and one Python file to drive the test) that
doesn't depend on WxWindows?  If you post that, it should be possible
to help you.

> I have tried to pass pointer "void *" instead, but Boost.Python
> declares it does not support "void *" as argument or return type.
> Could someone give me some example? I work for this problem for days
> :(

It isn't clear what problem you're having yet.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list