Search for built-in header and application header

Discussion in 'C Programming' started by linq936@gmail.com, Aug 22, 2007.

  1. Guest

    Hi,
    I always have an impression that for the following semantics:
    #include <something> e.g. #include <stdio.h>
    Compiler searches it from built-in header search path, on UNIX, it
    could be /usr/include, /bin/include.

    And for the following semantics:
    #include "someting" e.g. #include "mine.h"
    Compiler searches it according to the -I command option and the
    built-in search path.

    But I just encountered a problem, it is Visual C++ compiler, it
    seems for #include <> type, it also search for -I path. And it
    automatically add "include" to the end of -I path, here is an example:

    I have -I c:/repo in VC compiler path and in my C code, I have:
    #include <auto_array> while the file actually locates at c:/repo/
    include/auto_array, but VC compiler finds it.

    Could you confirm 2 things:

    1. Compiler searches builtin path and -I command option for both
    "#include <>" and "#include "" " type include.

    2. Compiler add "include" to the end of each search path named in -I
    option.

    Here is copy & paste from my compile command:

    c:/msvsn2003/vc7/bin/cl.exe -W3 -Tp ../s/TestUtils.c -c -nologo -GR -
    MDd -Ob2 -Zi -GX -DDEBUG -DNT -DNO_TCL_STUBS -FdlibTestUtils.pdb -
    FplibTestUtils.pch -Ic:/repo -I../i
    TestUtils.c

    Thanks.
     
    , Aug 22, 2007
    #1
    1. Advertising

  2. writes:
    > I always have an impression that for the following semantics:
    > #include <something> e.g. #include <stdio.h>
    > Compiler searches it from built-in header search path, on UNIX, it
    > could be /usr/include, /bin/include.
    >
    > And for the following semantics:
    > #include "someting" e.g. #include "mine.h"
    > Compiler searches it according to the -I command option and the
    > built-in search path.
    >
    > But I just encountered a problem, it is Visual C++ compiler,

    [snip]

    For '#include <foo.h>', the compiler "searches a sequence of
    implementation-defined places" for the foo.h header. (Note that a
    header needn't be a source file; for example, some compilers support
    precompiled headers.)

    For '#include "foo.h"', the compiler searches for a source file" in an
    implementation-defined manner". If that search fails, it tries again
    as if the argument were '<foo.h>'.

    See C99 6.10.2 for the full statement of the rules. See
    <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf> for the
    latest post-C99 draft (that section is identical in the actual C99
    standard and in n1124).

    I believe the behavior you describe is consistent with the (fairly
    loose) requirements of the standard.

    If you have questions about the behavior of the Visual C++ compiler,
    you'll need to ask in a forum that discusses the Visual C++ compiler,
    rather than just the C language.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Aug 22, 2007
    #2
    1. Advertising

  3. cr88192 Guest

    <> wrote in message
    news:...
    > Hi,
    > I always have an impression that for the following semantics:
    > #include <something> e.g. #include <stdio.h>
    > Compiler searches it from built-in header search path, on UNIX, it
    > could be /usr/include, /bin/include.
    >
    > And for the following semantics:
    > #include "someting" e.g. #include "mine.h"
    > Compiler searches it according to the -I command option and the
    > built-in search path.
    >


    exact details depend, but:
    usually '<...>' searches the both the user and system specified include
    directories;
    usually "..." first searches in the path of the source file, maybe then
    behaving like '<...>'.
     
    cr88192, Aug 23, 2007
    #3
  4. On Wed, 22 Aug 2007 11:00:27 -0700, wrote:


    snip

    > But I just encountered a problem, it is Visual C++ compiler, it
    >seems for #include <> type, it also search for -I path. And it
    >automatically add "include" to the end of -I path, here is an example:
    >


    snip

    Since your question has nothing to do with the language and everything
    to do with your particular compiler, you will get better answers from
    the microsoft.public.vc family of newsgroups.


    Remove del for email
     
    Barry Schwarz, Aug 26, 2007
    #4
    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. zeal elite
    Replies:
    2
    Views:
    355
  2. Gabriel Genellina

    Re: substring search without using built in utils

    Gabriel Genellina, Nov 9, 2006, in forum: Python
    Replies:
    6
    Views:
    297
    Bruno Desthuilliers
    Nov 13, 2006
  3. mlt
    Replies:
    2
    Views:
    891
    Jean-Marc Bourguet
    Jan 31, 2009
  4. devpoint
    Replies:
    0
    Views:
    277
    devpoint
    Oct 7, 2003
  5. Abby Lee
    Replies:
    5
    Views:
    447
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page