Mark A. Odell said:
(e-mail address removed) (sugaray) wrote in
This isn't what I'd call a calling convention. Usually the author is just
trying to indicate that he does not care about the return value of a
function. The void cast is not required by C. Lint however will complain
if you don't add the void cast.
If the author is creating lint-clean code out of compulsion, he should
restrain himself when writing code for a tutorial book. Not only is it
ugly, but it could introduce topics too far ahead of time for the code
to be easily followed by a pupil reading sequentially, as opposed to
an old hand skimming around for a specific section. If the author is
throwing void around before introducing the idea of an incomplete
type, he's setting the neophyte up for confusion.
Of course, a section on how to handle lint and how to get an idea of
which warnings one can ignore in a given program would be very
helpful, and I've never seen a text to provide that info. But, as I
said, everything in its proper time. (On a personal note, I always
thought it nitpicky for lint to complain that I'm not using the retval
of every subroutine I call. Dammit, give my human experience some
credit!)
If, on the other hand, the author doesn't give two damns about lint
and is simply illustrating to the newbie how to safely `throw away' a
retval, he should make it clear what he's doing and explain how
casting to an incomplete type allows interesting things to occur.
After all, it /is/ a cast he's doing, and a cast with nothing on the
`other side' could be a challenge to someone who's just learning the
type system.
In any case, the code is correct as far as it goes. Even if expression
were a variable of an integral type, it would be compilable (tho lint
would mutter). I probably would not enjoy the book sugaray is reading,
but I didn't pay for it.