Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jan 2007 18:45:01 +0100
From:      =?us-ascii?Q?Kristof_Zelechovski?= <giecrilj@stegny.2a.pl>
To:        <freebsd-standards@FreeBSD.ORG>, <giecrilj@stegny.2a.pl>
Subject:   RE: return value of fprintf
Message-ID:  <003101c73f16$3555e300$1a01080a@POCZTOWIEC>
In-Reply-To: <200701231727.l0NHRIRN074657@lurza.secnetix.de>
References:  <002401c73efd$5db24280$1a01080a@POCZTOWIEC> <200701231727.l0NHRIRN074657@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help


> -----Original Message-----
> From: Oliver Fromme [mailto:olli@lurza.secnetix.de]
> Sent: Tuesday, January 23, 2007 6:27 PM
> To: freebsd-standards@FreeBSD.ORG; giecrilj@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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003101c73f16$3555e300$1a01080a>