www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/11/29/05:39:52

Date: Tue, 29 Nov 1994 17:15:11 +0900
From: Stephen Turnbull <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
To: A DOT APPLEYARD AT fs1 DOT mt DOT umist DOT ac DOT uk, djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Unused variables

   >   In djgpp, how can I get a list of all variables and labels in a
   > program which are declared but not used? I was editing a program
   > which someone wants me to make it more efficient, and in the
   > process many variables became redundant, and I want to find them
   > by some means quicker than having to search for every one with my
   > emacs's search-for-word.

   Compile with the -Wall switch.  This will take care of most local and
   static variables.  As for globals, you have to "nm" the object files
   looking for references to them - it's not automatic.

Of course the religously correct answer is to run Emacs' tags function
on the source.  :-)  Since I don't write programs that take more than
one screen in 80x50 mode, I don't use it :-) :-)  Look in Info for
usage instructions.
    Seriously, it's an alternative.  And it does have the advantage
that you not only find the places where the unused variable gets
declared, but you can find all the places where the variable you
thought you weren't using any more is still being used.  OOooops.
    --Steve

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019