POSIX defines EOF as a macro expanding to a negative value:
The header should define the following macro, which should expand to an integer constant expression with type int and a negative value:
Eof
The return value of the end of the file.
In every implementation that I could find, EOF always like -1 .
Although the standard allows different values, I could not find any specific implementation where this happens, and I would like to find it for testing purposes. 1
1 I could make my own realization, but my real goal is to βfind it in the wild,β which, because of the inability to prove its absence, is the next best opportunity I can think of.
Almost the same question has already been asked , but at the end two questions were asked, and the accepted answer answers only the second (near WEOF ). Another user answered the first question in the negative, but since the question was limited to common C environments, a negative argument can be stated correctly: -1 is likely to be used in any reasonable implementation with a small char type.
Since my question is about existence, the only way to answer it is to provide an example, so I will rephrase it: please provide an example of an existing implementation, where EOF != -1 . Be it newlib or musl, PDP or VAX, Plan 9 or Hurd, any combination of libc / hardware / operating system with POSIX compliant or ISO C libc compatible when this happens.
source share