I am working on a large project that is provided to our customers as a static c lib and one prototype header file for our open API. The project has two similar but unique assemblies that require different data structures to be displayed in the header. I'm trying to come up with a better design to allow one API function to work with different data structures depending on the assembly. This is my idea so far, but I'm worried that this is a bad design.
My function will be implemented as follows
void foo(void *generic_data_struct) { #ifdef BUILD1 build1_t *data_struct = generic_data_struct; #else build2_t *data_struct = generic_data_struct; #endif ... }
And the open API header will, depending on the assembly of customer orders,
void foo(build1_t *data_struct);
or
void foo(build2_t *data_struct);
Is this a reasonable design pattern or is it a frown? Thanks!
source share