Reputation: 7516
I am digging around C++ I/O documentation.
I can find EOF
definition in stdio.h
of VC++ but can't find it in stdio.h
of llvm https://github.com/llvm-mirror/libcxx/blob/master/include/stdio.h
By the way, from https://en.cppreference.com/w/cpp/string/char_traits it says
So for char
, std::char_traits::eof
returns EOF
which is -1
. Also from https://en.cppreference.com/w/cpp/string/char_traits/eof, it says :
Returns a value not equivalent to any valid value of type char_type.
So here's what I deduce: -1
is not a valid value of type char_type(char
)?
How come? In VC++, char
is signed, so -1
should be valid for char
.
Upvotes: 0
Views: 685
Reputation: 47468
The file you mention, https://github.com/llvm-mirror/libcxx/blob/master/include/stdio.h , picks up EOF from the C library using this line:
#include_next <stdio.h>
LLVM does not provide a C library, so it will be whatever you have on your system. For example, on a Linux, it will typically be GNU libc, which defines EOF here
/* The value returned by fgetc and similar functions to indicate the
end of the file. */
#define EOF (-1)
Upvotes: 1