Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++, find unused code and includes

Are there any no-cost tools (or direct Eclipse CDT plugins) that scan C++ code for unused functions, methods, variables, includes...?

I only found this stuff for C# and Java, but I'd like to have it for C++.

Cppcheck and also compilers can find unused variables in a scope, but they don't find, for example, unused member functions in classes or unused includes in a .cpp file. It would be good to have something like that to find deprecated and old code in the project.

like image 766
blubberbernd Avatar asked Sep 06 '11 13:09

blubberbernd


3 Answers

A version of "NDepend" exists for C++ (cppdepend). I haven't tried it, but I did use NDepend in the past. It should be good, YMMV.

like image 96
Christian.K Avatar answered Nov 08 '22 15:11

Christian.K


Deheader, by the estimable Eric S Raymond, will find unused includes. For everything else I use Visual Studio's static analysis tools.

like image 34
Justin R. Avatar answered Nov 08 '22 17:11

Justin R.


PCLint is a good one for this kind of static analysis.

like image 26
Roel Van Nyen Avatar answered Nov 08 '22 17:11

Roel Van Nyen