Re: warnings
Re: warnings
- Subject: Re: warnings
- From: Miklós Fazekas <email@hidden>
- Date: Tue, 11 Oct 2005 19:50:36 +0200
The solution is to write warning-free code.
I always thought I'm hopelessly behind times; I don't even bother to
test the code I've just written before I've fixed all warnings. All
warnings emitted with -Wall switched _on_, of course.
But recently, quite a few people told about a zero-warning policy in
their company. I should re-adjust my felt position in time ;-)
One should not forget writing warning free code is not the goal.
Warnings are just a tool. The goal is writing better code.
A lot of times there are warnings that do not apply to your code.
Fixing them could results in worse code. Turning off a warning is
much better than "fixing" the code is such cases.
With Visual Studio we use 'treat warnings as errors' with 'warning
level 4'. It gives a more stupid warnings than gcc, but we can at
switch off any warning we're not interested in.
(b) Warnings can be turned off by number globally or for a
particular file.
Nobody stops you to add a -Wno-... flag to a single file.
GCC does. Only selected warnings has a -Wno- flag.
Had warnings a number, it wouldn't be the case.
Currently we're using a perl script to filter out warnings. But GCC
badly needs better warning control mechanism.
Regards,
Miklós
ps.:
Example for a stupid gcc warning you can't turn off is 'anynomous
enum' vs 'anynomous enum' mismatch in conditional expression. Some
code that results such a warning:
DrawThemeEditTextFrame (&rect,
IsControlActive
(theControl) ? kThemeStateActive : kThemeStateDisabled);
return (*read == nOfCharToRead ? NoError : EndOfInput); //
EndOfInput is a different anymous enum than NoError
We consider the above codes correct. We're not going to add casts to
them just because GCC doesn't have usefull warning control.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden