1

While developing my software, I declared many class functions that are not called anymore.

Now, I would like to tidy my sources, and get rid of those declarations.

GCC can detect unused variables, but is there a GCC option to detect unused class functions ? Or do I need upgrade for this (4.9.2) ?

Saint-Martin
  • 306
  • 3
  • 16
  • 4
    4.9.2 is definitely ancient. Upgrading might be a good idea regardless. Also, "prototypes" is an old C term. In C++, these are called declarations. And part of the problem with such warnings is that some C++ constructs use function declarations for overload resolution/SFINAE purposes, intentionally not defining them. – MSalters Apr 25 '23 at 09:52
  • Have a look at: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html You generally should activate `-pedantic` and `-Wall` and `-Wextra`, which activates `-Wunused-function`. – Fabian Keßler Apr 25 '23 at 09:59
  • Does this answer your question? [GCC -Wunused-function not working (but other warnings are working)](https://stackoverflow.com/questions/13224209/gcc-wunused-function-not-working-but-other-warnings-are-working) – Fabian Keßler Apr 25 '23 at 10:26

1 Answers1

2

By looking into the reference of GCC , you will find -Wunused-function. But it only marks static or inline functions.

To mark member functions, you should take a look at clang, which can be a drop-in replacement for GCC. Clang offers -Wunused-member-function. https://clang.llvm.org/docs/DiagnosticsReference.html

Fabian Keßler
  • 563
  • 3
  • 12