Yes, indeed, I meant to say, "the first non-whitespace character on the line". Oops.
BTW -- consider -W as well. It enables some other useful warnings I believe.
(Italic hashes look very strange in this font, whatever it is. They appear to have only one semi-vertical line. Well, it's actually two fused directly together, because it looks a bit thick. It's just strange. )
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
-W didn't do anything more with the example program, but thanks for the tip.
>Italic hashes look very strange in this font, whatever it is.
Congratulations DWK, you speak Chinese!
No, I wasn't really expecting it to. I just meant in general:-W didn't do anything more with the example program, but thanks for the tip.
From http://gcc.gnu.org/onlinedocs/gcc-3....%20Options-W
Print extra warning messages for these events:
* A function can return either with or without a value. (Falling off the end of the function body is considered returning without a value.) For example, this function would evoke such a warning:
Code:foo (a) { if (a > 0) return a; }
* An expression-statement or the left-hand side of a comma expression contains no side effects. To suppress the warning, cast the unused expression to void. For example, an expression such as x[i,j] will cause a warning, but x[(void)i,j] will not.
* An unsigned value is compared against zero with < or <=.
* A comparison like x<=y<=z appears; this is equivalent to (x<=y ? 1 : 0) <= z, which is a different interpretation from that of ordinary mathematical notation.
* Storage-class specifiers like static are not the first things in a declaration. According to the C Standard, this usage is obsolescent.
* The return type of a function has a type qualifier such as const. Such a type qualifier has no effect, since the value returned by a function is not an lvalue. (But don't warn about the GNU extension of volatile void return types. That extension will be warned about if -pedantic is specified.)
* If -Wall or -Wunused is also specified, warn about unused arguments.
* A comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. (But don't warn if -Wno-sign-compare is also specified.)
* An aggregate has a partly bracketed initializer. For example, the following code would evoke such a warning, because braces are missing around the initializer for x.h:
Code:struct s { int f, g; }; struct t { struct s h; int i; }; struct t x = { 1, 2, 3 };
* An aggregate has an initializer which does not initialize all members. For example, the following code would cause such a warning, because x.h would be implicitly initialized to zero:
Code:struct s { int f, g, h; }; struct s x = { 3, 4 };
Er -- what? How are strange italic hashes Chinese? Actually, come to think of it . . .>Italic hashes look very strange in this font, whatever it is.
Congratulations DWK, you speak Chinese!
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I do not recall there being a Chinese word that is pictorially equivalent to a #.
But yeah, I always assumed -W was some subset of -Wall. The "all" apparently is rather misleading.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The following is a snippet from the GCC man page (-W being the same as -Wextra):
-Wall
All of the above -W options combined. This enables all the warn-
ings about constructions that some users consider questionable, and
that are easy to avoid (or modify to prevent the warning), even in
conjunction with macros. This also enables some language-specific
warnings described in C++ Dialect Options and Objective-C and
Objective-C++ Dialect Options.
The following -W... options are not implied by -Wall. Some of them
warn about constructions that users generally do not consider question-
able, but which occasionally you might wish to check for; others warn
about constructions that are necessary or hard to avoid in some cases,
and there is no simple way to modify the code to suppress the warning.
-Wextra
(This option used to be called -W. The older name is still sup-
ported, but the newer name is more descriptive.) Print extra warn-
ing messages for these events:
There was a message about that somewhere . . . I can't find it at the moment. Apparently, enabling all warnings is a bad idea, because some are very inefficient and give lots of false positives. The "-Wall" is what the GCC developers think is a good set of warnings to use, and you can enable and disable warnings from there.But yeah, I always assumed -W was some subset of -Wall. The "all" apparently is rather misleading.
As for the name -- it's misleading, but it's a salute to Perl's -Wall, I believe.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I don't know that I'll use -W regularly though, because as dwks said, some of them might be unwanted. But I'll give it a shot.Don't look at me, dwk's the one who knows chinese.
But it (#) looks kind of like this: http://en.wikipedia.org/wiki/Image:C...r_Niu_Trad.png
No, what I meant was that enabling every single one of GCC's warnings would be a bad idea. However, even "-W -Wall" doesn't even come close to enabling all of its warnings. I highly recommend using "-W -Wall", or -Wextra if you don't mind the extra typing. (Sorry, couldn't resist.)
[edit] Personally, I hate any extra typing at all. alias is fantastic. [/edit]
I deny everything.Don't look at me, dwk's the one who knows chinese.
Sort of. If you squint really hard, take your glasses off (if you don't have glasses, borrow someone else's!), and walk as far backwards as the walls of the room you're currently in allow. (If you're outside . . . about 20 feet or so.)But it (#) looks kind of like this: http://en.wikipedia.org/wiki/Image:C...r_Niu_Trad.png
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Oh, ok.I'm glad you agree with me.I deny everything.
Sort of. If you squint really hard, take your glasses off (if you don't have glasses, borrow someone else's!), and walk as far backwards as the walls of the room you're currently in allow. (If you're outside . . . about 20 feet or so.)
Last edited by robwhit; 03-02-2008 at 12:21 AM.
Personally, I'm a believer in enabling as many warnings (or, better, errors) as I can from a compiler, and then either modifying code to eliminate warnings or make sure I have a valid argument to ignore the warning. If I can, I do that with multiple compilers.
With gcc, I generally use the "-Wall -pedantic-errors" command line options. I also add -ansi or -std=xxx options, depending on what version of the standard or updates I care about and my willingness to accept headaches (these options can trigger diagnostics from the standard headers).
So does matsp! http://cboard.cprogramming.com/member.php?u=26843 (And I.)Personally, I'm a believer in enabling as many warnings (or, better, errors) as I can from a compiler ...
I usually use "-W -Wall" for older versions of GCC, along with "-ansi -pedantic" for newer ones -- the last two can indeed cause warnings in standard header files in GCC 2.95, at least.
I've never really had cause to try out other options like --std, except for --std=c99 occasionally. Oh, and a few things like -Wno-endif-labels to deal with the recent Debian SDL 1.2.12 annoyance . . . .
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Using a fine-grained error sieve and then choosing what to ignore seems good. But what do you do once you decide to ignore the warning?
Do you just disable the warning? Then it can't be used for the rest of the file. And you have to remember which warnings you have on and which warnings you have off in any file.
Maybe you split the affected code into its own file? Then you can compile each file with different warnings. But it increases the complexity of the project. Is it worth it?
Then there are pragmas, but those aren't portable.
I tend to disable the warning for entire files, because I don't like messing around with pragmas. Of course, I enable the warning occasionally and go through each occurrence of the warning to see if it's something I really want to ignore or not . . .
If there were several warnings involved, I suppose it would probably be better to use pragmas. What do you do?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I'd probably split it. But I want to know what others would do. Partly because I'm not sure if splitting the file would work in RL... unforeseen problems and stuff.
Last edited by robwhit; 03-02-2008 at 01:27 AM.