This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wunused-macros


On 23-Jul-2002, Neil Booth <neil@daikokuya.co.uk> wrote:
>  
> > One question: will we get warnings for cases where
> > a macro is only used in a conditionally compiled piece of
> > code for which the condition is false?
> > E.g.
> > 
> > 	#define FOO ...
> > 
> > 	#ifndef __GNUC__
> > 	   ... FOO ...
> > 	#endif
> 
> This macro will be reported as unused.  I actually think that's a
> good idea - it encourages making the definition conditional along
> with the code that uses it.  Do you agree?

Not really.  I'm not convinced that making the definition conditional
is always an improvement.  Especially for cases like this,

 	#define FOO ...
 
 	#ifdef BAR1
	  ...
	  #ifdef BAR2
 	    ... FOO ...
	  #endif
	  ...
 	#endif

	#ifdef BAR3
	   ... FOO ...
	#endif

where the definition of FOO would need to be wrapped inside a
complex conditional,

	#if (defined(BAR1) && defined(BAR2)) || defined (BAR3)
	  #define FOO
	#endif

this just seems like it would add additional maintenance work
whenever the condition changes.

But I think the warning is still useful even if it gives a few
false positives in cases like this.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]