Unused parameter warnings
samiam at moorecad.com
Sat Sep 25 00:58:27 CEST 2004
Frank Heckenbach wrote:
>>This brings up the more general subject of the attitude to
>>warnings. Pascal is not C. In C many, if not most, warnings
>>indicate a serious situation where the probability of bad code is
>>high, if not certain. Pascal has so many more internal checks
>>that warnings tend to be just that, and the probability that the
>>code does what is intended is much higher.
>>Thus the Pascal programmer should be prepared to evaluate and
>>accept warnings on compilation. This attitude is probably not
>>fatal, as it would be in C. In particular an unused parameter
>>falls into this classification.
>I don't really agree. First, most of the warnings I see from C
>programs are alllso harmless on closer inspection. I haven't done
>any statistics to find out the relative relevance of Pascal vs. C
>However, the main point is that warnings that are left in will be
>seen by everyone who compiles the software, not only by the one who
>wrote the code. In the end, this will lead to the situation we
>mostly have in C now, where everyone expects to see some warnings
>when compiling something and almost nobody cares about them. We
>could just as well turn them all off then.
>So I agree with Adriaan that distributed software should compile
>without warnings, either (preferably) in a clean way by changing the
>code, otherwise by force, i.e. turning off warnings (as locally and
>specific as possible).
>BTW, using `-Werror' when compiling things helps you keep that
>discipline and forces you to fix warnings immediately (rather than
>having them accumulate until there are so many you don't want to
>start fixing them anymore ;-).
Pascal and C deserve to be treated completely differently with regards
to warnings. The following is perfectly valid C:
while (c = 1) ...;
But probally generates a warning on many C compilers nowdays. C compilers
have to determine what is "likely" to be a problem. This a good lesson
for Pascalers. We were blessed with a language that does not have
such grey areas.
PS. IP Pascal does not have warnings at all. If the option is on to
check for problem N, then the occurrance of problem N is an error, end
of story. This means the compiler returns an error to the build
processor, and in fact deletes any output files, to prevent a false
build being created for the bad build.
I agree with the other posters. C warnings are a mess. Avoid at all costs.
Samiam is Scott A. Moore
Personal web site: http:/www.moorecad.com/scott
My electronics engineering consulting site: http://www.moorecad.com
ISO 7185 Standard Pascal web site: http://www.moorecad.com/standardpascal
Classic Basic Games web site: http://www.moorecad.com/classicbasic
The IP Pascal web site, a high performance, highly portable ISO 7185 Pascal
compiler system: http://www.moorecad.com/ippas
Good does not always win. But good is more patient.
More information about the Gpc