Listing Unused Symbols

前端 未结 2 525
灰色年华
灰色年华 2020-12-10 20:26

I want to remove dead code from a largish project and would like to start with unused symbols. Is there anyway to get the linker to list unused symbols that it has optimized

2条回答
  •  孤城傲影
    2020-12-10 20:49

    GCC can generate a compiler warning when it encounters functions, labels and function parameters that are unused. The compiler flags -Wunused -Wunused-parameter will do this.

    I'd personally recommend turning on all warnings and extra warnings when developing. The flags are -Wall -Wextra and the dead code warnings are implied by these flags, together with a whole host of other warnings that I've found useful.

提交回复
热议问题