views:

134

answers:

3

Is there any tools to assist in diagramming a large C library? I am working on a project to port an existing C library to C++. The C library is largely undocumented with no diagrams. I would like to use a CASE tool to help me understand how the various files interact. There is extern variables in most of the files.

If possible I would prefer a visual diagram to better understand the flow of the code. I am not familiar with a diagramming tool for procedual lanagues (or if it even exists). I remember in college we use to use hierarchy and data flow diagrams for procedual languages.

I know there exists many tools for diagramming OO lanaguages, but I would like one for C. Any help would be appreciated.

Suggestions:


doxygen

It can help you in three ways:

It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual (in ) from a set of documented source files. There is also support for generating output in RTF (MS-Word), PostScript, hyperlinked PDF, compressed HTML, and Unix man pages. The documentation is extracted directly from the sources, which makes it much easier to keep the documentation consistent with the source code. You can configure doxygen to extract the code structure from undocumented source files. This is very useful to quickly find your way in large source distributions. You can also visualize the relations between the various elements by means of include dependency graphs, inheritance diagrams, and collaboration diagrams, which are all generated automatically. You can even `abuse' doxygen for creating normal documentation.


cppdepend

  • opensource/academic and commercial licence (MSVS plugin)

Improve your code base quality. CppDepend is a tool that simplifies managing a complex C\C++ (Native,Mixed and COM) code base. Architects and developers can analyze code structure, specify design rules, do effective code reviews and master evolution by comparing different versions of the code. These Cases Studies shows the utility of CppDepend to have a deep view of your architecture, design and implementation. Refactor and Improve your design and architecture. CppDepend provides useful graphs to analyze your design and architecture. CQL language gives you a flexibility to create your custom queries and have a deep view of your code base. here's a sample of using CppDepend to assist your refactoring. Assist your migration. Understanding the existing migration. CppDepend helps you in your migration process, you can find here the advantages of using CppDepend in your migration process.


ctag

  • (nedit, vim, emacs) VIM TUTORIAL
    • class names
    • macro definitions
    • enumeration names
    • enumerators
    • function definitions
    • function prototypes/declarations
    • class, interface, struct, and union data members
    • structure names
    • typedefs
    • union names
    • variables (definitions and external declarations)

csope

  • (cmd line, vim) VIM TUTORIAL
    • Allows searching code for:
    • all references to a symbol
    • global definitions
    • functions called by a function
    • functions calling a function
    • text string
    • regular expression pattern
    • a file
    • files including a file
+7  A: 

Doxygen can generate various types of interaction diagrams - files, function calls, etc. With the EXTRACT_ALL configuration variable set, it will generate diagrams and cross-referenced documentation even for code without documentation comments.

Nick Meyer
+3  A: 

Doxygen as mentioned by Nick Meyer is probably a good bet. You can also try the classic cross-referencing tools ctags and cscope, that you can use as standalone tools or integrated with your text editor.

src
cscope looks great but I am working in a Windows environment. It looks like a better version of MSVS NCB intelliense file (http://msdn.microsoft.com/en-us/library/ms379615(VS.80).aspx). However, cscope gives you the ability to query your database.
Shiftbit
+2  A: 

CppDepend, if you work on Windows, extends Doxygen with a query language and ability to move in the dependency graph.

plodoc