Assuming (on GNU linux, with GNU libstdc++ and C++17 -not C++23- compiled by [GCC](https://gcc.gnu.org/) version 15 or later) I have a
std::ifstream* f;
pointer to a valid input stream (presumably opened).
How can I get the POSIX input file descriptor? (e.g. to use [poll(2)](https://man7.org/linux/man-pages/man2/poll.2.html) or [fstat(2)](https://man7.org/linux/man-pages/man2/stat.2.html) ...)
I tried f->get_fd()
and it does not compile.
Same question for std::ofstream
and the POSIX output file descriptor.
Thanks.
Asked by Basile Starynkevitch
(10709 rep)
Aug 6, 2025, 09:01 AM
Last activity: Aug 6, 2025, 09:28 AM
Last activity: Aug 6, 2025, 09:28 AM