On Jun 25, 2:15 pm, g...@waves.com wrote:
I'm trying to find the best way to work with compiler warnings. I'd
like to remove *all* warnings from the code,
That's generally a good goal, but all of the compilers I've used
have one or two idiotic warnings, which can't reasonably be
avoided. (More than one compiler I've used has output warnings
from its own header files:-).) At the very least, be sure you
understand why the warning is there.
In a larger project, it's generally a good idea to start with
the rule that all code must be compiled at the maximum warning
level, and that no warnings are permitted. Then, as programmers
run into warnings that aren't practical to avoid, you introduce
exceptions, either on a one time basis (the code does something
special which requires a normally dangerous construct), or
generally (the compiler is getting in a tissy about nothing).
and playing around with the warning level, I've noticed that
compiling with /W3 I get warnings that with /W4 are shown as
remarks, e.g.:
The compilers I use don't distinguish.
warning #177: variable "Foo" was declared but never referenced
...is displayed as a "remark #177" with /W4. That doesn't fit the
definitions in Intel's help page. My questions are:
1. Why did the warning turn into a remark, is this a bug?
For any specific warning, you'll have to ask the compiler
vendor.
If not, what is the intention behind this behaviour? This
doesn't include ALL warnings, e.g.
warning #504: initial value of reference to non-const must be an
lvalue
remains a warning with /W4.
That *isn't* a warning, or at least shouldn't be. That is an
error, and conformant compilers won't compile such code.
2. How come issues of conversion from "double" to "float" are
displayed only as remarks with w4? Usually they are w3 with other
compilers...?
The compilers I've seen don't usually say anything about
narrowing conversions. There are historical reasons which mean
that most such warnings are irrelevant, and rather than flood
the output with irrelevant warnings, they don't worry about it.
In many ways, it's a shame, but we can't change history.
3. Can remarks be eliminated altogether, and what is the best
way (in your opinion) to go with remarks/warnings?
Again, most compilers don't distinguish. In the end: ideally,
you should strive for no output from the compiler, but
practically, you're going to have to evaluate, and allow some.
The decision should be based on your requirements, not any
categorization by the compiler, however.
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34