[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.9,1.10
From: |
David Philippi |
Subject: |
Re: [Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.9,1.10 |
Date: |
Thu, 15 Aug 2002 18:21:30 +0200 |
User-agent: |
KMail/1.4.1 |
On Thursday 15 August 2002 16:10, Ingo Ruhnke wrote:
> I find these empty 'if's rather ugly. We should probally replace them
> with something like:
> #define UNUSED_ARGUMENT (x) if(x);else;
> #ifdef GCC
> #define UNUSED_ARGUMENT (x) __attribute__ ((unused)) x
> #endif
Sure, the only problem is - where do you define those macros? I don't know of
a header included by everyone. But since we also have things like
#ifdef WIN32
#define for if();else // or similar ;-)
#endif
It may be a good idea to have a header defining some basic included
everywhere (or rather in as much headers as required to be everywhere).
> or what ever the compiler likes most.
I've found two variants:
1) #define UNUSED_ARG(a) (a)
2) #define UNUSED_ARG(a) do {/* null */} while (&a == 0)
The first is simpler and probably faster thrown away from the compiler but
may issue warnings with some compilers (statement with no effect), the
second should work all the time and generates no code at all if
optimizations are enabled. Without -O some compilers may generate code for
this.
> The last one could be used like:
> void foobar (float x, int UNUSED_ARGUMENT (y))...
> while the other ones would be placed in the function body:
> void foobar (float x, int y) {
> UNUSED_ARGUMENT (y);
> ...
> }
>
> Not sure if windows provides something simalar to the __attribute__
> thing of GCC.
I've never heard of the __attribute__ in GCC before, but if they don't
support __FUNCTION__ I consider it unlikely. Then there's the fact that I
dislike having the UNUSED_ARGUMENT in the declaration of the function, such
things are better placed at the end where you see them only if you look at
the whole function and when you reach one you know that there's no code
following anymore.
Bye David