Switch -Wunused-variable on?

Maciej W. Rozycki macro@codesourcery.com
Wed Apr 25 17:22:00 GMT 2012


On Wed, 25 Apr 2012, Andreas Schwab wrote:

> >> It also requires an unconditional declaration and definition of
> >> target_frobnicate_harder.
> >
> >  Yes, but do you see at as advantage or disadvantage?
> 
> It makes your example non-working as written due to the missing
> declaration.

 The declaration should be moved outside the conditional, I've overlooked 
that, sorry.  If target_frobnicate_harder is external then the prototype 
will be in a header anyway.

 And such an unconditional declaration is actually good for conditional 
pieces that are rarely enabled -- people making bulk changes will still 
receive the usual diagnostics about this function's argument type 
compatibility, etc. even if this piece of code is actually not used for 
the configuration they chose, as long as this source file is compiled at 
all.

 Then you don't actually need a definition, because the call will be 
optimised away (together with the whole enclosing "if (0)" block) by the 
compiler.  There's nothing wrong with having a declaration and no 
definition for an entity that's never eventually used.

  Maciej



More information about the Gdb mailing list