This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libiberty] Add ARG_UNUSED as a C++-friendly replacement forATTRIBUTE_UNUSED


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]