Just a little background for the strange question: I have a network framwork (RTI DDS) which has a C serialisation function which takes a pointer and converts a C struct to a string.
It also (and is also designed to work) with C++ classes. But if I make a C++ class polymorphic by adding a virtual function this serialisation funktion segfaults or sometimes even worse provides wrong output.
I assume that it internally makes assumptions about the memory layout of the struct.
Is it possible to get a raw C pointer from a polymorphic C++ object?
I know that I could just create every struct twice, once polymorphic and once non-polymorphic, but this would lead to an insane amount of glue code.
Currently I am out of ideas.
Some technical background: The C function is in the RTI DDS Source package:
DynamicData.c DDS_ReturnCode_t DDS_DynamicData_to_cdr_buffer(...) { ..