This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

file descriptor to ofstream


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?



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