When the interfaces of Python and C + + involve buffers, you can create buffers in Python and pass pointers to the buffers to C + + functions (by creating additional functions for conversion). Examples are as follows:
Python side:
1. Get the binary data represented by STR (read files, etc.).
2. Create a buffer using the Create_string_buffer (str) function in the cTYPES package.
3. Get the buffer address represented by INT, take advantage of the AddressOf (BUF) function, buf the buffer object created in 2.
4. Use the extra conversion function INT2VOIDP (address) function to convert int to the buffer address of a C + + void*,address that is obtained by int in 3.
5. Pass the resulting Void* object to the C + + function.
C + + side:
1. Use void* from Python to make calls, or convert to char*.
Python use of pointers when calling C++dll via Swig