Advertisement
Advertisement


What is a good tool to aid in browsing/following C code?


Question

I sometimes need to modify OSS code or other peoples' code (usually C-based, but sometimes C++/Java) and find myself "grep"ing headers for types, function declarations etc. as I follow code flow and try to understand the system. Is there a good tool that exists to aid in code browsing. I'd love to be able to click on a type and be taken to the declaration or click on a function name and be taken to it's implementation. I'm on a linux box, so replies like "just use Visual Studio" won't necessarily work for me. Thanks!

2009/08/22
1
12
8/22/2009 8:18:49 PM


I use Vim with ctags and taglist plugins. You can move the cursor to a variable name and with a key combination it will take you to the declaration of the variable (and back). Taglist will also show an overview of all functions, classes etc. in a side bar.

2008/09/16

I've heard amazing things about OpenGrok. I know another team at my place of employ uses it and they find it very handly. From its web site:

OpenGrok is a fast and usable source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It can understand various program file formats and version control histories like Mercurial, Git, SCCS, RCS, CVS, Subversion, Teamware, ClearCase, Perforce and Bazaar. In other words it lets you grok (profoundly understand) the open source, hence the name OpenGrok. It is written in Java.

2013/05/14

Doxygen can generate an set of web pages that include a source browser. Not quite as fancy as an IDE, but all it needs is a web browser.

2018/12/12

The Eclipse IDE is capable of working with C/C++ in addition to Java. There is a write-up on how to configure Eclipse for C/C++ development on IBM's Developer Works site.

edit: Why has this been voted down? It is a valid answer. Eclipse with the C/C++ addon will allow the question author to do what he is wanting to do. I am not the only one to have suggested, yet the others have not been voted down. So why has this one been voted down?

2008/09/16

I do a bit in the kernel space, and keep coming back the scope.

For example:

$ cd /usr/src/redhat/BUILD/kernel-version

$ cscope -R -p4

   Find this C symbol:
   Find this function definition:
   Find functions called by this function:
   Find functions calling this function:
   Find this text string:
   Change this text string:
   Find this egrep pattern:
   Find this file:
   Find files #including this file:

I usually "live" in c-scope when working on someone elses project. I use this to open files with "gvim" (my IDE), edit things, then quit "back" to c-scope, It helps me keep task focused.

I believe that cscope can be configured to work with vim and emacs, although I've seen people use other editors also.

Best of luck to you.

2008/09/16

Source: https://stackoverflow.com/questions/68247
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]