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

Renato Perini rperini at email.it
Sun May 28 22:52:25 CEST 2006


Why not use just a "-Wno-unused" flag passed to the compiler?

Ken Hughes ha scritto:
> 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)))
>
> or
>
> #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))
> #else
> #define UNUSED(x) x
> #endif
>
> Ken
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
>

 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Hai dei virus sul tuo PC ma non sai come eliminarli? Allora impara subito come rimuovere ogni tipo di virus
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=5057&d=28-5


More information about the Bf-committers mailing list