Hi,
I am having a look af a big C++ project with more than 100 files. Given a certain function name, how can one find just using bash tools like find or grep, the declaration and the defintion of a function?
Thanks
Hi,
I am having a look af a big C++ project with more than 100 files. Given a certain function name, how can one find just using bash tools like find or grep, the declaration and the defintion of a function?
Thanks
If you have the convention that the function definition starts at the beginning of a line, then you can use:
find . -exec egrep '^fn' '{}' ';' >/dev/null -print
if you want to limit to headers, you can put -name *.h before the -exec
NB if you want to do this a lot, look at "tags" and friends fire keeping an up-to-date index which would be faster in future.
in the very simplest case,
grep -ER '^.*(.*);' file #find declaration.
as for definition, its a bit tricky if you want to get the whole defintion. (ie. from opening braces to closing). you might want to show what you want to get by using a sample C++ file