Unused variables, better as error or warning?
Walter Bright
newshound2 at digitalmars.com
Fri Aug 20 16:23:32 PDT 2010
bearophile wrote:
> Walter Bright:
>> Not every problem is worth using a sledgehammer to deal with.
> Giving a warning where you have not used a variable is not a sledgehammer,
> it's a light thing, that helps keep code tidy and once in a while helps avoid
> bugs.
My point is it is not a light thing. It negatively and irritatingly impacts
normal coding practices. Adding in pragmas uglifies the code. More compiler
switches increases the cognitive load.
(I've seen many build scripts for C/C++ that include a long list of switches. I
ask the developer what those switches do, he often has no idea. He just copied
the list of switches from some other project.)
So it's a tradeoff. How much time do you save when it finds an actual bug, vs
how much time it costs you to futz around trying to suppress invalid warnings.
More information about the Digitalmars-d
mailing list