Due to paperwork that has to be filled out, I need to know how many functions exist in an entire C project.
The project is split across multiple folders, so ideally what I am looking for is something where you can type in:
FindAllTheFunctions --recursive /path/to/folder
And the result is written something like:
/path.../filename: int foo(float bar)
.
.
.
/path.../final/filename: double foo2(int bar2)
How could I get results of this nature?
Many thanks!
cproto
which will scan C-source files creating a concise list of the function declaration. You can collected the declarations from all files in your project. It does a wonderful job. http://invisible-island.net/cproto/cproto.html. Give it a look.f
in the last field; those are functions; the first field is the function name, the rest isn't interesting for you. Counting these lines will give you the number of function definitions in your project.grep
might not be the best tool for extracting function declarations (for simple declarations it's certainly works though) once you have the output fromctags
orcproto
you can usegrep
to extract the information you want. For example using the file generated byctags
you cangrep
for the trailingf
and usewc
to count the number of lines, which should correspond to the number of functions.