Is there a way to get warned about unused functions?

后端 未结 6 1603
执笔经年
执笔经年 2020-12-01 06:26

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

6条回答
  •  半阙折子戏
    2020-12-01 06:51

    Caolan Mc Namara, a LibreOffice developer, has made a small tool to detect this type of thing in LibreOffice source code. They had around thousands functions & methods unused in LibreOffice. His tool is a key element for removing them.

    It's called callcatcher. It can

    collect functions/methods defined and subtract called/referenced

    It works directly on assembler output and so, it works only for x86 and x86_64 architecture. It can produce output like this. You can integrate it with your traditional compiling and linking call to gcc.

    Caolan agrees that it should become a gcc plugin.

提交回复
热议问题