[Bf-committers] unused function args & warnings.

Campbell Barton ideasman42 at gmail.com
Wed Oct 13 23:27:00 CEST 2010

On Wed, Oct 13, 2010 at 11:51 AM, Martin Poirier <theeth at yahoo.com> wrote:
> --- On Tue, 10/12/10, Campbell Barton <ideasman42 at gmail.com> wrote:
>> Id like to enable warnings in GCC for
>> unused args, however this gives
>> a lot of warnings for functions which have args which are
>> needed so
>> the function can be used as a callback.
>> This would only apply to C code in blender's source/ and
>> intern/ dirs,
>> since it doesn't make sense to modify external libs for
>> this.
> What do you expect to catch with that warning? Is it related to a real error you found in the sources?
> Martin

This mostly just helps reduce general sloppiness in blenders code - as
with unused variables.

A few times I have gone to some effort to get vars passed along to a
function (which weren't originally accessible from the caller), only
to find it wasn't used.
But this is still fairly rare, so Ill put it down to me being
pedantic, that I like to know args are used without having to
read/search the source manually.

This has got a little worse with 2.5 functions being moved around can
cause this.
GCC has some useful warnings -Wunused-parameter,
-Wunused-but-set-parameter, -Wunused-label which we could make use of
which I think would help in the long run.

Regarding how to do this, I'd prefer the UNUSED() macro, in the
function arguments, mainly because with (void)arg;, once arg becomes
used their is no error whereas with the GCC __attribute__ it does, for
portability we can use defines ofcourse.

More information about the Bf-committers mailing list