I have to pass array of different struct type to a function which has to perform same functionality.
void chklink_state(void *links, int count)
{
int i;
int ret;
for (i = 0; i < count; i++)
{
if (links[i].curr_status != links[i].prev_status)
links[i].prev_status = links[i].curr_status;
}
}
main()
{
struct gre_info gre_infos[10];
struct vti_info vti_infos[10];
//populate data with some functions
chklink_state(gre_infos, 10);
chklink_state(vti_infos, 10);
}
But getting error compiling with gcc. If I use union I have to use switch case for different structure type. If I use casting I have to cast links to different struct type variables then have to use switch case.
Is it possible to do mentioned operation without using switch case or if else?