www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/10/17:48:45

Date: Sun, 8 Dec 1996 16:51:23 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: v2 funnies
In-Reply-To: <32a7674d.11527979@news.ox.ac.uk>
Message-ID: <Pine.SUN.3.91.961208164815.3423I-100000@is>
MIME-Version: 1.0

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.

- Raw text -


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