I have a different objects, like this:
typedef struct { int32_t info ; } item1_properties_t ;
and
typedef struct { int32_t info ; } item2_properties_t ;
the objects are held in containers. I want to introduce a function that returns these objects (i.e. a const pointer) with minimum casts (working in C). I thought of having the function return the type and a void pointer, expecting the caller to cast correctly but I don't really like it. Do you have better ideas?
What the OP can do is store the data of the containers as an array of bytes alongside the type of the data. Then, when pointer/copying that data to a coitainer, a cast can be done based on the stored type.