|
Showing function definitions and references |
Peter Hull
Member #1,136
March 2001
|
Does anyone know of a tool which can run on a set C (and maybe C++) files and give a list of where all functions are defined and where they are used? If you've used an IDE it's like a combination of 'source browser' and 'find all references' Reason - I want to look for functions that are never used and could be removed, also ones that are only ever called from one file and therefore could be static to that file. Thanks!
|
GullRaDriel
Member #3,861
September 2003
|
I would use compiler flags to spot unused function @ compilation && doxygen to generate the functions relations diagrams to see the caller graph & all. "Code is like shit - it only smells if it is not yours" |
Thomas Fjellstrom
Member #476
June 2000
|
ctags may be what you're looking for. (not 100% sure). -- |
Gideon Weems
Member #3,925
October 2003
|
Peter Hull
Member #1,136
March 2001
|
Thanks all! ctags (unless I am mistaken) finds where each function is defined but doesn't say anything about the call graph. doxygen - I didn't know it would do this. Bravo, mon vieux! It generates the call graph very nicely but nothing in the graph shows where the functions are defined, although doxygen must have that information somewhere. Example below. {"name":"610766","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fcec657ad22d6eb1cea1f852a8275a5.png","w":552,"h":337,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/7\/f\/7fcec657ad22d6eb1cea1f852a8275a5"} gtags - is this the same as gnu global? Looks promising, will have to do some research.
|
Elias
Member #358
May 2000
|
cppcheck --enable=unusedFunction Although running it on Allegro sources, it has a lot of false positives. -- |
GullRaDriel
Member #3,861
September 2003
|
Peter: click on the box and it gets you to the function definition page, which mention file, line, parameter. Only white box are clickable, as the grey ones are terminaisons. "Code is like shit - it only smells if it is not yours" |
Gideon Weems
Member #3,925
October 2003
|
Peter Hull said: gtags - is this the same as gnu global? Yes, though if call graphs are what you're after, perhaps cflow would be more appropriate. (I've never used it, so no endorsement.) This handy page lists more options. |
Peter Hull
Member #1,136
March 2001
|
I think gtags does what I want. Thanks all, especially Gideon that page was very helpful
|
Gideon Weems
Member #3,925
October 2003
|
|