Nick Maclaren <yyyy@xxxxxxxxxxxxx> wrote, on 15 Jul 2005:
>
> > That argument works for the C standard because, as you say, it says
> > nothing about what kind of errors occur for fgetc() and fputc().
> > The same argument does not work for POSIX, because POSIX requires
> > fgetc() and fputc() to set errno to indicate which error occurred.
> > If stdin is open for reading, fgetc(stdin) can fail but it cannot
> > set errno to EBADF.
> >
>
> I wish :-(
>
> POSIX states very clearly that it does not specify the language
> aspects, but does not clarify what that means. That is particularly
> serious w.r.t. signal handling, but affects this one, too. fgetc
> is a macro, and the undefined behaviour caused by a read error is
> potentially visible to the language - so a perfectly good reading
> is that the behaviour is undefined.
No. If fgetc() is defined as a macro, POSIX still requires it to
exist as a function as well. So undefined behaviour from the macro
version of fgetc() is a red herring - my argument still applies to
the fgetc() function.
--
Geoff Clare <yyyyyyy@xxxxxxxxxxxxx>
The Open Group, Thames Tower, Station Road, Reading, RG1 1LX, England
|