example code to access some C++ classes in a DLL
Jimmy Retzlaff
jimmy at retzlaff.com
Sat Feb 28 23:35:47 EST 2004
More information about the Python-list mailing list
Sat Feb 28 23:35:47 EST 2004
- Previous message (by thread): example code to access some C++ classes in a DLL
- Next message (by thread): Book Sale
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Larry Bates wrote: >> i have written a DLL that implements some C++ classes and >> their methods. Now i would like to make the classes and >> their methods known to python. > > You can interface Python to ANY .DLL by using > CALLDLL. I've written a wrapper that I feel makes > doing this easier that is posted at: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146847 Thomas Heller's ctypes also makes calling most DLLs very simple, but neither of these approaches are well suited to using classes and methods in C++ DLLs. C++ compilers do name mangling (i.e., they tack extra symbols onto function names) to implement function overloading. You'd have to look up the mangling to figure out what to call and this mangling often differs between different compilers and sometimes between different versions of the same compiler. Name mangling (and hence function overloading) can be turned off in some (all?) C++ compilers for normal functions, but I'm not sure name mangling can be disabled for methods (which typically have their classes encoded into their names). Jimmy
- Previous message (by thread): example code to access some C++ classes in a DLL
- Next message (by thread): Book Sale
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list