This is the mail archive of the libstdc++@gcc.gnu.org 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: Accessing the UNIX file descriptor inside an fstream


On Fri, Sep 14, 2001 at 09:20:12PM -0700, Chris Rankin wrote:
> Hi,
> 
> Yes, I am fully aware that this topic has been brought up before. I
> have found numerous references in the mailing list going back to
> January 2000. However, I doubt that you'll make it go away by ignoring
> it, especially since libstdc++-v3 is now part of gcc.
> 
> I am (was) trying to port some C++ code from g++-2.95.3 to g++-3.0.1
> and the showstopper problem was this single line:
> 
>   fcntl(m_file.rdbuf()->fd(), F_SETFD, FD_CLOEXEC);

Given the existence of the extended basic_filebuf constructor, I think
it would be reasonable to provide an operator FILE *() member on
basic_filebuf.  This would allow rewriting that as

    fcntl(fileno(static_cast<FILE *>(m_file.rdbuf())), F_SETFD, FD_CLOEXEC);

which fits with the way the standard library seems to work.

Chris is right, people do need this functionality and it doesn't serve
our users to deny them it on pedantic conformance issues.

zw


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