We have a huge codebase in HP-UX and we are porting them in RH-Linux. I am facing the problem of making the following code work in gcc -
Here one file is opened and then the ofs variable is attached to that file descriptor.
Unlike HP-UX compiler, gcc doesn't have the attach() function. So how I can make the code compatible? I tried to solve the problem in various ways like how it is described here - Gerhard Wesp - Re: Attaching cout || cerr to an ostream or here - [c++] How to create a std:fstream to a temp file? - Stack Overflow. But nothing is helping this particular issue since fd is a filedescriptor and not a filebuf. Can you please help me out?
There's no standard, portable way to do this. Like ghostbusters, you're not supposed to cross the streams. But g++ iostreams do have some extensions to make it possible. Adapting an example found here I tried this:
Testing this on a file containing 'asdf' it does print asdf, so while a bit tortuous it does actually work. It being that tortuous also makes it plain that you are using an extension, which is probably the point...
I don't know if the stdio_filebuf closes the FILE * for you when it goes out of scope or not.
First of all thanks a ton to your post - appreciate your time and effort to help me out! I took long time to reply here because of some other urgent work.
I took your help and wrote the following program which creates an ostream object from the file descriptor -
To create the ofstream object in the same way we have to do the following -
Both the programs and running fine and will be a ready references for other users facing the same problem.
Once again thanking you for your generous support!
Hi,
Code written in C++ got compiled successfully using Sun 4.2 Compiler on Solaris 6. As part of migration, i am using same code and trying to compile using Sun 5.8 C++ compiler(Sun Studio11) on Solaris 10 and could not compile the below line,
outStr.attach(1); // here outStr is declared... (1 Reply)
Hi all,
Has anyone experience with proting a Linux driver (C-code) to Solaris 10?
I have a Sunix SATA card with a inicio1622 chipset, but no driver available. From the website of inicio I downloaded the drivercode for Linux 2.4.
Having done some investigation I found a Solaris driver... (4 Replies)
Hi,
I was trying to port efs_mount(OSE system call) to a LInux.The efs_mount function is used to mount a volume on the indicated device dev.Upon successful completion of this OSE sytem call a volume manager (VM) will be available through which files on this volume are accessed. The Syntax for... (4 Replies)
I am new to Linux programming and my work involves changing an abstraction layer which made Nucleus calls, to Linux calls.
In Case of Events Nucleus has calls like
NU_Set_Events()
NU_Retrieve_Events()
Can I use the POSIX thread conditional variables for Linux?
Can I use the System V calls... (1 Reply)
Hello All,
I have a code of DHCP which is implemented on Linux. During porting this code from Linux to VxWorks, I come up with following errors:-
jects\freedom\ap\udhcp\socket.c
C:\projects\freedom\ap\udhcp\socket.c: In function `read_interface':
C:\projects\freedom\ap\udhcp\socket.c:79:... (1 Reply)
helo,
i m porting HP-UX socket application to Linux SSL-socket application.
I have use htonl() in HP-UX.
so when i use it in Linux, data transf is not done and application become soem time crashed.
now when i remove htonl() in linux, then i got data but it will not proper order or some data may... (1 Reply)
Gents,
i'm a senior applications developer and need to port a Linux server application ( no additional / special libraries or unique header files ) to a HPUX enviroment.
Any chance to compile it on the Linux using flags to create an HPUX binary with gcc? (8 Replies)
Hi all,
i wanted to port some HP-UX code to linux. can anybody point to some documents or resources that would help me in doing the porting..
thanks in advance
Arun Prakash (0 Replies)