file descriptor to ofstream

Ajay Bansal Ajay_Bansal@infosys.com
Wed Jun 18 13:06:00 GMT 2003


I believe this is not supported with gcc 3.2 !!!!!!!!!!!!!!! 


-----Original Message-----
From: Stephen Biggs [mailto:xyzzy@hotpop.com] 
Sent: Wednesday, June 18, 2003 3:35 PM
To: GCC-Help list

Linux RedHat 8.0, all updated to the latest.

$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=i386-redhat-linux --with-system-zlib
--enable-__cxa_atexit Thread model: posix gcc version 3.2 20020903 (Red
Hat Linux 8.0 3.2-7)

given the code:

#include <fstream>

...

int fd = open("junk",O_CREAT | O_EXCL);

ofstream f(fd);

How do I do the above operation?

This gives a compile error on G++ 3.2, since the ofstream constructor in
/usr/include/c++/3.2/fstream is not overloaded to take an integer file
descriptor, but the constructor defined in /usr/include/g++-3/fstream
does do this.

Are the include files in g++-3 deprecated? Those files are not being
included, instead the ones in c++/3.2 are which are much less in
content.  How do I change a vanilla installation to include the g++-3
files, if, in fact, that is what I should do?





More information about the Gcc-help mailing list