c - Is there a way to get warned about unused functions? -
c - Is there a way to get warned about unused functions? -
i'd find unused functions in codebase - including across compilations units. i'm using gcc compiler.
here's example:
foo.c (assume appropriate foo.h):
void foo() { .... } void bar() { .... } main.c:
#include <stdio.h> #include "foo.h" int main(void) { bar(); homecoming 0; } in example, i'd warned foo() not beingness used.
there -wunused-function gcc option:
-wunused-function
warn whenever static function declared not defined or non-inline static function unused. warning enabled -wall.
but it's static functions - won't produce warning on illustration above.
i'll take suggestions of tools/scripts/other compilers can me - though i'd prefer stick gcc if possible.
caolan mc namara, libreoffice developer, has made little tool observe type of thing in libreoffice source code. had around thousands functions & methods unused in libreoffice. tool key element removing them.
it's called callcatcher. can
collect functions/methods defined , subtract called/referenced
it works straight on assembler output , so, works x86 , x86_64 architecture. can produce output this. can integrate traditional compiling , linking phone call gcc.
caolan agrees should become gcc plugin.
c gcc gcc-warning
Comments
Post a Comment