Professional Web Applications Themes

header/include files and compilers - UNIX Programming

Hi everyone, When writing a program (say, work.c), I could simply include header files using, for example: #include <stdio.h> and "gcc work.c" would compile no problem. For the compiler such as gcc, how does it know where to find that include file, without even having to specify paths to search using -I ? I'd certainly think it has internally included (default) path to /usr/include/ ? It also seems to be the case for arm-linu-gcc (cross compiler for arm processor). What if I do not want use those header files in my native system but the others (ie. the ones that ...

  1. #1

    Default header/include files and compilers

    Hi everyone,

    When writing a program (say, work.c), I could simply include header
    files using, for example:
    #include <stdio.h>

    and "gcc work.c" would compile no problem.

    For the compiler such as gcc, how does it know where to find that
    include file, without even having to specify paths to search using -I ?
    I'd certainly think it has internally included (default) path to
    /usr/include/ ? It also seems to be the case for arm-linu-gcc (cross
    compiler for arm processor). What if I do not want use those header
    files in my native system but the others (ie. the ones that come with
    arm cross compiler package)?

    In addition, if two included paths both contain the header needed (same
    name but not necessary the same content). Which one does a compiler choose?

    I never have understood this concept until recent I started working with
    different compiler for different platform which has its own libraries
    and different versions of linux kernels. And I'd get confused with
    different versions of header files in my system.

    I'd really appreciate if anyone could answer these questions for me.
    Thanks alot!

    Johnny

    Johnny Shih Guest

  2. #2

    Default Re: header/include files and compilers

    Johnny Shih wrote:
    > Hi everyone,
    >
    > When writing a program (say, work.c), I could simply include header
    > files using, for example:
    > #include <stdio.h>
    >
    > and "gcc work.c" would compile no problem.
    >
    > For the compiler such as gcc, how does it know where to find that
    > include file, without even having to specify paths to search using -I ?
    > I'd certainly think it has internally included (default) path to
    > /usr/include/ ? It also seems to be the case for arm-linu-gcc (cross
    > compiler for arm processor). What if I do not want use those header
    > files in my native system but the others (ie. the ones that come with
    > arm cross compiler package)?
    >
    > In addition, if two included paths both contain the header needed (same
    > name but not necessary the same content). Which one does a compiler choose?
    >
    > I never have understood this concept until recent I started working with
    > different compiler for different platform which has its own libraries
    > and different versions of linux kernels. And I'd get confused with
    > different versions of header files in my system.
    >
    > I'd really appreciate if anyone could answer these questions for me.
    > Thanks alot!
    >
    Sure. If your using a flavor of gcc, do a `gcc -v'. The output will refer
    to a `specs' file that will contain all such information.

    HTH,
    --ag


    --
    Artie Gold -- Austin, Texas



    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    [url]http://www.newsfeed.com[/url] The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    Artie Gold Guest

Similar Threads

  1. intel compilers
    By Shea Martin in forum Ubuntu
    Replies: 0
    Last Post: April 15th, 12:56 AM
  2. Replies: 4
    Last Post: November 18th, 11:36 PM
  3. Replies: 2
    Last Post: September 17th, 02:46 PM
  4. Replies: 3
    Last Post: July 30th, 02:02 PM
  5. include() header and footer
    By Jez in forum PHP Development
    Replies: 3
    Last Post: July 12th, 04:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139