[comp.lang.c] C compilers/variables

jerry@starfish.Convergent.COM (Gerald Hawkins) (04/28/89)

Is anyone aware of a program to analyze a c-program for the variables it
uses, producing a table showing the usage?  I had a Fortran compiler
which did this once, but I've not seen it for c.

An example of the output I would want:
Variable_Name       Used on Line(s)
a                   37, 43, 53 (main)
b                   21 (global)
					45, 57, 63 (main)
					135, 145, 159 (crashsystem)
					175, 185, 195 (fixsystem)

Function_Name
getch()             47, 49, 51 (main)
					136, 139, 143 (crashsystem)

I think you get the idea.  The purpose of this is to help track down
variables--especially global ones--which you might overlook while
maintaining code.  Also when writing code, to help remind one to #include
the necessary headers for the functions used.



"	I don't want to imply I'm underpaid, but ...
	Last time I took my paycheck to the bank to be cashed, the teller
	asked me, 'How would you like that, sir, Heads, or Tails?'	"

Jerry		( jerry@starfish.Convergent.COM )
-----

gwyn@smoke.BRL.MIL (Doug Gwyn) (04/29/89)

In article <996@starfish.Convergent.COM> jerry@starfish.Convergent.COM (Gerald Hawkins) writes:
>Is anyone aware of a program to analyze a c-program for the variables it
>uses, producing a table showing the usage?

On UNIX systems, "cref" and "cflow" will probably meet your needs.
Some implementations don't provide these, but they may have something
similar.  Nag your vendor.