Solved

C++ Program  coding for different platform.

Posted on 2001-08-21
5
212 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MSVCR80.dll crash 2 134
Which IDE to use to begin C++ training? 5 59
operator overload: incompatible type and too many params 5 62
Why isn't object file created? 6 39
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now