Wireshark-dev: Re: [Wireshark-dev] Unused variables
From: Gerhard Gappmeier <gerhard.gappmeier@xxxxxxxxxxx>
Date: Mon, 12 Feb 2007 15:39:29 +0100
> In fact it should be used like:
>
> void method(int foo _U_)
>
> which should become
>
> void method(int foo __attribute__((unused)))
>
> I'm not sure if _U_ is implemented for anything other than GCC, though. 
>   What compiler are you using?
>   
ok, I See.
I'm using MSVC6 on XP and GCC on Gentoo.
I just want a solution that works on every platform.

I didn't know this unused attribute of GCC,
but referencing the variable in the code is normally a good idea.

MSVC does not complain at all until you use warning level 4, what I
generally do.
void method(int foo)
{
  foo;
}
does the job for MSVC
But this causes a "statement has not effect" waning with gcc -Wall.

void method(int foo)
{
  (void)foo;
}
does the job for both.

So
#define REFERENCE_PARAMETER(name) (void)name;
works good for me.
void method(int foo)
{
  REFERENCE_PARAMETER(foo);
}

The intel compiler is a little bit different, that's why trolltech uses
this kind of define.

#if defined(Q_CC_INTEL) && !defined(Q_OS_WIN)
template <typename T>
inline void qUnused(T &x) { (void)x; }
#  define Q_UNUSED(x) qUnused(x);
#else
#  define Q_UNUSED(x) (void)x;
#endif


Are there any reasons to not use such a kind of macro?