title: Is there such a thing as a generic function pointer in C that can be assigned/cast to a more restrictive prototype?
body: <p>I have the need to dynamically link against a library at run-time and resolve a series of functions using <code>dlsym</code>. My first thought was to use an array of function pointers that can be easily iterated through by leveraging a secondary array of <code>char *</code> representing the symbol names. </p>
  
  <p>However, the problem with this is that not all of the functions take the same arguments. Is there a way to use a <em>generic</em> function pointer in the array, but assign it to a more restrictive function pointer prototype? For example:</p>
  
  <p>If I need to resolve these functions:</p>
  
  <pre><code>int (*functionA)(int)
  char (*functionB)(char,int)
  </code></pre>
  
  <p>Is it possible to do something like (pseudo-ish .. )</p>
  
  <pre><code>void* functionList(...)[2] = {functionA, functionB};
  </code></pre>
  
  <p>Along with</p>
  
  <pre><code>char FuncNameA[] = "functionA";
  char FuncNameB[] = "functionB";
  char *functionNames[2] = {FuncNameA, FuncNameB};
  </code></pre>
  
  <p>For the purpose of looping though the call to <code>dlsym</code> for symbol resolution</p>
  
  <pre><code>int i = 0;
  for(; i&lt;2; i++)
      functionList[i] = dlsym(DL_OPEN_HANDLE, functionNames[i]);
  </code></pre>
  
  <p>Where DL_OPEN_HANDLE would be defined by an earlier call to <code>dlopen</code>. </p>