Atomic #defines (was Re: Password checking program)

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Aug 29 00:02:49 AEST 1989


In article <1625 at mcgill-vision.UUCP> mouse at mcgill-vision.UUCP (der Mouse) writes:
>In article <10765 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>> EOF belongs to the C implementation.  Invent your own symbols for
>> your own uses.
>Fine.  But how?

#include <stdio.h>
#define MY_EOF (-1234) /* presumably in some local header */
#define MY_ERR (-4321)
int MyGetChar() { int c;
return (c = getchar()) == EOF ? ferror(stdin) ? MY_ERR : MY_EOF : c; }

>By the way, it seems to me that the required existence of EOF implies
>that it is not a legal implementation choice to make char and int
>identical.  Is this true?

Since in such an implementation an int would be unable to represent
all possible values in the range of a unsigned char, as required by
the specification for some library routines, it would not be standard
conforming.



More information about the Comp.lang.c mailing list