Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I extract a specific function from a C/C++ source code file for subsequent processing

I am looking for an easy way to print out a specific function from within some C/C++ source code. For example, assume that test.c has several functions defined within it. I want to be able to print out the source code associated with only one of those functions.

Edit: Sorry, I should be a bit more clear about my end goal. I want the function printed to the screen so I can use wc to grab the word count of this specific function. Also, I want this be part of a command line tool-chain so it isn't an option to manually enter files and select the text.


1 Answers

You can run your project through doxygen. It will index all your functions (and classes, structs etc) and can make them available in multiple formats (including PDF and HTML, both easily printable).

like image 169
codelogic Avatar answered Dec 02 '25 05:12

codelogic