473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 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 5377
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kevin T. Ryan | last post by:
Hi All - I'm not sure, but I'm wondering if this is a bug, or maybe (more likely) I'm misunderstanding something...see below: >>> f = open('testfile', 'w') >>> f.write('kevin\n') >>>...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
21
by: sachin dooble | last post by:
is there any method where i can run my linux code that is all the a.out i made on linux to run on windows. plz tell me the way.
6
by: Abubakar | last post by:
Hi, we are finding out ways in which we could develop libraries that could be written in c++ in a way that we can use them in windows, linux, and mac os. We want to write portable code, so that it...
12
by: Von Clubusev | last post by:
I like Java just as much as I like C#, but the truth is that unless you absolutely need platform portability, DotNet is the way to go. This is becoming even more true with the release of Windows...
5
by: Richard Giuly | last post by:
Hello, I would like to write "portable" C++ code that could theoretically run on linux, windows, and other platforms, and I'd like to use VS as the editor/compiler/linker. The simplest thing...
5
by: pedro.ballester | last post by:
Hi everyone, I am struggling with the following problem. I would like to measure the wall clock time required to run a section of the code with a precision of milliseconds. The attached code...
13
by: jc | last post by:
I have written a parser using bison and flex to read ASAP2 file for CAN communications. entire development was done in an unix environment and now the code is ready to be integrated to an existing...
3
by: Levi Campbell | last post by:
Hi, I'm trying to write a program for a friend of mine who uses windows but I use GNU/Linux. I know you can use mingw and link to the python dll, but is there a way to create a win32 service under...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.