Re: lots of unused variable warnings in assert-free builds - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: lots of unused variable warnings in assert-free builds
Date
Msg-id 4F12D14C.20700@dunslane.net
Whole thread Raw
In response to Re: lots of unused variable warnings in assert-free builds  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: lots of unused variable warnings in assert-free builds  (Simon Riggs <simon@2ndQuadrant.com>)
Re: lots of unused variable warnings in assert-free builds  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers

On 01/15/2012 01:37 AM, Tom Lane wrote:
> Peter Eisentraut<peter_e@gmx.net>  writes:
>> I see that in some places our code already uses #ifdef
>> USE_ASSERT_CHECKING, presumably to hide similar issues.  But in most
>> cases using this would significantly butcher the code.  I found that
>> adding __attribute__((unused)) is cleaner.  Attached is a patch that
>> cleans up all the warnings I encountered.
> Surely this will fail entirely on most non-gcc compilers?  Not to
> mention that next month's gcc may complain "hey, you used this 'unused'
> variable".  I think #ifdef USE_ASSERT_CHECKING is really the only way
> if you care about quieting these warnings.  (Personally, I don't.)
>
>             


It would possibly have some documentary value too. Just looking very 
quickly at Peter's patch, I don't really understand his assertion that 
this would significantly butcher the code. The worst effect would be 
that in a few cases we'd have to break up multiple declarations where 
one of the variables was in this class. That doesn't seem like a tragedy.

I like software that compiles in the normal use with few or no warnings. 
I should have thought that would appeal to most packagers, too.

cheers

andrew


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: age(xid) on hot standby
Next
From: Simon Riggs
Date:
Subject: Re: lots of unused variable warnings in assert-free builds