Re: lots of unused variable warnings in assert-free builds

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lots of unused variable warnings in assert-free builds
Date: 2012-01-18 19:15:52
Message-ID: 1326914152.9180.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On sön, 2012-01-15 at 01:37 -0500, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)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?

No, because __attribute__() is defined to empty for other compilers. We
use this pattern already.

> Not to
> mention that next month's gcc may complain "hey, you used this 'unused'
> variable".

No, because __attribute__((unused)) means "that the variable is meant to
be possibly unused".

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2012-01-18 19:16:56 Re: lots of unused variable warnings in assert-free builds
Previous Message Dimitri Fontaine 2012-01-18 19:03:29 Re: Command Triggers