471,078 Members | 820 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,078 software developers and data experts.

writing a code for both windows and linux

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...

Sep 18 '07 #1
4 5217
In article <11*********************@y42g2000hsy.googlegroups. com>,
ju**********@yahoo.co.in <ju**********@yahoo.co.inwrote:
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
Sep 18 '07 #2
ju**********@yahoo.co.in 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.
Sep 18 '07 #3
On 18 Sep, 15:51, "junky_fel...@yahoo.co.in"
<junky_fel...@yahoo.co.inwrote:
>
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.

Sep 18 '07 #4
On Sep 18, 7:51 am, "junky_fel...@yahoo.co.in"
<junky_fel...@yahoo.co.inwrote:
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

Sep 18 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Kevin T. Ryan | last post: by
5 posts views Thread by Jeong-Gun Lee | last post: by
21 posts views Thread by sachin dooble | last post: by
6 posts views Thread by Abubakar | last post: by
12 posts views Thread by Von Clubusev | last post: by
5 posts views Thread by Richard Giuly | last post: by
5 posts views Thread by pedro.ballester | last post: by
3 posts views Thread by Levi Campbell | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.