title: Generic datastructures in C
body: <p>I'm looking into creating a generic BST. Nothing fancy no COTS, but I'm trying to decide the best way to keep track of the type of the void*. Here's the interface for the nodes:</p>
  
  <pre><code>typedef struct
  {
     void *data;
     struct TreeNode *left;
     struct TreeNode *right;  
  } TreeNode;
  </code></pre>
  
  <p>However, when I write add/remove, I'll need to do comparisons, hence I'll need to keep track of the type of data that "data" is pointing to, right?</p>
  
  <p>Basic idea is to have an enum Node_Type and a function compareTreeNodes that receives the two TreeNodes and the enum as a 3rd arg. This would allow the function to determine what to cast the void* to.</p>
  
  <p>Any other/better thoughts? </p>