Getting a file descriptor or a file number) for an fstream (Was:Accessing the underlying file descriptor in fstream)

Jon Cast jcast@ou.edu
Wed Feb 14 22:16:00 GMT 2001


Gabriel Dos Reis [gdr@codesourcery.com] writes
> Well let's make this straight.  The thing on top of which IOStreams are
> implemented aren't directly accessible to you.

In C the underlying mechanism of a FILE* _is_ available, in practice even if
not in theory.  So what you're saying is, code that is perfectly
well-defined under C/Unix should not be possible under C++/Unix without
sacrificing the major advantages of C++ for I/O.  That, IMAO, is a
legitimate QOI issue, not some essential sacrifice to the dread god of
`portability'.

If your concern is for abstraction, then I would say this is an area where
ease of use trumps abstraction.  It isn't any good to abstract your
interface to the point of breaking well-defined and useful code.  That kind
of code, if it became prevalent, would be asking for a fork.

Jon Cast




More information about the Libstdc++ mailing list