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: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: 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: Tue, 13 Jul 2004 09:50:36 +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>
Andrew Pinski wrote:
>>this patch adds the ARG_UNUSED() macro to be used in place of
>>ATTRIBUTE_UNUSED. The syntax looks like this:
>>
>> void foo (ARG_UNUSED (int, x))
>> {
>> }
>>
>>The C++ frontend can't parse attribute((unused)) when it
>>appears after the variable name. The cleanest work-around
>>is using the standard C++ syntax to specify unused
>>parameters, which can also be used when bootstrapping from
>>other C++ compilers.
>>
>>This patch is a prerequisite for the upcoming C++ bootstrap
>>patches that I've been preparing.
>
>
> Huh? Yes it can from 3.4.0 and above.
Nevertheless, bootstrap from earlier versions of GCC
would fail (I was using Apple's version of GCC 3.3).
ansidecl.h enables ATTRIBUTE_UNUSED for any GCC > 2.7.
We could make the check stricter, like this:
#if !defined(__cplusplus) || GCC_VERSION >= 3004
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
But I'd much prefer the ARG_UNUSED solution, which can
be made to work with and C or C++ compiler, using whatever
funny syntax the compiler requires.
This macro is in libiberty, which is about portability
across different OSes and compilers.
I also like the ARG_UNUSED syntax because it's somewhat
shorter to type. (btw, Doxygen can parse it if you
define ARG_UNUSED(T,N) to "T N").
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/