Reputation: 7947
Is there a flag I can set so that the compiler (linker?) will output a list of all the functions called by (not just defined in) each separate source file during the compilation(linking) process?
Thanks,
Upvotes: 4
Views: 2006
Reputation: 99374
Compile it into an object file and get the list of undefined external symbols in it. You can get the list automatically with the proper tools for your platform: in Linux it's readelf
.
Upvotes: 1
Reputation: 93556
For an individual function, right-click, and select Call-Browser->Show Call Graph.
If you do this from main() you get a call tree for the main() thread. You would have to do this on the entry point of each thread to get a complete view of a multi-threaded application. It may not handle functions invoked through pointers of course.
Upvotes: 1
Reputation: 3312
or you can use a different editor. For instance, SourceInsight does a great job producing call/calledby graphs real time in the editor.
For a programmatic output: I found oing C code unit testing on a shoestring very interesting. For Visual Studio it needs some manual work since Visual Studio has poor C99 compatibility.
External tools (like doxygen and CppDepends) are very useful, as long as you can live with 2 constrainst:
For the static dependencies, consider the following example:
void foo(boolean b)
{
if (false == b)
{ bar1(); }
else
{ bar2(); }
}
Static tools will then output both bar1 and bar2. A runtime call graph would show either bar1 or bar2 depending on the value of the parameter.
Upvotes: 0
Reputation: 30819
You can try CppDepends to generate dependency map of your project along with some other useful information
Upvotes: 2