[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

C++ Program  coding for different platform.

Posted on 2001-08-21
5
Medium Priority
?
239 Views
Last Modified: 2012-06-27
Hi,

I have been asked to develop a s/w in C++
which will use Dial up to modem,
sending data, receiving data and showing response.
It will be running as a deamon program
on Linux and NT/Win2000.

I have similar program developed on linux and i know how to do the coding part.

What is the best way to approach coding so that I do not
have to write seperate source code for linux and windows.

It will be command line based program.

Please suggest me how is coding for different platform handled so that same souce code with proper OS related handling instruction is achieved. I am not willing to use DJGPP (http://www.delorie.com/djgpp/). Please suggest any other ideas you have.

Regards,
Shinda

0
Comment
Question by:shinda
5 Comments
 

Accepted Solution

by:
andrewschneider earned 400 total points
ID: 6412702
There is a product called Cygwin (http://sources.redhat.com/cygwin/) that provides a port of the UNIX API to Windoze. You could try that, it works quite well. There are other more costly packages out there as well. Personally (having been involved in a large port of a Unix app to NT) I'd opt for going native (unless you have a large pre-existing code base). You will end up with duplicate code but if you carefully define your object model and interfaces you can push all the O/S specific stuff right out into the periphery which makes it much easier to handle.

Your duplicate code will probably be in the handling of the device itself. If you're careful file handling and general stuff can be written in a way that works on both NT and Unix without loads of alternate source paths everywhere. You'll need to pay attention to code syntax since VC++ and other compilers often don't see eye to eye. There is some content on the Netscape web-site that is a guide to writing platform independant code - you might want to look at that.

You might want to take a look at how Apache and other open source projects handle the Unix/NT front. On the daemon front, in NT/Win2000 that's a service which requires a bunch of infrastructure. However, there are free packages around that effectively proxy the service code for you, you just write an executable in the same way you would for [x]inetd and the proxy exec's your code for you. You'll find references to these packages in most good VB and Java forums (since neither are ideal environments for handling the NT service API).
0
 

Author Comment

by:shinda
ID: 6415130
Hi,
Thanks for the insight.

Till date i have only used GCC on linux. And we do not use any windows based productus or compilers.
Long back I used cygwin just to see how it handles my unix code on windows NT. Everything was working fine in terms of file handling but it was taking too much of CPU time whenever my program used to go in loop waiting for a file in a specific directory. I will check at Netscape sie for the guide.

Andrew: Have you used CYGWIN in your cross compilations on Windows 2000 ? Does it work well ?

Thanks a lot for your valueable suggestions.
Regards,
Shinda

0
 

Expert Comment

by:andrewschneider
ID: 6416753
Cygwin has come a long way now. I've used it on small green-field developments (to good effect) but I must admin I tend to go "native" unless I have a strong reason otherwise.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6861804
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to accept "andrewschneider" comment(s) as an answer.

If you think your question was not answered at all, you can post a request in Community support (please include this link) to refund your points.
The link to the Community Support area is: http://www.experts-exchange.com/commspt

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6883890
Per recommendation, force-accepted by
Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question