Jump to content
  • Advertisement
Sign in to follow this  
Ksingh30

unused method

This topic is 3792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there some kind of tool that can let me do the following. I have a fairly large C++ app I am working on. and theres lots of methods in there that I think are never invoked. is there a tool that can go through my code and tell me which methods never get called?

Share this post


Link to post
Share on other sites
Advertisement
IIRC an optimizing compiler will just strip that all out for you (if you're worried about EXE size). If it's just about keeping the code clean, I'm sure one exists but don't know it off the top of my head.

If you want to go the DIY route, there are plenty of pretty awesome lexing/parsing libraries out there that you could use to write such a tool.

-me

Share this post


Link to post
Share on other sites
No there isn't. C++ isn't required to keep unused methods. Furthermore, many methods get inlined, meaning that they'll be missing from the executable in their source form.

One way that might work would be DoxyGen.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ksingh30
Is there some kind of tool that can let me do the following.
I have a fairly large C++ app I am working on. and theres lots of methods in there that I think are never invoked. is there a tool that can go through my code and tell me which methods never get called?


There are a variety of code coverage tools. I used one at my last company, but the name is escaping me ATM. A quick (and $$ free) way is to simply add a line to the beginning of each method (perhaps just the suspect ones to start), and have the ability to enable or disable logging off this line. Output it in a nice, easy to check format. Then you can use a tool (perhaps sed & awk) to retrieve the useful parts of the output. If you can figure out what is called, it's then easy to figure out what hasn't been called.

I will say, though, that unused functions aren't necessarily bad, if they're general purpose and reusable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!