Date: Sun, 8 Dec 1996 16:51:23 +0200 (IST) From: Eli Zaretskii To: George Foot cc: djgpp AT delorie DOT com Subject: Re: v2 funnies In-Reply-To: <32a7674d.11527979@news.ox.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Fri, 6 Dec 1996, George Foot wrote: > > (2) How can I look through a big Gnu C++ program for unused functions and > >global variables? I was once advised to use NM, which I just did; but I could > >not see in its output anything that told me whether each symbol is ever > >referred to or not. > > If you compile the program with -Wall (I think) it will point out > unused variables, and the lines they are declared on. You might also > need to turn on optimisations (e.g. -O2). Note that gcc will ignore > these unused parameters/variables anyway. This is only true for (a) local (automatic) variables which aren't used in the block that declares them and (b) for global variables declared static which aren't used anywhere on the current source file. If you declare a global variable which isn't static, like so: int unused_var; the compiler has no way of knowing if the variable is used on any other files, so it won't say a thing, even with -Wall.