I am currently embedding python in a C++ module. I have a problem in that one of the functions I am trying to build must be capable of accepting various structures for processing specific commands.

The function should be declared in C++ as follows

void Write(char *cmd, void* mystruct, struct_type structID);

The function itself should then take the 3rd parameter (it is an enumeration containing structure type id's) and then process the void pointer (2nd parameter) based on the structure type.

I am exporting all structure types into python, so it should have access to each type of structure. In the python code, I will fill out the structure, then send it to the Write function.

Is this possible?

8 Years
Discussion Span
Last Post by sneekula

If the write function is possible, how is a void pointer sent from python to the exposed C++ function? Is the casting dynamic?

Also, if I were to read and return a structure, will a void pointer suffice in python?


Yes, it should all work but i dont know how a void pointer is sent to the exposed c++ function.

Again, look into the module struct in the Python manual.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.