ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Unused variables

From: Michael Tuexen <Michael.Tuexen@xxxxxxxxxxxxxxxxx>
Date: Mon, 12 Feb 2007 17:39:47 +0100
Question in-line.

Best regards
Michael

On Feb 12, 2007, at 3:39 PM, Gerhard Gappmeier wrote:


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
Isn't it C++? Wireshark uses only C.


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


_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev