writing a code for both windows and linux

Discussion in 'C Programming' started by junky_fellow@yahoo.co.in, Sep 18, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. In article <>,
    <> 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
     
    Walter Roberson, Sep 18, 2007
    #2
    1. Advertising

  3. Mark Bluemel Guest

    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.
     
    Mark Bluemel, Sep 18, 2007
    #3
  4. Guest

    On 18 Sep, 15:51, ""
    <> 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.
     
    , Sep 18, 2007
    #4
  5. user923005 Guest

    On Sep 18, 7:51 am, ""
    <> 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
     
    user923005, Sep 18, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SIP3261
    Replies:
    1
    Views:
    296
    Mike Wahler
    Sep 4, 2004
  2. Dawn Minnis
    Replies:
    6
    Views:
    495
    Lawrence Kirby
    Feb 8, 2005
  3. Mauro \Baba\ Mascia

    Ping and ARP on both Win and Linux in Python

    Mauro \Baba\ Mascia, Mar 13, 2008, in forum: Python
    Replies:
    1
    Views:
    1,182
    Rune Strand
    Mar 14, 2008
  4. ABCL
    Replies:
    0
    Views:
    567
  5. Nam
    Replies:
    3
    Views:
    484
Loading...

Share This Page