return value of fprintf
Kristof Zelechovski
giecrilj at stegny.2a.pl
Tue Jan 23 17:45:12 UTC 2007
> -----Original Message-----
> From: Oliver Fromme [mailto:olli at lurza.secnetix.de]
> Sent: Tuesday, January 23, 2007 6:27 PM
> To: freebsd-standards at FreeBSD.ORG; giecrilj at stegny.2a.pl
> Subject: Re: return value of fprintf
>
>
> C++ is different anyway for its support for exceptions,
> which is the normal mechanism to handle I/O errors.
Only if you explicitly ask for exceptions.
You do not get exceptions out of the box because it is still possible
to use C++ without exceptions
(in an environment where exceptions are not supported).
You get a bad stream that refuses to do anything more instead.
> C doesn't support exceptions, so you have to check the
> return code from every I/O operation yourself.
>
> > nor do I understand why the C library prefers
> > to let sloppy code leave holes in data.
>
> Would you suggest that _all_ I/O operations continue to
> fail until the application explicitly clears the error
> indicator? That would break many programs. Many.
>
> In fact, I think that the existing behaviour makes more
> sense. For example, if one printf() failed because of
> ENOSPC, then the next printf() should still be performed,
> because the error condition might have cleared in the
> meantime. It should work, no matter if the programmer
> decided to check all return values and reset the error
> indicator or not.
Thanks for your opinion,
I just could not imagine anybody would like it that way.
I also believed that C++ streams were similar to C streams by design,
which is apparently not the case.
Chris
More information about the freebsd-standards
mailing list