title: I want to save a pointer to a function in a Global variable
body: <p>So i thought this would be straight forward but i keep getting compile errors, which probably means i am doing something stupid.</p>
  
  <p>So i am using C and i want to save a pointer to a function in a global variable.</p>
  
  <p>As a test case i have three files. Test.c, Test.h and FunctionPtr.c</p>
  
  <p>Test.h goes like this</p>
  
  <pre><code>void (*MyCallBack)(void);
  
  int SetFunc( void (*CallBackArg)(void));
  void CallFunc();
  </code></pre>
  
  <p>Test.c Goes like this</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "test.h"
  void SetFunc( void (*CallBackArg)(void)){
  
      printf("Set CallBack\n");
      MyCallBack=CallBackArg;
  }
  
  void CallFunc(){
      printf("In Call Func\n");
      MyCallBack();
  }
  </code></pre>
  
  <p>and FunctionTest.c goes like this</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "test.h"
  
  
  void MyFunc(){
      printf("Work!\n");
  }
  int main()
  {
      SetFunc(MyFunc);
      CallFunc();
  
  }
  </code></pre>
  
  <p>When i compile using  gcc FunctionTest.c  test.c test.h -o FunctionTest</p>
  
  <p>I get the following error...</p>
  
  <p>test.c:4: error: conflicting types for ‘SetFunc’
  test.h:4: note: previous declaration of ‘SetFunc’ was here</p>
  
  <p>I cant figure out what i am doing wrong? Perhaps i am not declaring the Global Pointer right? </p>