writing a code for both windows and linux

J

junky_fellow

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

Walter Roberson

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

Mark Bluemel

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

keith

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

user923005

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top