title: Is there a way to get warned about unused functions?
body: <p>I'd like to find unused functions in a codebase - including across compilations units. I'm using gcc as my compiler. </p>
  
  <p>Here's an example:</p>
  
  <p><code>foo.c</code> (assume appropriate <code>foo.h</code>):</p>
  
  <pre><code>void foo() {
     ....
  }
  
  void bar() {
     ....
  }
  </code></pre>
  
  <p><code>main.c</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "foo.h"  
  
  int main(void)  {
      bar();
      return 0;
  }
  </code></pre>
  
  <p>In this example, I'd like to get warned about <code>foo()</code> not being used. </p>
  
  <p>There is the <code>-Wunused-function</code> gcc option:</p>
  
  <blockquote>
    <p><code>-Wunused-function</code></p>
    
    <p>Warn whenever a static function is declared but not defined or a non-inline static function is unused.  This warning is
               enabled by -Wall.</p>
  </blockquote>
  
  <p>but it's only for static functions - it won't produce a warning on the example above.</p>
  
  <p>I'll also accept suggestions of tools/scripts/other compilers that can do this for me - though I'd prefer to stick with <code>gcc</code> if possible.</p>