Bruno Haible <[email protected]> writes: > Hi Collin, > >> The mb_putc function in mbchar.h is defined as: >> >> #define mb_putc(mbc, stream) fwrite ((mbc).ptr, 1, (mbc).bytes, >> (stream)) >> >> but documented as: >> >> extern void mb_putc (const mbchar_t mbc, FILE *stream); >> >> If someone wanted to check that the character was written, they could >> check the that the return value of the fwrite is correct, equal to >> mb_len (mbc). > > Marking the return type of mb_putc as 'void' is intended, to match the > common use of fputc() and putc(). Most programs that use stdio for output > don't check the return value of fputc(), putc(), fwrite(), fprintf(), > since it is easier to write the error handling in one place, through an > ferror() test, rather than to litter the code with '== EOF' tests and error > handling. (And the cases where fprintf() can fail without setting the stream's > error indicator are such that most programs don't encounter them: when dealing > with wide characters or huge strings.) > > Thus, it wouldn't make sense to encourage people to test a return value of > mb_putc().
Thanks for checking. Glad that I asked before pushing. I'll leave the documentation as-is. That reasoning sounds good to me. That is the same reason it we use close_stdout. It is much easier and more maintainable to check the stream at program exit, instead of checking every printf and other stdio functions. Collin
