C++ Logo


Advanced search

[std-proposals] Construct an iostream from a file descriptor

From: Paul Fee <paul.f.fee_at_[hidden]>
Date: Fri, 2 Sep 2022 10:36:56 +0100

POSIX defines fdopen(), which takes ownership of a low level file
descriptor and returns a FILE* with which a user can perform buffered I/O.
There doesn't appear to be a similar feature in C++, though non-standard
workarounds exist, such as __gnu_cxx::stdio_filebuf.


Are there issues that would block standardisation of such a facility?
Perhaps it's because fdopen() is part of POSIX rather than ISO C, hence
file descriptors themselves may not be universally portable. Does that in
turn mean that the standard library can't provide functionality that
depends on a POSIX feature? Would it be feasible to provide this feature
only on platforms where file descriptors exist?


Received on 2022-09-02 09:37:07