Here’s a problem I’ve had recently that just HAS to be a common pain to others here.
I’m working with someone else’s legacy C code and need to find where a function or macro was defined. The code #includes a bunch of different standard system libraries in addition to those from the specific project.
Is there a tool or technique to quickly find where a specific function, macro, (or other global for that matter) was defined?
I tried:
grep -R 'function' /usr/lib
and other similar *nix/bash-fu with only limited success and lots of annoying chaff to cull. One of you sage coders out there must have a good solution to this seemingly common scenario.
I was very surprised to not find another question on this particular pain here or in my searches of the interwebs. (I’m sure there will be angry comments if I missed one… ;-))
Thanks in advance for any tips!
Use
etags/ctagsfrom the exuberant ctags project in conjunction with an editor (emacs, vim) that understands them, or GNU GLOBAL.Oh, and if you happen to use automake it generates a target
TAGS. So no need for complicated manual calls to{c,e}tags.