title: How to reuse the same piece of C code with different typedef within the same program?
body: <p>I have a dynamic array ADT whose element type is void*</p>
  
  <pre><code>// In dyn_array.h
  typedef void* element;
  void append(array *a, element e);
  inline void set(array *a, int i, element e);
  ...
  // dyn_array.c contains the implementation
  </code></pre>
  
  <p>and this is used in many parts of my program. When I am adding new features to the program, now I want a dynamic array with int element instead of void*. I know one of the solution might be making a dyn_arrayi.h and dyn_arrayi.c whose contents are almost identical to dyn_array.h and dyn_array.c, except the typedef statement and the functions' names. But that doesn't seem to be an elegant solution for me, because I am obviously repeating myself meaninglessly.</p>
  
  <p>Is there a better solution so that I don't need to repeat myself? Perhaps compiling different versions of object code? How exactly would you do that? Thanks.</p>