void casts; and C definition question
Henry Spencer
henry at utzoo.UUCP
Wed Oct 5 09:12:07 AEST 1983
A while ago, I exchanged mail with DMR about the question of whether
neglecting to declare the type of an unused return value was a sin.
The C book does say that awful things may happen if you get the type
wrong (explicitly or implicitly) and use the value, but it is silent
on the subject of return values that are merely discarded. Dennis's
comments (as nearly as I remember them) were, roughly: "There has been
no firm decision on this. It would be a lot cleaner to require proper
declaration, but it would break many, many existing programs. There is
also an argument which says 'if you don't use it, why should you need
to declare it?'." I believe the pragmatic issues involved made him
lean toward being permissive about this. It does make life harder for
compiler writers, especially with structure returns. About the only
thing you can do if your machine is especially recalcitrant is to have
the compiler quietly generate an extra little function for each "real"
function, with the extra function calling the real one and then properly
discarding the returned value. The compiler then calls either the
real function or the extra, depending on whether the returned value is
used by the particular call or not.
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!henry
More information about the Comp.lang.c
mailing list