0

Possible Duplicate:
what is the difference between #include <filename> and #include “filename”

Why do we use Quotation Marks ("...") for custom build classes and braces for built in classes(<...>)?

Community
  • 1
  • 1
Taimur Ajmal
  • 2,778
  • 6
  • 39
  • 57

3 Answers3

5

It's to denote that the header isn't system-wide.

This is a convention, not a requirement.

By the way, those aren't inverted commas, they're quotation marks. There is a difference in the field of typography.

Borealid
  • 95,191
  • 9
  • 106
  • 122
2

At least for C, it makes no difference nowadays. The ISO standard states that the location of the files is implementation defined in both cases.

The usual way is to use <> for system headers (things under /usr/include for example) and "" for your own headers, but it's not required.

The relevant bits of C99 are from 6.10.2, "Source file inclusion", quoted below.


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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • quote and link the standard for bonus points :D – Matt Joiner Aug 22 '10 at 02:41
  • Why bother, Matt? It's quoted in probably every other dup of this: http://stackoverflow.com/questions/3162030/difference-between-angle-bracket-and-double-quotes-while-including-header/3162067#3162067 http://stackoverflow.com/questions/21593/what-is-the-difference-between-include-filename-and-include-filename/77092#77092 – Gabe Aug 22 '10 at 02:45
1

Yeah, from what I've heard, angle brackets (<'s) are used to denote that the header was provided with the compiler, OR that the compiler has been told about a directory in which the header file can be found (-I). Quotes ("'s) are usually used for header files within the source tree. But like others have mentioned, it's not a requirement.

Jorge Israel Peña
  • 36,800
  • 16
  • 93
  • 123