3 ms·
I think in the real world where a file can have a 64 bit size and long is 32 bits, ftell() can work or return an error depending on the size of the file. There
by fanf2 2y ago
I think in the real world where a file can have a 64 bit size and long is 32 bits, ftell() can work or return an error depending on the size of the file. There isn’t really any other reasonable implementation in that situation.
So ftell() can exist but fail for unbounded seekable streams. The standard does not require ftell() to provide an answer in all situations.
- oecumena 2y agoStill won't work. The Standard explicitly specifies that FILE type includes all stream attributes, including position indicator: ISO/IEC 9899:TC3 7.19.1 FILE which 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; Hence no stream can be longer than 2^(sizeof(FILE)*CHAR_BIT) (6.2.6.1 guarantees that objects of any type cannot have "hidden" bits of state not accounted by sizeof()).