On 2 Oct 2008, at 07:11, Stewart Smith wrote:
On Thu, Oct 02, 2008 at 09:04:47AM -0400, Jay Pipes wrote:
Paul McCullagh wrote:
It's probably useful to go through each of the patches there and
re-do
some of the work. A bunch of the compiler warnings I solved in
rather
silly ways. e.g. unused parameters, i just did (void)foo; instead
of the
better solution of removing the parameter.
I'm OK with this solution for the moment. Some of these cannot be
changed because they involve callbacks which sometimes/may use the
parameters.
-1 Please let's use __attribute__((unused)) as it is clearer and
indicates to the caller that the argument is not currently used...the
(void)foo; approach doesn't make it clear in the function declaration
that the parameter isn't used.
I remember previously having portability issues with this approach
(rather than cast to (void))... can't remember which platform
though...
I'm guessing HPUX or Solaris or Windows... they usually cause me pain
and memory loss.
using (void)x to silence unused parameters is not good and can cause
warnings by itself with some compilers. (statement has no effect)
An option available for most C++ compilers is to omit the argument
name... so..
int test1(int a, int b __attribute__((unused)), int c)
{ return a + c; }
can be written as:
int test2(int a, int, int c)
{ return a + c; }
The drawback... it won't compile in C mode.
It may be desirable to set a define depending upon the behavour of the
compiler:
#ifdef HAVE_ATTRIBUTE_UNUSED
#define UNUSED(X) X __attribute__ ((UNUSED))
#endif
#define UNUSED(X)
#endif
int test3(int a, int UNUSED(b), int c)
{ return a + c; }
Regards,
Antony.
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp