[libiberty] Add ARG_UNUSED as a C++-friendly replacement for ATTRIBUTE_UNUSED

Bernardo Innocenti bernie@develer.com
Tue Jul 13 22:45:00 GMT 2004


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/



More information about the Binutils mailing list