Preprocessor includes, difference between quote and lt/gt

Discussion in 'C Programming' started by artifact.one@googlemail.com, Nov 30, 2006.

  1. Guest

    Hi.

    What's the practical difference between:

    #include <header.h>

    and:

    #include "header.h"

    ...besides the fact that in the second case, 'header.h' will be used if
    it's
    in the current working directory?

    cheers,
    MC
    , Nov 30, 2006
    #1
    1. Advertising

  2. said:

    > Hi.
    >
    > What's the practical difference between:
    >
    > #include <header.h>
    >
    > and:
    >
    > #include "header.h"



    3.1.7 of C89 says (in part): "The sequences in both forms of header names
    are mapped in an implementation-defined manner to headers or external
    source file names as specified in $3.8.2."

    3.8.2 says (in part): " 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.


    So the practical upshot is that C provides two different mechanisms for
    finding a header: "header" and <header>. If you use "header", the
    implementation uses a particular search strategy, which could of course
    fail. If it does, the implementation pretends you'd used <header> instead,
    which also uses a particular search strategy for locating the header. There
    need not necessarily be any difference between the two strategies, but on
    typical desktop systems there normally is. (I know of no typical desktop
    exceptions, anyway.)


    > ..besides the fact that in the second case, 'header.h' will be used if
    > it's
    > in the current working directory?


    A mere implementation detail, of no particular significance in comp.lang.c -
    the C language does not require implementations to support or even
    recognise a concept of "directory", and some implementations do not in fact
    recognise such a concept.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
    Richard Heathfield, Nov 30, 2006
    #2
    1. Advertising

  3. Guest

    Ok, thanks. That explains it well.

    MC
    , Nov 30, 2006
    #3
  4. CBFalconer Guest

    wrote:
    >
    > What's the practical difference between:
    >
    > #include <header.h>
    > and:
    > #include "header.h"
    >
    > ..besides the fact that in the second case, 'header.h' will be
    > used if it's in the current working directory?


    Not so. Look at your system documentation. Note that <header.h>
    need not access any file whatsoever. What the standard says is
    (N869):

    [#2] 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.

    [#3] 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.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>
    CBFalconer, Dec 1, 2006
    #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. jakk
    Replies:
    4
    Views:
    12,144
  2. ashwani
    Replies:
    3
    Views:
    3,739
    Frederick Gotham
    Aug 11, 2006
  3. Evan
    Replies:
    1
    Views:
    389
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  4. Evan
    Replies:
    3
    Views:
    518
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  5. vikrant
    Replies:
    8
    Views:
    361
    vikrant
    May 17, 2007
Loading...

Share This Page