On Mon, Jan 07, 2002 at 11:03:05PM +0000, Nicholas Clark wrote: > --- include/parrot/parrot.h~ Sat Dec 15 14:21:03 2001 > +++ include/parrot/parrot.h Mon Jan 7 21:56:40 2002 > @@ -68,6 +68,11 @@ > typedef void* BIGINT; > typedef void* BIGFLOAT; > > +/* define a macro to acknowledge an unused argument, and silence a "helpful" > + compiler warning. gcc will emit a warning on an empty if body unless {} is > + used to make an empty block. */ > +#define UNUSED(a) if (0 || a) {} > + > #include "parrot/global_setup.h" > #include "parrot/interpreter.h" > #include "parrot/encoding.h" > --- ./encodings/singlebyte.c.orig Tue Jan 1 20:35:56 2002 > +++ ./encodings/singlebyte.c Mon Jan 7 22:34:07 2002 > @@ -16,6 +16,8 @@ > > static UINTVAL > singlebyte_characters (const void *ptr, UINTVAL bytes) { > + UNUSED (ptr); > + > return bytes; > }
For gcc, an alternative would be #define UNUSED(var) __attribute__((unused)) var static UINTVAL singlebyte_characters (const void * UNUSED(ptr), UINTVAL bytes) { return bytes; } or even #define UNUSED __attribute__((unused)) static UINTVAL singlebyte_characters (const void UNUSED *ptr, UINTVAL bytes) { return bytes; } I just mention it because I'm wondering if with the first version I gave, you could just do #define UNUSED(var) to wipe out variable names. gcc doesn't like that (though it's fine with it for forward declarations of functions), but I thought maybe it would appeal more to other compilers. My only complaints with 'if (0 || a) {}' are (1) I can easily see it getting optimized away and complaining anyway on a later gcc version or different compiler, and (2) it means you have to put all the UNUSED() after the variable declarations: int f(int x, int y) { int i = x + 1; float f; char* s = malloc(256); UNUSED(y); /* body */ } ....but it's still the most portable of the alternatives I see, so I guess it should stay that way in wait of a better idea.