include header

Discussion in 'C++' started by Christopher, Mar 20, 2008.

  1. Christopher

    Christopher Guest

    On Mar 19, 9:03 pm, June Lee <> wrote:
    > when include headers in C++ what's different when using
    >
    > < > or " " like the following?
    >
    > #include "ne_session.h"
    > #include <ne_uri.h>


    First hit on Google when searching for: include "" vs include <>
    http://www.thescripts.com/forum/thread138207.html

    Tryed Google advanced search to limit to this NG, but couldnt get it
    to work :(

    At any rate it has been asked before, Google is your friend.
     
    Christopher, Mar 20, 2008
    #1
    1. Advertising

  2. On Mar 20, 1:03 pm, June Lee <> wrote:
    > when include headers in C++ what's different when using
    >
    > < > or " " like the following?
    >
    > #include "ne_session.h"
    > #include <ne_uri.h>


    #include "..." means the header file is in the same directory,
    where #include <...> means the header file is in the directory that
    the compiler uses.

    My explanation is not covering everything about the differences
    between two. As Christopher recommended you, do some googling, you
    will find more than millions of tutorials =)

    cheers,
    Alex
     
    Alexander Dong Back Kim, Mar 20, 2008
    #2
    1. Advertising

  3. Christopher

    June Lee Guest

    when include headers in C++ what's different when using

    < > or " " like the following?


    #include "ne_session.h"
    #include <ne_uri.h>
     
    June Lee, Mar 20, 2008
    #3
  4. Christopher

    Kai-Uwe Bux Guest

    June Lee wrote:

    > when include headers in C++ what's different when using
    >
    > < > or " " like the following?
    >
    >
    > #include "ne_session.h"
    > #include <ne_uri.h>


    What these do is mostly up to the implementation. You have to check the
    documentation of your compiler. Pay particular attention to settings and
    switches.


    From the standard [16.2/2-3]:

    A preprocessing directive of the form

    # include <h-char-sequence> new-line

    searches a sequence of implementation-defined places for a header identified
    uniquely by the specified sequence between the < and > delimiters, and
    causes the replacement of that directive by the entire contents of the
    header. How the places are specified or the header identified is
    implementation-defined.

    A preprocessing directive of the form

    # include "q-char-sequence" new-line

    causes the replacement of that directive by the entire contents of the
    source file identified by the specified sequence between the " delimiters.
    The named source file is searched for in an implementation-defined
    manner. If this search is not supported, or if the search fails, the
    directive is reprocessed as if it read

    # include <h-char-sequence> new-line

    with the identical contained sequence (including > characters, if any) from
    the original directive.



    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Mar 20, 2008
    #4
  5. Christopher

    James Kanze Guest

    On Mar 20, 3:07 am, Kai-Uwe Bux <> wrote:
    > June Lee wrote:
    > > when include headers in C++ what's different when using


    > > < > or " " like the following?


    > > #include "ne_session.h"
    > > #include <ne_uri.h>


    > What these do is mostly up to the implementation. You have to
    > check the documentation of your compiler. Pay particular
    > attention to settings and switches.


    In practice, however, the first will first look in the directory
    where the including file is located, then behave more or less
    like the second. There may be options to override this, but if
    you specify include directories using the more or less standard
    -I option (or /I under Windows), then the first looks first in
    the directory where the including file is located, then in the
    directories specified by the -I options (in the order they were
    given), then in the "standard" locatsions; the second just skips
    the lookup in the directory where the including file is located.

    Of course, there's no guarantee about this from the standard,
    but the above does hold for pretty much all compilers on the
    usual platforms (Windows and mainstream Unix). I think some of
    the compilers have additional options, which can be used to
    change it, however.

    In good coding practice, of course, the first is used for your
    headers, the second for system headers (with a more or less
    application dependent notion of what is "system"---I would
    generally consider things like the data base, or Boost, part of
    the "system").

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orient�e objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34
     
    James Kanze, Mar 20, 2008
    #5
    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. Danny Anderson
    Replies:
    5
    Views:
    529
    Victor Bazarov
    Aug 15, 2003
  2. Rolf Magnus
    Replies:
    2
    Views:
    628
    Karl Heinz Buchegger
    Nov 28, 2003
  3. Aguilar, James
    Replies:
    2
    Views:
    725
    Aguilar, James
    Jul 16, 2004
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    1,003
    Andreas Bogenberger
    Feb 22, 2008
  5. mlt
    Replies:
    2
    Views:
    907
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page