Hi All,
I have the function that need to be type cast the void point to different type of data structure. Is there any way to do that with the name of structure and the void pointer.
For example I have the follwowing data structure:
typedef struct struct_a_s
u_int16_t my_id;
u_int_t num_counter;
} struct_a_t;
typedef struct struct_b_s
char name[30;
int age;
} struct_b_t
/*
data point to data of ether struct_b_t or struct_a_t
name_structure is the name of either struct_b_t or struct_a_t
get_data(void *data, char *name_structure);
I want this macro to return the type case data to struct_a_t or struct_b_t base on the name;
Usually I did this
(struct_a_t *)data;
or (struct_b_t *)data;
for casting the data type to the correct one by if I have the macro then it is better. Just need to past in the void* and the name of structure I can cast to the correct one.
Thanks for your help.
J