title: control reaches end of non-void function with custom exit function
body: <p>While trying to rid my code of GCC warnings I have discovered a strange bug/behaviour. My program uses a custom exit function which performs some clean-up and finally calls <code>exit()</code>.</p>
  
  <p>However my use of this exit function is causing GCC to produce spurious warnings of:</p>
  
  <blockquote>
    <p>control reaches end of non-void function with custom exit function</p>
  </blockquote>
  
  <p>An example of a program causing this bug is:</p>
  
  <p>File1.c:</p>
  
  <pre><code>extern void CleanExit(int ExitCode);
  
  int MyFunc(int ErrorCode)
  {
      if(-1 == ErrorCode)
          return -1;
      if(1 == ErrorCode)
          return 1;
      if(2 == ErrorCode)
          return 0;
      if(3 == ErrorCode)
          CleanExit(0);
      CleanExit(-1);
  }
  </code></pre>
  
  <p>File2.c:</p>
  
  <pre><code>void CleanExit(int ExitCode)
  {
      /* Do Some Cleanup */
      exit(ExitCode);
  }
  </code></pre>
  
  <p>Is there some way to be rid of these warnings without adding useless cruft to every function which uses this structure?</p>
  
  <p>I would prefer to do so with standard C but am willing to use some kind of GCC pragma if needed.</p>