Unix Programming - ofstream constructor doesn't take file descriptor as an argument.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > ofstream constructor doesn't take file descriptor as an argument.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ofstream constructor doesn't take file descriptor as an argument.
Anoop Kumar

2004-01-23, 5:21 pm

Hi

I have RH Linux 9.0 installed on my x86 computer.
The GCC version is 3.3.2 and the gdb version is 6.0.

I am porting an application from solaris to linux.
The solaris application makes use of such a statement :

ofstream (fd ); where fd is a file descriptor.

This somehow seems to be working in solaris. But when i compile
the program in linux , it gives the following error.

initializing argument 1 of `std::basic_ofstream<_CharT,
_Traits>::basic_ofstream(const char*, std::_Ios_Openmode) [with _CharT =
char, _Traits = std::char_traits<char>]'

1) Is there a work around to this problem???
If so, please do let me know.

- Thanks
Anoop
Nils O. =?iso-8859-1?Q?Sel=E5sdal?=

2004-01-23, 5:21 pm

In article <31fe3fb2.0401050250.5deb550f@posting.google.com>, Anoop Kumar wrote:
quote:

> Hi
>
> I have RH Linux 9.0 installed on my x86 computer.
> The GCC version is 3.3.2 and the gdb version is 6.0.
>
> I am porting an application from solaris to linux.
> The solaris application makes use of such a statement :
>
> ofstream (fd ); where fd is a file descriptor.
>
> This somehow seems to be working in solaris. But when i compile
> the program in linux , it gives the following error.
>
> initializing argument 1 of `std::basic_ofstream<_CharT,
> _Traits>::basic_ofstream(const char*, std::_Ios_Openmode) [with _CharT =
> char, _Traits = std::char_traits<char>]'
>
> 1) Is there a work around to this problem???
> If so, please do let me know.


iirc ostream can take a streambuf ,and you should be able to make a strambuf
based on a file descriptor.

--
Vennlig hilsen/Best Regards
Nils Olav Selåsdal <NOS at Utel.no>
System Engineer
UtelSystems a/s

Anoop Kumar

2004-01-23, 5:21 pm

noselasd@frisurf.no (Nils O. Selåsdal) wrote in message news:<slrnbvih3j.vkl.noselasd@utelsystems.dyndns.org>...
quote:

> In article <31fe3fb2.0401050250.5deb550f@posting.google.com>, Anoop Kumar wrote:
> iirc ostream can take a streambuf ,and you should be able to make a strambuf
> based on a file descriptor.






--------------------------------------------------------------------------------


Hi,


How do i do that???
Could you explain the technique ???
what all functions do i need to override, inorder to perform that????

- Thanks
Anoop
Maurizio Loreti

2004-01-23, 5:21 pm

anoop_kn@yahoo.com (Anoop Kumar) writes:
quote:

> How do i do that???



The complete example in in Josuttis, page 672 ff.

Go to toe book site, and download the example files io/outbuf2.hpp,
io/outbuf2.cpp, io/outbuf3.hpp .

--
Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy ROT13: ybergv@cq.vasa.vg
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com