Search code examples
c++eclipse-cdt

Eclipse: how to find functions in .h that have no implementation in .cpp?


How to find functions in .h files that have no implementation in .cpp files and never used?

Seems Eclipse give no warning or error if such functions present.

If it matters I'm using Eclipse Version: 3.8.1 on Ubuntu 14.04.


Solution

  • Eclipse does have a checker for unused function declarations, which can be enabled in Preferences -> C/C++ -> Code Analysis, but it only checks function declarations in .cpp files, not header files.

    Checkers can have options (that can be configured by clicking "Customize Selected..." on that preference page), and it may make sense to add an option to the "Unused function declaration" checker to check header files as well.

    You could file an issue requesting that such an option be added.

    If you're interested, you could also consider contributing a patch that implements such an option. It would be a relatively straightforward change to the existing checker code. I have some experience with this code, and I would be happy to mentor you (or anyone else) in making such a change.