I've tried compiling the source (current CVS version)
with gcc 4.0.0 and all warnings enabled with:
-Werror -Wall -W -Winline -Wpointer-arith
-Wno-cast-align -Wcast-qual -Wwrite-strings -Wshadow
-Wredundant-decls -Wconversion -Wsign-promo -Wsynth
Machine-specific flags were:
-Os -pipe -march=athlon-mp -mfpmath=sse
On a dual-proc Athlon MP, Linux 2.6.12
Thousands of warnings result due to problems in the
1) const correctness. This is the most unpleasant one
to deal with; there are char all over the place that
are pointing to const strings. Functions take char
when they really only need const char*.
2) Unused function arguments. In old time C code it was
ok to leave the parameter in if it is not used. In C++,
the names for unused parameters should be omitted (or
commented out, as in the patch).
3) Uninitialized variables. At several points undefined
behaviour would result from some parameter values. This
is a serious problem and may lead to hard-to-find
crashes. On the other hand, some instances of this are
in what might be critical loops, so the changes should
be reviewed by whoever knows how they really work and
determine the actual impact of the changes.
4) Variable shadowing. There are many instances of
class members shadowed by parameters or locals with the
same name. The patch renames the parameters, but a
better solution would be to better name the member
variables; the common solution is to use m_ Hungarian
prefix on them.
5) Incomplete enum switches. C++ will warn if the
switch contains some enum values, but not all of them.
The patch fixes these by adding default: cases, which
should be reviewed for possible performance impact.
6) Anonymous structs. File-scoped variables should not
use anonymous types; the compiler thinks they may be
exported and warns that external users will not know
7) Unused static functions. These should be commented
out to avoid a warning.
8) Mixed-type comparisons. Signed-unsigned mismatches
can result in strange behaviour if the wrong conversion
is implicitly performed.
There was also some strange code in sdlmain.cpp, which
I think is a bug. On line 274 there is ~(CAN_8,CAN_16),
although it probably ought to be ~(CAN_8|CAN_16). Yes,
there was a warning about it.
The patch to fix all these things is attached. I've
tested it under X with Sid Meyer's Colonization. (on
the console SDL sets an unusable refresh rate and locks
up my LCD, although I can see the shell come up; this
is a configuration problem I haven't figured out yet)