This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [libiberty] Add ARG_UNUSED as a C++-friendly replacement forATTRIBUTE_UNUSED
- From: Bernardo Innocenti <bernie at develer dot com>
- To: Bernd Schmidt <bernds at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, Andrew Pinski <pinskia at physics dot uc dot edu>,GCC Patches <gcc-patches at gcc dot gnu dot org>, gdb-patches at sources dot redhat dot com, binutils at sources dot redhat dot com, Ian Lance Taylor <ian at wasabisystems dot com>, DJ Delorie <dj at redhat dot com>
- Date: Wed, 14 Jul 2004 00:44:58 +0200
- Subject: Re: [libiberty] Add ARG_UNUSED as a C++-friendly replacement forATTRIBUTE_UNUSED
- Organization: Develer S.r.l.
- References: <200407120419.i6C4Jq318362@tin.geop.uc.edu> <40F3944C.1000502@develer.com> <20040713081153.GA3089@redhat.com> <Pine.LNX.4.56.0407132255170.4658@hades.cambridge.redhat.com>
Bernd Schmidt wrote:
> On Tue, 13 Jul 2004, Richard Henderson wrote:
>>On Tue, Jul 13, 2004 at 09:50:36AM +0200, Bernardo Innocenti wrote:
>>
>>#ifdef __cplusplus
>># define ARG_UNUSED(N)
>>#elif somegccversion
>># define ARG_UNUSED(N) N ATTRIBUTE_UNUSED
>>#else
>># define ARG_UNUSED(N) N
>>#endif
>
> That fails in cases where the argument is unused only on some targets
> and needed by others.
For those (few) cases, I've handled it by moving ATTRIBUTE_UNUSED
before the typename, which seems to work G++ 3.3 too.
> What's wrong with just disabling ATTRIBUTE_UNUSED for compilers that
> can't handle it?
- You get lots of annoying warnings in stage1 and when building
a cross compiler;
- If we switch to C++, ARG_UNUSED would allow using the standard
C++ syntax for unused arguments;
- libiberty.h is used in other projects and it's about portability
across different compilers and platforms. The ATTRIBUTE_UNUSED
macro cannot be made to work usefully with all compilers,
therefore it must be replaced with something more portable;
- "int ARG_UNUSED(foo)" is shorter, more readable and sexier than
"int foo ATTRIBUTE_UNUSED".
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/