[lug] C programming Q.
David Morris
lists at morris-clan.net
Wed Apr 17 12:50:20 MDT 2002
Quoting rm at fabula.de:
> On Wed, Apr 17, 2002 at 11:41:01AM -0600, Bear Giles wrote:
> > > On Wed, Apr 17, 2002 at 11:54:41AM -0500, Michael J. Hammel wrote:
> > > > I hate this. We're using some gawd-awful args to gcc that force
> > > > all warnings into errors so compiles fail. Ick.
> > >
> > > No, this is a _good_ habbit, really ;-) Since i made this the
> > > default in my projects (and cranked up the warning switches) i had
> > > way less bugs sneak into my production code.
> >
> > I dislike the forced warnings->errors coercion for two reasons.
> > First, there are some rare situations where you can't easy eliminate
> > the warnings. These are very rare, maybe only once every 10 kloc, but
> > like gotos when you need them you really need them.
>
> Yes, indeed, there are some rare situations when it's really hard or
> even impossible to get the code warning-free.
>
> > Second, as a practical matter this coercion usually ends up driving
I can bug agree that on *rare* occations one cannot get the code
completely warning-free, however it should be tried for whenever
possible.
I have had to deal with *lots* of "Junior Programmers" (some of which
have theoretically been programming longer than me, but I can never
quite figure out how) and whenever they complain about the warning
flags (or reporting warnings as errors) I tell them this:
You are a Software Engineer, but consider if you were a Structural
Engineer instead. You are building a bridge, and someone warns you there
looks to be a crack in one of the supporting pillars. Do you ignore the
warning? NO! If you do, it is likely that someday the bridge will
collapse and people will die.
Just because the code we write is does not (usually) have peoples lives
depending on the quality of our work does NOT mean that we can ignore
warnings that crop up. We must investigate the warning, and fix the
problem behind the warning whenever possible. It might take time, it
might get to be very annoying some days, but the end product will be
vastly improved. Development will finish sooner in the long-run, and
users will find fewer faults in the software. The simple task of
investigating a few minor warnings *now* means the difference between
lots of money and bankrupcy *later*.
So please, for users (and the sanity of lead programmers :) everywhere,
PLEASE PLEASE PLEASE always use as many warning flags as possible with
your code!
--David
More information about the LUG
mailing list