title: How to perform conditional function calling in C?
body: <p>So I am doing some work in C where I have implementation of the same function in both assembly and C and I want to compare the performance of C vs assembly implementation. Now for that I would want to be able to compile and call the function conditionally i.e I would want to create a function which would act as an interface between the caller and the right function that I want to call. somehow I am not sure how to do that.
  I was thinking somewhere along the line of following:</p>
  
  <pre><code>//header file containing the C definition and the assembly definition
  
  void getstate(state* m, int* values);   
  extern void kalmanstate(state* m, int* values);
  </code></pre>
  
  <p>Then the caller can include the above header file and pass either &amp;getstate or &amp;kalmanstate.</p>
  
  <pre><code>void callTheRightFunction(state* m, int* values, void *fnptr(state*,int*))
  {
    *fnptr(m,values);
  }
  </code></pre>
  
  <p>However the problem with this is that both getstate and kalmanstate will be compiled which kind of defeats the purpose of my simulation. It does not sound to me the best implementation of the wrapper I want to have. I know conditional execution exists in C but how would I use it to get the right function compile? I mean if I do something like this in the header file:</p>
  
  <pre><code>#ifdef __C__FUNC
  void getstate(state* m, int *values);
  #endif
  #ifdef __kalman
  void kalmanstate(state *m, int *values)
  #endif
  </code></pre>
  
  <p>Then in the caller:
      include "headerfile.h" //include the above header file
      //caller defining _<em>C</em>_FUNC
      define __C_FUNC
      callTheRightFunction(m,p,&amp;getstate);
  But since I include the header file at the beginning when none of them are defined it would probably not include any of them at all and thus will generate runtime errro.
  Any suggestions towards right direction would be appreciated. Thanks in advance guys!</p>