FILE as a void typeAuthors: Jay Ghiron
Date: 2026-03-17
Submitted against: C23
Status: Open
No wording exists currently to say that FILE cannot be void or
_Atomic void:
The types declared are
...
FILEwhich is an object type capable of recording all the information needed to control a stream, including its file position indicator, a pointer to its associated buffer (if any), an error indicator that records whether a read/write error has occurred, and an end-of-file indicator that records whether the end of the file has been reached;
(C23 7.23.1 "Introduction" paragraph 3.)
In C11 the definition of object type was modified to include
incomplete types, and this was intentionally extended to FILE so it
can be defined as an incomplete type. For example:
typedef struct _FILE FILE;
Which will prevent programs from accessing the contents of a FILE
through a FILE*. This change however also included allowing FILE
to be defined as void or _Atomic void, though such definitions
were likely not intended to be valid. A motivating example to forbid
such definitions is so that _Generic can always distinguish between
void* and FILE*. A definition of FILE as void would also
result in lots of undesirable implicit conversions to FILE* being
possible.
Modify C23 7.23.1 paragraph 3:
FILEwhich is an object type other than a void type capable of recording all the information needed to control a stream, including its file position indicator, a pointer to its associated buffer (if any), an error indicator that records whether a read/write error has occurred, and an end-of-file indicator that records whether the end of the file has been reached;
Note: The wording "a void type" is already used to include _Atomic void, though that is never clearly defined.