Actually std::filebuf
has never offered a constructor taking a FILE*
. You've fallen victim to a gcc extension.
The C++ I/O system is very extensible, though in a fairly antique fashion. It is not that difficult to create a custom streambuf
which could be constructed from a FILE*
, in perfectly portable C++. Normally I'd just plop the code down here. However it is a little long for an answer. And normally I don't shamelessly plug a product instead of offering an answer.
In this case I'm making an exception.
Josuttis' "The C++ Standard Library" shows how to do this for a POSIX file descriptor in section 15.13.3. It would be trivial to adopt this code to use a FILE*
instead of a POSIX file descriptor.
If this was the only thing you could get out of Nicolai's book, I probably wouldn't recommend it. However that is far from the case. I recommend this book.