Newbie-question: include headers for different plattforms

Discussion in 'C Programming' started by TK, Nov 28, 2005.

  1. TK

    TK Guest

    Hi,

    I'm a C-Newbie and here's my question: how can I include headers for
    different plattforms like Mac OS X, Windows 2000 and Suse Linux?

    I want to use my program on this three Systems.

    Thanks for help.

    o-o

    Thomas
     
    TK, Nov 28, 2005
    #1
    1. Advertising

  2. TK

    smiletolead Guest

    It depends on the compiler are using: On windows, the compiler option
    /I is used to specify the directories to look for header files. On
    linux, the compiler option, -I can be used to specify the header file
    search path. If you are using gcc on Mac OS, you can use the option -I
    as in linux. Suppose you are compiling your program on linux. You can
    include the headers as follows:
    gcc yourprogram.c -I<include-dir>
     
    smiletolead, Nov 28, 2005
    #2
    1. Advertising

  3. TK

    TK Guest

    Hi,

    thanks for help.

    > It depends on the compiler are using: On windows, the compiler option
    > /I is used to specify the directories to look for header files. On
    > linux, the compiler option, -I can be used to specify the header file
    > search path. If you are using gcc on Mac OS, you can use the option -I
    > as in linux. Suppose you are compiling your program on linux. You can
    > include the headers as follows:
    > gcc yourprogram.c -I<include-dir>
    >


    Ah, ok.

    But I thought there are some preprocessor-directives (with symbols for
    an appropriate OS).

    o-o

    Thomas
     
    TK, Nov 28, 2005
    #3
  4. TK wrote:
    > Hi,
    >
    > thanks for help.
    >
    > > It depends on the compiler are using: On windows, the compiler option
    > > /I is used to specify the directories to look for header files. On
    > > linux, the compiler option, -I can be used to specify the header file
    > > search path. If you are using gcc on Mac OS, you can use the option -I
    > > as in linux. Suppose you are compiling your program on linux. You can
    > > include the headers as follows:
    > > gcc yourprogram.c -I<include-dir>
    > >

    >
    > Ah, ok.
    >
    > But I thought there are some preprocessor-directives (with symbols for
    > an appropriate OS).
    >
    > o-o
    >
    > Thomas


    If you *really* are doing platform specific stuff, you can
    select what is included as follows. Just examples, not sure
    these are what you want...

    #if defined (_WIN32)
    #include <conio.h>
    #elif defined(__linux__)
    #include <curses.h>
    ....
    #endif

    If you need the above and have questions, you should direct
    them to newsgroups about the individual operating systems...

    -David
     
    David Resnick, Nov 28, 2005
    #4
  5. On Mon, 28 Nov 2005 14:58:53 +0100, in comp.lang.c , TK
    <> wrote:

    >I'm a C-Newbie and here's my question: how can I include headers for
    >different plattforms like Mac OS X, Windows 2000 and Suse Linux?


    Headers are just where functions and so forth are declared. The actual
    definitions are in a library, which is binary-compatible only with the
    operating system it came from. You can't generally use libraries from
    one OS on another OS.

    See also FAQ 10.11.

    >I want to use my program on this three Systems.


    Then you must compile it for all three systems - generally by
    compiling it /on/ each system in turn.

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Nov 28, 2005
    #5
  6. On Mon, 28 Nov 2005 16:29:12 +0100, in comp.lang.c , TK
    <> wrote:

    >
    >But I thought there are some preprocessor-directives (with symbols for
    >an appropriate OS).


    You'd use preprocessor directives like this to customise a header or C
    file for different environments, yes. You see this a lot in gnu
    projects for instance

    It would not allow your code to run on those different environments,
    unless you then also compiled it multiple times, and linked it against
    platform specific libraries. This is all offtopic here tho.
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Nov 28, 2005
    #6
  7. TK

    TK Guest

    Hi,

    thanks for help!

    > If you *really* are doing platform specific stuff, you can
    > select what is included as follows. Just examples, not sure
    > these are what you want...
    >
    > #if defined (_WIN32)
    > #include <conio.h>
    > #elif defined(__linux__)
    > #include <curses.h>
    > ...
    > #endif


    Yes, I'm looking for things like this.

    o-o

    Thomas
     
    TK, Nov 29, 2005
    #7
    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. Aguilar, James
    Replies:
    2
    Views:
    691
    Aguilar, James
    Jul 16, 2004
  2. dont bother
    Replies:
    0
    Views:
    810
    dont bother
    Mar 3, 2004
  3. Andreas Bogenberger
    Replies:
    3
    Views:
    932
    Andreas Bogenberger
    Feb 22, 2008
  4. Phil
    Replies:
    4
    Views:
    687
    Gabriel Genellina
    Jan 17, 2010
  5. Ian
    Replies:
    2
    Views:
    1,963
Loading...

Share This Page