This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: Switch -Wunused-variable on?


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


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