title: How to write C function accepting (one) argument of any type
body: <p>I am implementing simple library for lists in C, and I have a problem with writing <code>find</code> function.</p>
  
  <p>I would like my function to accept <em>any</em> type of argument to find, both:
  <code>find(my_list, 3)</code> and <code>find(my_list, my_int_var_to_find)</code>.
  <strong>I already have information what is type of list's elements</strong>.</p>
  
  <p>For now I've found couple of ways dealing with this:</p>
  
  <ul>
  <li><p>different function with suffix for different types: <code>int findi(void* list, int i)</code>, <code>int findd(void* list, double d)</code> - but I don't like this approach, it seems like redundancy for me and an API is confusing.</p></li>
  <li><p>using union:</p>
  
  <pre><code>typedef union {
     int i;
     double d;
     char c;
     ...
  } any_type;
  </code></pre>
  
  <p>but this way I force user to both know about <code>any_type</code> union, and to create it before invocation of <code>find</code>. I would like to avoid that.</p></li>
  <li><p>using variadic function: <code>int find(void* list, ...)</code>. I like this approach. However, I am concerned about no restrictions on number of arguments. User is free to write <code>int x = find(list, 1, 2.0, 'c')</code> although I don't know what it should mean.</p></li>
  </ul>
  
  <p>I have seen also answer to this question: <a href="https://stackoverflow.com/questions/10212655/c-send-different-structures-for-one-function-argument">C : send different structures for one function argument</a> but it's irrelevant, because I want to accept non-pointer arguments. </p>
  
  <p>What is the proper way of handling this function?</p>