謎の(void)fprintf()
printf()を呼び出しているところすべてに、いちいち(void)のキャストを付けているコードを見かけた。なぜこんなことをするのか。
FreeBSD lsのusageより。
void usage(void) { (void)fprintf(stderr, #ifdef COLORLS "usage: ls [-ABCFGHILPRSTUWZabcdfghiklmnopqrstuwx1]" #else "usage: ls [-ABCFHILPRSTUWZabcdfghiklmnopqrstuwx1]" #endif " [file ...]\n"); exit(1); }
なんか繋がった(笑
% man 3 printf
#include <stdio.h> int printf(const char *format, ...); int fprintf(FILE *stream, const char *format, ...);
うぅ。確かに値を返してる。
K&R買ったほうがいいかな・・・。