Why use (void) func() ?
Karl Heuer
karl at haddock.ima.isc.com
Sat Sep 29 07:26:12 AEST 1990
In article <oazbx9O00VtqAheFBf at andrew.cmu.edu> ghoti+ at andrew.cmu.edu (Adam Stoller) writes:
>I happen to agree that having printf() return an int is rather a waste,
>but if/when it bothers me, I either go through the code and put the void
>cast in front of each printf, or [fake it with a macro].
In other words, you treat the symptoms instead of the disease.
My opinion: the disease is pretty mild, but so are the symptoms (a single
entry in one line of lint output); and I'd rather keep the latter around in
case I someday decide to repair the former. I actually have one program that
lints cleanly, modulo lint bugs, and does not do any such fudging: output is
done with
void pprintf(Player *p, char const *fmt, ...) {
va_list ap;
va_start(ap, fmt);
if (vfprintf(p->ofp, fmt, ap) < 0) bugcheck();
va_end(ap);
if (fflush(p->ofp) == EOF) bugcheck();
}
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