How to write C function accepting (one) argument of any type
I am implementing simple library for lists in C, and I have a problem with writing find function. I would like my function to accept any type of argument to find, both: find(my_list, 3) and find(my_list, my_int_var_to_find) . I already have information what is type of list's elements . For now I've found couple of ways dealing with this: different function with suffix for different types: int findi(void* list, int i) , int findd(void* list, double d) - but I don't like this approach, it seems like redundancy for me and an API is confusing. using union: typedef union { int i; double d; char c;