[Bf-committers] Solution for suppressing "unused parameter" warnings?

Ken Hughes khughes at pacific.edu
Sat May 27 16:26:51 CEST 2006

I'm getting annoyed by all these warnings for "unused parameters", 
mainly in the Python code.  For my own sanity, I've started using 
someone else's trick of renaming unused parameters to "X_unused" just so 
when I see them, I know they're really intended.  But the forest of 
these X_unused warnings still hide the real ones.

I discovered GCC and some other compilers implement the keyword 
__attribute__, which shuts up the complaints very nicely with gcc v3.4.x:

static PyObject *M_Mesh_New(BPy_Mesh *self __attribute__ ((unused)))


#define UNUSED(x) x __attribute__ ((unused))
static PyObject *M_Mesh_New(BPy_Mesh *UNUSED(self))

Of course, don't know if everyone else's compilers will be happy with 
this. The other option which works is simply to use the stupid variable 
somewhere in the body.  Pointers are easy:

static PyObject *M_Mesh_New(BPy_Mesh *self) {
   self = NULL;

But again, don't know if non-gcc compilers will be happy.

Can we discuss and arrive at some solution for this?  If nothing else, 
maybe I'll pick a nice, general-purpose *.h file and add:

#if defined (__linux__)
#define UNUSED(x) x __attribute__ ((unused))
#define UNUSED(x) x


More information about the Bf-committers mailing list