filebuf::fd()

Nathan Myers ncm-nospam@cantrip.org
Mon Dec 3 00:03:00 GMT 2001


On Mon, Dec 03, 2001 at 08:45:30AM +0100, Gabriel Dos Reis wrote:
> Nathan Myers <ncm-nospam@cantrip.org> writes:
> | > | +      int 
> | > | +      fd();
> | > 
> | > Replace this with
> | > 
> | > +   #ifdef _GLIBCPP_USE_EXTENSIONS
> | > +      FILE*
> | > +      FILE_pointer();
> | > +   #endif
> | 
> | I strongly object to this.  
> | 
> | There is no standard requirement nor practical reason for a filebuf 
> | to have a FILE underneath, but it necessarily uses a file descriptor
> | in a POSIX environment.  I don't think we should be documenting an 
> | interface that commits us to an implementation technique we would be 
> | better off freeing ourselves from.
> 
> Well, I'm not suggesting we should use FILE* to implement the
> underlying stream.  However, either the stdio-based solution or
> libio-based solution somehow sync with the FILE* thingy, so I think
> we're better off just returning the FILE* thingy -- there is no
> further commitment than there is with returning an int.

Only cin, cout, and cerr are obliged to have some kind of 
synchronization with a stdio object.  For those cases you already 
know what the FILE* object is, and the file descriptors too.

The fd() member is interesting for all the other cases.

Nathan Myers
ncm at cantrip dot org



More information about the Libstdc++ mailing list