Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22027

Is there a way to get warned about unused functions?

$
0
0

I'd like to find unused functions in a codebase - including across compilations units. I'm using gcc as my compiler.

Here's an example:

foo.c (assume appropriate foo.h):

void foo() {   ....}void bar() {   ....}

main.c:

#include <stdio.h>#include "foo.h"int main(void)  {    bar();    return 0;}

In this example, I'd like to get warned about foo() not being used.

There is the -Wunused-function gcc option:

-Wunused-function

Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.

but it's only for static functions - it won't produce a warning on the example above.

I'll also accept suggestions of tools/scripts/other compilers that can do this for me - though I'd prefer to stick with gcc if possible.


Viewing all articles
Browse latest Browse all 22027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>