Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Angband > Re: Compiler wa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 9 Topic 6470 of 6642
Post > Topic >>

Re: Compiler warnings.

by Antony Sidwell <antony@[EMAIL PROTECTED] > Mar 20, 2008 at 03:42 PM

roustk wrote:

> Actually, having just tried this, -pedantic doesn't seem to do it.  I
now 
> get warnings about C++ style comments, but nothing more.  I'll play 
> with Shanoah's full list, though.  (Pointer arithmetic is bad?  We're in

> trouble...)

Just a quick summary of the warnings enabled there, and why you do or
don't want to use the options (all IMO obviously)...

-pedantic is a good one if you want your code to be ****table.  Without
it, you're not going to get warned about various actually illegal (in
the sense of non-standard) constructions.

-Wall turns on a whole load of mostly useful warnings - particularly
warnings of possible initialised variables, unused "static" functions,
and so on.

-Wextra turns on a few warnings such as -Wmissing-parameter-type and
-Wold-style-declaration that can be useful sometimes, but also a couple
of no particular use, and one you really want to turn off (see
missing-field-initializers).

-Wpointer-arith is already enabled by -pedantic, but is useful as it
doesn't warn of all pointer arithmetic, just relying on sizeof(void) and
similar non-standard things.

-Wc++-compat would be useful if you had some reason to write code
compatible with C++ I suppose, but that's not true of most programs, and
certainly isn't true of Angband.

-Wcast-qual is pointless - there are times when you want a function to
take a "const char *" for instance to tell the caller that you won't
modify the contents of the pointed-to thing, but it's useful to cast
away the const to avoid the genuinely useful warning about implicitly
discarding it.  The presence of the cast should be enough warning for
anyone reading the code to be careful what they're doing.  Enable it
sometimes if you want, but only to highlight them to be checked in a
code audit, not in a regular build.

-Wmissing-field-initializers is turned on by -Wextra (or used to be
anyway) and is actively undesirable.  The pain caused by initialising
every field of every structure/union is far greater than the pain caused
by possibly forgetting to initialise something you meant to.  The
shorthand is there because it's useful, especially if you're extending a
data structure with an optional field at the end. :)

So if you're looking for more warnings, I'd say you'd be best off with
"-ansi -pedantic -Wall -Wextra -Wno-missing-field-initializers
-Wno-unused-parameter".  For everyday builds anyway. :)
-- 
Antony "Not the maintainer" Sidwell
 




 9 Posts in Topic:
Compiler warnings.
pete m <pmac360@[EMAIL  2008-03-19 19:50:10 
Re: Compiler warnings.
roustk <roustk@[EMAIL   2008-03-20 03:34:14 
Re: Compiler warnings.
pete m <pmac360@[EMAIL  2008-03-19 21:36:20 
Re: Compiler warnings.
roustk <roustk@[EMAIL   2008-03-20 14:25:21 
Re: Compiler warnings.
Antony Sidwell <antony  2008-03-20 15:42:44 
Re: Compiler warnings.
Antony Sidwell <antony  2008-03-20 08:37:00 
Re: Compiler warnings.
"arcum42@[EMAIL PROT  2008-03-20 04:54:40 
Re: Compiler warnings.
pete m <pmac360@[EMAIL  2008-03-20 09:01:16 
Re: Compiler warnings.
"arcum42@[EMAIL PROT  2008-03-20 13:51:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 4:49:07 CDT 2008.