#include -- double quotes vs. angle brackets

Discussion in 'C++' started by bartek, May 25, 2004.

  1. bartek

    bartek Guest

    Hi,

    I'm aware that both quoted and angle-bracketed strings in an #include
    directive result in implementation-defined file lookup, differing in the
    fact that #include "foo.h" first checks *something* and then falls back to
    the same behaviour as #include <foo.h>.

    Now, in reality #include <foo.h> generally results in file name being
    checked up in explicitly specified locations (-I command line options,
    system header locations), while the double quoted version gets the current
    directory checked first.

    My question is:
    - Is that the current working directory? E.g. the directory from which the
    compiler is being run.
    - Or, the directory where the file with the said #include directive being
    parsed is lying?

    What's the common behaviour?

    Cheers.
    --
    :: bartekd [at] o2 [dot] pl
    bartek, May 25, 2004
    #1
    1. Advertising

  2. bartek

    Unforgiven Guest

    bartek wrote:
    > My question is:
    > - Is that the current working directory? E.g. the directory from
    > which the compiler is being run.
    > - Or, the directory where the file with the said #include directive
    > being parsed is lying?


    The latter is common. The former would make not much sense, since
    application-specific header files are rarely in the same directory as the
    compiler.

    Also note that, at least in Windows, the current working directory need not
    actually be the directory that contains the executable. The compiler might
    change the current working directory to the location of the compiled source
    file, and then look for the header file in the working directory, resulting
    in the same behaviour as option 2.

    --
    Unforgiven
    Unforgiven, May 26, 2004
    #2
    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. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,843
    Hermit Dave
    Sep 22, 2004
  2. Keith Hughitt

    Angle brackets in command-line arguments?

    Keith Hughitt, Jul 16, 2008, in forum: Python
    Replies:
    4
    Views:
    611
    Keith Hughitt
    Jul 16, 2008
  3. jOhn
    Replies:
    1
    Views:
    219
    Phlip
    Jan 29, 2008
  4. Richard Sandoval
    Replies:
    5
    Views:
    201
    7stud --
    Apr 26, 2011
  5. Angle Brackets vs. foreach

    , Apr 13, 2005, in forum: Perl Misc
    Replies:
    1
    Views:
    122
    Richard Gration
    Apr 13, 2005
Loading...

Share This Page