IAmRedScarf IAmRedScarf - 1 year ago 51
C Question

Get all function name and line number for c/c++ source code

Here is a project source code folder for c/c++. I want to write a small and fast tool/script to get the filename, line number, and function name for all files.

For example, I want it will output like below:

./src/a.c line 1500 call func1();
./src/a.c line 1600 call func1();
./src/a.c line 1700 call func2();
./src/b.c line 1700 call func3();

How to do it with any tools or language?

Answer Source

If you are under gcc:

gcc -aux-info output app.c
sed '/include/d' output

The sed line excludes stdlib functions from the result.