Reputation: 1663
Is there a method to know if a private function isn't used within the definition class? Also, I need to know if there some public function of the class which is not used outside the class. How can achieve this?
Upvotes: 0
Views: 233
Reputation: 6875
Remove the function and see whether your project still compiles and links.
You should remove the definition (in the cpp file) only, and leave the declaration in the header. Otherwise overload resolution could mask the places where your function is called.
Upvotes: 1
Reputation: 3289
The solution depends heavily on the situation.
In many cases, you can simply grep
or ag
the source for calls to the function. Also, there are tools like cppcheck
that can analyze a source base and tell you this.
However, if you don't have source then there are other methods.
Add code to the functions that will output somehow visibly (perhaps to a logfile) when called. This is what gcc's Code Coverage functions do.
Upvotes: 2