From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,INVALID_MSGID, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public X-Google-Thread: fdb77,4873305131bf4d94 X-Google-Attributes: gidfdb77,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public From: Dan.Pop@cern.ch (Dan Pop) Subject: Re: How big is an int? (was: Yet another stupid language war (was: ... the only languages you need!!)) Date: 1997/11/07 Message-ID: #1/1 X-Deja-AN: 287682795 Sender: news@news.cern.ch (USENET News System) X-Nntp-Posting-Host: ues5.cern.ch References: <34557f2b.1934172@news.mindspring.com> <63qkp9$bqr$3@darla.visi.com> <63r2sv$rgm$1@helios.crest.nt.com> <878820761snz@genesis.demon.co.uk> <63t1j9$md8$1@helios.crest.nt.com> Organization: CERN European Lab for Particle Physics Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.lang.java.advocacy,comp.lang.c,comp.lang.c++ Date: 1997-11-07T00:00:00+00:00 List-Id: In <63t1j9$md8$1@helios.crest.nt.com> kaz@helios.crest.nt.com (Kaz Kylheku) writes: >I forgot that you can check feof() and ferror(), which will resolve the >ambiguity if EOF clashes. > > unsigned char byte; > > switch (ch = getc(stream)) { > /*...*/ > case EOF: > if (feof(stream) || ferror(stream)) { > /* handle */ > } else { > byte = EOF; > } > /*...*/ > } > >However, I doubt that very many programs actually do this. Few programs are intended to be portable to such platforms. The main reason being that all the implementations with sizeof(int) == 1 that I know of are freestanding. But someone who wants to write maximally portable code had to do the error checking as shown above. >Is a strictly conforming program required to deal with the possibility >that EOF might not actually be an indicator of neither an error, nor >the end of input? Can a strictly conforming program perform *any* kind of I/O? You cannot predict the behaviour of the system from the text of the standard. Part of the definition of "strictly conforming program" says: It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior... It is unspecified (or maybe implementation-defined) when an I/O operation fails and if that failure affects the behaviour of your program... Dan -- Dan Pop CERN, IT Division Email: Dan.Pop@cern.ch Mail: CERN - PPE, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland