There are few rules, according to the ISO standard. Both forms are implementation-dependent as to where they look for the header files. They don't even have to be files.
Section 2.9
of C++11 makes no distinction between the two varieties other than the fact you can include "
in the <>
variant and >
in the ""
variant but few people would be silly enough to use those characters in file names :-)
Section 16.2
further states:
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.
I tend to use <>
for system headers and ""
for my own headers, but that's personal preference only. I would note that the aforementioned C++11 document states:
Note: Although an implementation may provide a mechanism for making arbitrary source files available to the <>
search, in general programmers should use the <>
form for headers provided with the implementation, and the ""
form for sources outside the control of the implementation.
This isn't mandated but it's a good idea nonetheless.