Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > writing a code for both windows and linux

Reply
Thread Tools

writing a code for both windows and linux

 
 
junky_fellow@yahoo.co.in
Guest
Posts: n/a
 
      09-18-2007
guys,

I need to write a program that should work on both windows and linux
systems. I have to do lot of file handling (file creation, checking
access permissions etc) and have to use lots of system specific APIs
(like popen etc) in my code. I don't want to put #ifdef windows and
#ifdef linux, for all system specific calls. This makes code quite
unreadable. Is there a good way of doing it ?

thanks a lot for any help...

 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      09-18-2007
In article <(E-Mail Removed). com>,
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> I need to write a program that should work on both windows and linux
>systems. I have to do lot of file handling (file creation, checking
>access permissions etc) and have to use lots of system specific APIs
>(like popen etc) in my code. I don't want to put #ifdef windows and
>#ifdef linux, for all system specific calls. This makes code quite
>unreadable. Is there a good way of doing it ?


Isolate the system-specific portions so that your main code calls
(e.g.,) "check_access_rights", and have that -one- routine
know about the system differences.

This does presume that you can find unified "intentions" at
each point and represent them in a system-independant manner in
the API you create.

--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
 
Reply With Quote
 
 
 
 
Mark Bluemel
Guest
Posts: n/a
 
      09-18-2007
(E-Mail Removed) wrote:
> guys,
>
> I need to write a program that should work on both windows and linux
> systems. I have to do lot of file handling (file creation, checking
> access permissions etc) and have to use lots of system specific APIs
> (like popen etc) in my code. I don't want to put #ifdef windows and
> #ifdef linux, for all system specific calls. This makes code quite
> unreadable. Is there a good way of doing it ?


Abstract the platform specific processing into separate modules, behind
"generic" interfaces.

Implement for the two platforms, build and link as appropriate for the
different targets.
 
Reply With Quote
 
keith@bytebrothers.co.uk
Guest
Posts: n/a
 
      09-18-2007
On 18 Sep, 15:51, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
>
> I need to write a program that should work on both windows and linux
> systems. I have to do lot of file handling (file creation, checking
> access permissions etc) and have to use lots of system specific APIs
> (like popen etc) in my code. I don't want to put #ifdef windows and
> #ifdef linux, for all system specific calls. This makes code quite
> unreadable. Is there a good way of doing it ?


Write it in Perl. Really.

 
Reply With Quote
 
user923005
Guest
Posts: n/a
 
      09-18-2007
On Sep 18, 7:51 am, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:
> guys,
>
> I need to write a program that should work on both windows and linux
> systems. I have to do lot of file handling (file creation, checking
> access permissions etc) and have to use lots of system specific APIs
> (like popen etc) in my code. I don't want to put #ifdef windows and
> #ifdef linux, for all system specific calls. This makes code quite
> unreadable. Is there a good way of doing it ?


There are lots of ways to do it.
People have written toolkits for that.
The easiest way to find them is via a web search.

Some examples are SFL by Imatix and ACE by Schmidt
For GUI there is wxWIdgets
OT here anyway

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compilation error: file exists in both in both 'c:\WINNT\Microsoft.NET\Framework\v2.0.50727 ABCL ASP .Net 0 05-29-2008 04:59 PM
2 computers, both online, both invisible to each other ? b Computer Support 9 04-21-2006 04:06 AM
Linux and Windows BOTH Targets? Kyle :o\) Computer Support 10 04-12-2006 09:58 AM
problems writing a printf/scanf function that handles both int and char input from the console Dawn Minnis C Programming 6 02-08-2005 02:49 PM
From where i can download C9X compiler for both linux and windows SIP3261 C Programming 1 09-04-2004 05:07 PM



Advertisments