Why use (void) func() ?
Karl Heuer
karl at haddock.ima.isc.com
Tue Sep 25 09:31:20 AEST 1990
In article <586 at dptechno.UUCP> dave at dptechno.uucp (Dave Lee) writes:
>Why should I go to the extra trouble to [explicitly cast to void]?
To distinguish between "This call might fail, but I don't know what I should
do about it" (uncast) and "This call might fail, but the appropriate recovery
operation is a NOP" (cast). An example of the former is most programs' use of
putchar() or printf(). An example of the latter is unlink(t) in a cleanup
routine where t is a temp file that may or may not exist at this point, or the
fprintf(stderr, ...) issued from a panic routine just before exiting.
Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
More information about the Comp.lang.c
mailing list