compiling and finding the source

This is a discussion on compiling and finding the source within the C Programming forums, part of the General Programming Boards category; Dumb question, but when you include a header file in a C program, how does the compiler/program know where to ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    69

    compiling and finding the source

    Dumb question, but when you include a header file in a C program, how does the compiler/program know where to find the source file?

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    1. Config files, or the registry
    2. Hard coded into the compiler
    3. User defined (or environment variables).

    Usually, the compiler will have a list of places it will go through in order to find the header. For example,
    1. Where you tell it to look
    2. /usr/include
    3. /path/to/my/program

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    69
    By source file, I meant the *.c file. If I specify foo.h, does the compiler/program look for foo.c in the same location as foo.h?

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    if you use "" - then compiler start from the current folder, then it goes all the include path
    then you use <> - it skips the current folder and starts with the include path scanning directly
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling Anagramarama
    By biggins in forum C Programming
    Replies: 2
    Last Post: 01-18-2007, 04:35 PM
  2. Help on compiling code
    By mattyp1977 in forum C++ Programming
    Replies: 4
    Last Post: 03-26-2006, 04:07 PM
  3. need help finding problems
    By kwm32 in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2004, 05:49 PM
  4. Finding out a Parse error
    By Ziionyx in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2003, 12:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21