This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to ...


On Thu, Sep 21, 2000 at 08:57:36PM +0200, Theodore Papadopoulo wrote:
> 
> 	I know that the current goal of gcc and libstdc++-v3 is to 
> implement the C++ standard. However, that standard does not seem to 
> have considered the possibility of getting the file descriptor for 
> iostreams.

It was considered and rejected.  Not all environments use file descriptors.
Of those that do, not all of them use integers to represent them.


> This is very annoying when trying to use some system calls 
> such as mmap that requires such file descriptors and obliges the 
> users to use the old C interface.

This can cause all kinds of problems.  Once you've opened a file with an
[io]fstream and started doing things with it, data can be buffered inside
the fstream.  Using the file descriptor to mmap an open fstream's file
would essentially be doing an "end run" around the buffered data.

This would be one of those features that's easy to use incorrectly.


> Would it be accepted to add some 
> method (in basic_file.h), eventually protected by sthg like 
> #ifdef GNU_EXTENSION to add a method that would provide this file 
> descriptor ??

I dunno.  I can see that being done.  I can also see a separate
streambuf/stream class pair being written and placed in the ext directory.
Those classes can specifically support this idea, and take steps to make
using it correctly easier on the programmer (e.g., no internal buffering).
Programmers who want to use file descriptors can then use that streambuf
(or even the whole stream class) directly.


Phil

-- 
pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools.  Fools are protected by more capable fools.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]