<p>What is the difference between using angle brackets and quotes in an <code>include</code> directive?</p>
<ul>
<li><code>#include &lt;filename&gt;</code></li>
<li><code>#include &quot;filename&quot;</code></li>
</ul>

[{'answer_id': 21594, 'author': 'quest49', 'author_id': 2399, 'author_profile': 'https://Stackoverflow.com/users/2399', 'pm_score': 11, 'selected': False, 'text': '<p>What differs is the locations in which the preprocessor searches for the file to be included.</p>\n<ul>\n<li><p><code>#include &lt;filename&gt;</code> \xa0 The preprocessor searches in an implementation-defined manner, normally in directories pre-designated by the compiler/IDE. This method is normally used to include header files for the C standard library and other header files associated with the target platform.</p>\n</li>\n<li><p><code>#include &quot;filename&quot;</code> \xa0 The preprocessor also searches in an implementation-defined manner, but one that is normally used to include programmer-defined header files and typically includes same directory as the file containing the directive (unless an absolute path is given).</p>\n</li>\n</ul>\n<p>For GCC, a more complete description is available in the GCC <a href="https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html" rel="noreferrer">documentation on search paths</a>.</p>\n'}, {'answer_id': 41538, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': False, 'text': '<p>The <code>&lt;file&gt;</code> include tells the preprocessor to search in <code>-I</code> directories and in predefined directories <strong>first</strong>, then in the .c file\'s directory. The <code>"file"</code> include tells the preprocessor to search the source file\'s directory <strong>first</strong>, and then revert to <code>-I</code> and predefined. All destinations are searched anyway, only the order of search is different.</p>\n\n<p>The 2011 standard mostly discusses the include files in "16.2 Source file inclusion".</p>\n\n<blockquote>\n  <p>2 A preprocessing directive of the form</p>\n  \n  <p><code># include &lt;h-char-sequence&gt; new-line</code></p>\n  \n  <p>searches a sequence of implementation-defined places for a header identified uniquely by the\n  specified sequence between the &lt; and > delimiters, and causes the\n  replacement of that directive by the entire contents of the header.\n  How the places are specified or the header identified is\n  implementation-defined.</p>\n  \n  <p>3 A preprocessing directive of the form</p>\n  \n  <p><code># include "q-char-sequence" new-line</code></p>\n  \n  <p>causes the replacement of that directive by the entire contents of the source file identified by the\n  specified sequence between the " delimiters. The named source file is\n  searched for in an implementation-defined manner. If this search is\n  not supported, or if the search fails, the directive is reprocessed as\n  if it read</p>\n  \n  <p><code># include &lt;h-char-sequence&gt; new-line</code></p>\n  \n  <p>with the identical contained sequence (including > characters, if any) from the original directive.</p>\n</blockquote>\n\n<p>Note that <code>"xxx"</code> form degrades to <code>&lt;xxx&gt;</code> form if the file is not found. The rest is implementation-defined.</p>\n'}, {'answer_id': 50266, 'author': 'aib', 'author_id': 1088, 'author_profile': 'https://Stackoverflow.com/users/1088', 'pm_score': 8, 'selected': False, 'text': '<p>The sequence of characters between &lt; and > uniquely refer to a header, which isn\'t necessarily a file. Implementations are pretty much free to use the character sequence as they wish. (Mostly, however, just treat it as a file name and do a search in the <em>include path</em>, as the other posts state.)</p>\n\n<p>If the <code>#include "file"</code> form is used, the implementation first looks for a file of the given name, if supported. If not (supported), or if the search fails, the implementation behaves as though the other (<code>#include &lt;file&gt;</code>) form was used.</p>\n\n<p>Also, a third form exists and is used when the <code>#include</code> directive doesn\'t match either of the forms above. In this form, some basic preprocessing (such as macro expansion) is done on the "operands" of the <code>#include</code> directive, and the result is expected to match one of the two other forms.</p>\n'}, {'answer_id': 77092, 'author': 'piCookie', 'author_id': 8763, 'author_profile': 'https://Stackoverflow.com/users/8763', 'pm_score': 10, 'selected': False, 'text': '<p>The only way to know is to read your implementation\'s documentation.</p>\n\n<p>In <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf#page=182" rel="noreferrer">the C standard</a>, section 6.10.2, paragraphs 2 to 4 state:</p>\n\n<blockquote>\n  <ul>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include &lt;h-char-sequence&gt; new-line\n</code></pre>\n  \n  <p>searches a sequence of implementation-defined places for a <strong>header</strong> identified uniquely by the specified sequence between the <code>&lt;</code> and <code>&gt;</code> delimiters, and causes the replacement of that directive by the entire contents of the <strong>header</strong>. How the places are specified or the header identified is implementation-defined.</p></li>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include "q-char-sequence" new-line\n</code></pre>\n  \n  <p>causes the replacement of that directive by the entire contents of the <strong>source file</strong> identified by the specified sequence between the <code>"</code> delimiters. The named <strong>source file</strong> 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</p>\n\n<pre><code>#include &lt;h-char-sequence&gt; new-line\n</code></pre>\n  \n  <p>with the identical contained sequence (including <code>&gt;</code> characters, if any) from the original\n  directive.</p></li>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include pp-tokens new-line\n</code></pre>\n  \n  <p>(that does not match one of the two previous forms) is permitted. The preprocessing tokens after <code>include</code> in the directive are processed just as in normal text. (Each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens.) The directive resulting after all replacements shall match one of the two previous forms. The method by which a sequence of preprocessing tokens between a <code>&lt;</code> and a <code>&gt;</code> preprocessing token pair or a pair of <code>"</code> characters is combined into a single header name preprocessing token is implementation-defined.</p></li>\n  </ul>\n  \n  <h3>Definitions:</h3>\n  \n  <ul>\n  <li><p>h-char: any member of the source character set except the new-line character and <code>&gt;</code></p></li>\n  <li><p>q-char: any member of the source character set except the new-line character and <code>"</code></p></li>\n  </ul>\n</blockquote>\n'}, {'answer_id': 4932605, 'author': 'Stefan Steiger', 'author_id': 155077, 'author_profile': 'https://Stackoverflow.com/users/155077', 'pm_score': 6, 'selected': False, 'text': '<p>It does:</p>\n\n<pre><code>"mypath/myfile" is short for ./mypath/myfile\n</code></pre>\n\n<p>with <code>.</code> being either the directory of the file where the <code>#include</code> is contained in, and/or the current working directory of the compiler, and/or the <code>default_include_paths</code></p>\n\n<p>and</p>\n\n<pre><code>&lt;mypath/myfile&gt; is short for &lt;defaultincludepaths&gt;/mypath/myfile\n</code></pre>\n\n<p>If <code>./</code> is in <code>&lt;default_include_paths&gt;</code>, then it doesn\'t make a difference.</p>\n\n<p>If <code>mypath/myfile</code> is in another include directory, the behavior is undefined.</p>\n'}, {'answer_id': 4932607, 'author': 'Maxim Egorushkin', 'author_id': 412080, 'author_profile': 'https://Stackoverflow.com/users/412080', 'pm_score': 4, 'selected': False, 'text': '<p>For <code>#include ""</code> a compiler normally searches the folder of the file which contains that include and then the other folders. For <code>#include &lt;&gt;</code> the compiler does not search the current file\'s folder.</p>\n'}, {'answer_id': 4932754, 'author': 'Damon', 'author_id': 572743, 'author_profile': 'https://Stackoverflow.com/users/572743', 'pm_score': 4, 'selected': False, 'text': '<p>An #include with angle brackets will search an "implementation-dependent list of places" (which is a very complicated way of saying "system headers") for the file to be included.</p>\n\n<p>An #include with quotes will just search for a file (and, "in an implementation-dependent manner", bleh). Which means, in normal English, it will try to apply the path/filename that you toss at it and will not prepend a system path or tamper with it otherwise.</p>\n\n<p>Also, if #include "" fails, it is re-read as #include &lt;> by the standard.</p>\n\n<p>The <a href="http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html" rel="noreferrer">gcc documentation</a> has a (compiler specific) description which although being specific to gcc and not the standard, is a lot easier to understand than the attorney-style talk of the ISO standards.</p>\n'}, {'answer_id': 7589297, 'author': 'Barbara', 'author_id': 969921, 'author_profile': 'https://Stackoverflow.com/users/969921', 'pm_score': 3, 'selected': False, 'text': '<pre><code>#include "filename" // User defined header\n#include &lt;filename&gt; // Standard library header.\n</code></pre>\n\n<p>Example:</p>\n\n<p>The filename here is <code>Seller.h</code>:</p>\n\n<pre><code>#ifndef SELLER_H     // Header guard\n#define SELLER_H     // Header guard\n\n#include &lt;string&gt;\n#include &lt;iostream&gt;\n#include &lt;iomanip&gt;\n\nclass Seller\n{\n    private:\n        char name[31];\n        double sales_total;\n\n    public:\n        Seller();\n        Seller(char[], double);\n        char*getName();\n\n#endif\n</code></pre>\n\n<p>In the class implementation (for example, <code>Seller.cpp</code>, and in other files that will use the file <code>Seller.h</code>), the header defined by the user should now be included, as follows:</p>\n\n<pre><code>#include "Seller.h"\n</code></pre>\n'}, {'answer_id': 7889340, 'author': 'Denis Ros', 'author_id': 1012712, 'author_profile': 'https://Stackoverflow.com/users/1012712', 'pm_score': 5, 'selected': False, 'text': '<p>At least for GCC version &lt;= 3.0, the angle-bracket form does not generate a dependency between the included file and the including one.</p>\n\n<p>So if you want to generate dependency rules (using the GCC -M option for exemple), you must use the quoted form for the files that should be included in the dependency tree.</p>\n\n<p>(See <a href="http://gcc.gnu.org/onlinedocs/cpp/Invocation.html" rel="noreferrer">http://gcc.gnu.org/onlinedocs/cpp/Invocation.html</a> )</p>\n'}, {'answer_id': 11576616, 'author': 'Yann Droneaud', 'author_id': 611560, 'author_profile': 'https://Stackoverflow.com/users/611560', 'pm_score': 7, 'selected': False, 'text': '<p>Some good answers here make references to the C standard but forgot the POSIX standard, especially the specific behavior of the <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html">c99 (e.g. C compiler)</a> command.</p>\n\n<p>According to <a href="https://www2.opengroup.org/ogsys/catalog/C138">The Open Group Base Specifications Issue 7</a>,</p>\n\n<blockquote>\n  <p><strong>-I</strong>  <em>directory</em></p>\n  \n  <p>Change the algorithm for searching for headers whose names are not absolute pathnames to look in the directory named by the <em>directory</em> pathname before looking in the usual places. Thus, headers whose names are enclosed in double-quotes ( "" ) shall be searched for first in the directory of the file with the <strong>#include</strong> line, then in directories named in <strong>-I</strong> options, and last in the usual places. For headers whose names are enclosed in angle brackets ( "&lt;>" ), the header shall be searched for only in directories named in <strong>-I</strong> options and then in the usual places. Directories named in <strong>-I</strong> options shall be searched in the order specified. Implementations shall support at least ten instances of this option in a single <em>c99</em> command invocation.</p>\n</blockquote>\n\n<p>So, in a POSIX compliant environment, with a POSIX compliant C compiler, <code>#include "file.h"</code> is likely going to search for <code>./file.h</code> first, where <code>.</code> is the directory where is the file with the <code>#include</code> statement, while <code>#include &lt;file.h&gt;</code>, is likely going to search for <code>/usr/include/file.h</code> first, where <code>/usr/include</code> is your system defined <em>usual places</em> for headers (it\'s seems not defined by POSIX).</p>\n'}, {'answer_id': 13910243, 'author': 'AndroidDev', 'author_id': 1085742, 'author_profile': 'https://Stackoverflow.com/users/1085742', 'pm_score': 4, 'selected': False, 'text': '<ul>\n<li><strong><code>#include &lt;&gt;</code> is for predefined header files</strong></li>\n</ul>\n\n<p>If the header file is predefined then you would simply write the header file name in angular brackets, and it would look like this (assuming we have a predefined header file name iostream):</p>\n\n<pre><code>#include &lt;iostream&gt;\n</code></pre>\n\n<ul>\n<li><strong><code>#include " "</code> is for header files the programmer defines</strong></li>\n</ul>\n\n<p>If you (the programmer) wrote your own header file then you would write the header file name in quotes. So, suppose you wrote a header file called <code>myfile.h</code>, then this is an example of how you would use the include directive to include that file:</p>\n\n<pre><code>#include "myfile.h"\n</code></pre>\n'}, {'answer_id': 16921556, 'author': 'Eakan Gopalakrishnan', 'author_id': 2262959, 'author_profile': 'https://Stackoverflow.com/users/2262959', 'pm_score': 3, 'selected': False, 'text': '<p>The simple general rule is to use angled brackets to include header files that come with the compiler. Use double quotes to include any other header files. Most compilers do it this way.</p>\n\n<p><em><a href="http://www.learncpp.com/cpp-tutorial/19-header-files/" rel="nofollow">1.9 — Header files</a></em> explains in more detail about pre-processor directives. If you are a novice programmer, that page should help you understand all that. I learned it from here, and I have been following it at work.</p>\n'}, {'answer_id': 22011884, 'author': 'sp2danny', 'author_id': 3202093, 'author_profile': 'https://Stackoverflow.com/users/3202093', 'pm_score': 4, 'selected': False, 'text': '<p>Many of the answers here focus on the paths the compiler will search in order to find the file. While this is what most compilers do, a conforming compiler is allowed to be preprogrammed with the effects of the standard headers, and to treat, say, <code>#include &lt;list&gt;</code> as a switch, and it need not exist as a file at all.</p>\n\n<p>This is not purely hypothetical. There is at least one compiler that work that way. Using <code>#include &lt;xxx&gt;</code> only with standard headers is recommended.</p>\n'}, {'answer_id': 25535615, 'author': 'srsci', 'author_id': 1216268, 'author_profile': 'https://Stackoverflow.com/users/1216268', 'pm_score': 3, 'selected': False, 'text': '<p>The <code>#include &lt;filename&gt;</code> is used when a system file is being referred to. That is a header file that can be found at system default locations like <code>/usr/include</code> or <code>/usr/local/include</code>. For your own files that needs to be included in another program you have to use the <code>#include "filename"</code> syntax.</p>\n'}, {'answer_id': 26372302, 'author': 'riderBill', 'author_id': 4079867, 'author_profile': 'https://Stackoverflow.com/users/4079867', 'pm_score': 4, 'selected': False, 'text': '<p>Thanks for the great answers, esp. Adam Stelmaszczyk and piCookie, and aib.</p>\n<p>Like many programmers, I have used the informal convention of using the <code>&quot;myApp.hpp&quot;</code> form for application specific files, and the <code>&lt;libHeader.hpp&gt;</code> form for library and compiler system files, i.e. files specified in <code>/I</code> and the <code>INCLUDE</code> environment variable, for years thinking that was the standard.</p>\n<p>However, the C standard states that the search order is implementation specific, which can make portability complicated.  To make matters worse, we use jam, which automagically figures out where the include files are.  You can use relative or absolute paths for your include files. i.e.</p>\n<pre><code>#include &quot;../../MyProgDir/SourceDir1/someFile.hpp&quot;\n</code></pre>\n<p>Older versions of MSVS required double backslashes (\\\\), but now that\'s not required. I don\'t know when it changed. Just use forward slashes for compatibility with \'nix (Windows will accept that).</p>\n<p>If you are <em>really</em> worried about it, use <code>&quot;./myHeader.h&quot;</code> for an include file in the same directory as the source code (my current, very large project has some duplicate include file names scattered about--really a configuration management problem).</p>\n<p>Here\'s the <a href="http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx" rel="noreferrer">MSDN explanation</a> copied here for your convenience).</p>\n<blockquote>\n<p><strong>Quoted form</strong></p>\n<p>The preprocessor searches for include files in this order:</p>\n<ol>\n<li>In the same directory as the file that contains the #include statement.</li>\n<li>In the directories of the currently opened include files, in the reverse order in which<br />\nthey were opened. The search begins in the directory of the parent include file and<br />\ncontinues upward through the directories of any grandparent include files.</li>\n<li>Along the path that\'s specified by each <code>/I</code> compiler option.</li>\n<li>Along the paths that are specified by the <code>INCLUDE</code> environment variable.</li>\n</ol>\n<p><strong>Angle-bracket form</strong></p>\n<p>The preprocessor searches for include files in this order:</p>\n<ol>\n<li>Along the path that\'s specified by each <code>/I</code> compiler option.</li>\n<li>When compiling occurs on the command line, along the paths that are specified by the <code>INCLUDE</code> environment variable.</li>\n</ol>\n</blockquote>\n'}, {'answer_id': 29418258, 'author': 'Hafiz Shehbaz Ali', 'author_id': 2189932, 'author_profile': 'https://Stackoverflow.com/users/2189932', 'pm_score': 3, 'selected': False, 'text': '<code>#include &lt;filename&gt;</code>\n<p>is used when you want to use the header file of the C/C++ system or compiler libraries. These libraries can be stdio.h, string.h, math.h, etc.</p>\n<code>#include &quot;path-to-file/filename&quot;</code>\n<p>is used when you want to use your own custom header file which is in your project folder or somewhere else.</p>\n<p>For more information about preprocessors and header. Read <em><a href="http://www.tutorialspoint.com/cprogramming/c_preprocessors.htm" rel="noreferrer">C - Preprocessors</a></em>.</p>\n'}, {'answer_id': 32064944, 'author': 'skyking', 'author_id': 4498329, 'author_profile': 'https://Stackoverflow.com/users/4498329', 'pm_score': 5, 'selected': False, 'text': '<p>By the standard - yes, they are different:</p>\n\n<blockquote>\n  <ul>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include &lt;h-char-sequence&gt; new-line\n</code></pre>\n  \n  <p>searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the <code>&lt;</code> and <code>&gt;</code> 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.</p></li>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include "q-char-sequence" new-line\n</code></pre>\n  \n  <p>causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the <code>"</code> 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</p>\n\n<pre><code>#include &lt;h-char-sequence&gt; new-line\n</code></pre>\n  \n  <p>with the identical contained sequence (including <code>&gt;</code> characters, if any) from the original\n  directive.</p></li>\n  <li><p>A preprocessing directive of the form</p>\n\n<pre><code>#include pp-tokens new-line\n</code></pre>\n  \n  <p>(that does not match one of the two previous forms) is permitted. The preprocessing tokens after <code>include</code> in the directive are processed just as in normal text. (Each identifier currently defined as a macro name is replaced by its replacement list of preprocessing tokens.) The directive resulting after all replacements shall match one of the two previous forms. The method by which a sequence of preprocessing tokens between a <code>&lt;</code> and a <code>&gt;</code> preprocessing token pair or a pair of <code>"</code> characters is combined into a single header name preprocessing token is implementation-defined.</p></li>\n  </ul>\n  \n  <h3>Definitions:</h3>\n  \n  <ul>\n  <li><p>h-char: any member of the source character set except the new-line character and <code>&gt;</code></p></li>\n  <li><p>q-char: any member of the source character set except the new-line character and <code>"</code></p></li>\n  </ul>\n</blockquote>\n\n<p>Note that the standard does not tell any relation between the implementation-defined manners. The first form searches in one implementation-defined way, and the other in a (possibly other) implementation-defined way. The standard also specifies that certain include files shall be present (for example, <code>&lt;stdio.h&gt;</code>).</p>\n\n<p>Formally you\'d have to read the manual for your compiler, however normally (by tradition) the <code>#include "..."</code> form searches the directory of the file in which the <code>#include</code> was found first, and then the directories that the <code>#include &lt;...&gt;</code> form searches (the include path, eg system headers).</p>\n'}, {'answer_id': 35452132, 'author': 'virat', 'author_id': 5938959, 'author_profile': 'https://Stackoverflow.com/users/5938959', 'pm_score': 3, 'selected': False, 'text': '<p>In C++, include a file in two ways:</p>\n\n<p>The first one is #include  which tells the preprocessor to look for the file in the predefined default location.\nThis location is often an INCLUDE environment variable that denotes the path to include files.</p>\n\n<p>And the second type is #include "filename" which tells the preprocessor to look for the file in the current directory first, then look for it in the predefined locations user have set up.</p>\n'}, {'answer_id': 41646905, 'author': 'Suraj Jain', 'author_id': 5473170, 'author_profile': 'https://Stackoverflow.com/users/5473170', 'pm_score': 6, 'selected': False, 'text': '<p><a href="https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html" rel="noreferrer">GCC documentation says</a> the following about the difference between the two:</p>\n\n<blockquote>\n  <p>Both user and system header files are included using the preprocessing     directive <strong><code>‘#include’</code></strong>. It has two variants:</p>\n  \n  <blockquote>\n    <p><strong><code>#include &lt;file&gt;</code></strong></p>\n    \n    <p>This variant is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the <code>-I</code> option (see <a href="https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation" rel="noreferrer">Invocation</a>).</p>\n    \n    <p><strong><code>#include "file"</code></strong></p>\n    \n    <p>This variant is used for header files of your own program. It searches for a file named file first in the directory containing the current file, then in the quote directories and then the same directories used for <code>&lt;file&gt;</code>. You can prepend directories to the list of quote directories with the <code>-iquote</code> option.\n    The argument of <code>‘#include’</code>, whether delimited with quote marks or angle brackets, behaves like a string constant in that comments are not recognized, and macro names are not expanded. Thus, <code>#include &lt;x/*y&gt;</code> specifies inclusion of a system header file named <code>x/*y</code>.</p>\n    \n    <p>However, if backslashes occur within file, they are considered ordinary text characters, not escape characters. None of the character escape sequences appropriate to string constants in C are processed. Thus,<code>#include "x\\n\\\\y"</code>specifies a filename containing three backslashes. (Some systems interpret ‘\\’ as a pathname separator. All of these also interpret <code>‘/’</code> the same way. It is most portable to use only <code>‘/’</code>.)</p>\n    \n    <p>It is an error if there is anything (other than comments) on the line after the file name.</p>\n  </blockquote>\n</blockquote>\n'}, {'answer_id': 41807677, 'author': 'Christy Wald', 'author_id': 7109320, 'author_profile': 'https://Stackoverflow.com/users/7109320', 'pm_score': 3, 'selected': False, 'text': '<pre><code>#include &lt;abc.h&gt;\n</code></pre>\n\n<p>is used to include standard library files. So the compiler will check in the locations where standard library headers are residing.</p>\n\n<pre><code>#include "xyz.h"\n</code></pre>\n\n<p>will tell the compiler to include user-defined header files. So the compiler will check for these header files in the current folder or <code>-I</code> defined folders.</p>\n'}, {'answer_id': 49226070, 'author': 'adrian', 'author_id': 5487769, 'author_profile': 'https://Stackoverflow.com/users/5487769', 'pm_score': 6, 'selected': False, 'text': '<p>The exact behavior of the preprocessor varies between compilers. The following answer applies for GCC and several other compilers.</p>\n<p><code>#include &lt;file.h&gt;</code> tells the compiler to search for the header in its &quot;includes&quot; directory, e.g. for MinGW the compiler would search for <code>file.h</code> in C:\\MinGW\\include\\ or wherever your compiler is installed.</p>\n<p><code>#include &quot;file&quot;</code> tells the compiler to search the current directory (i.e. the directory in which the source file resides) for <code>file</code>.</p>\n<p>You can use the <code>-I</code> flag for GCC to tell it that, when it encounters an include with angled brackets, it should also search for headers in the directory after <code>-I</code>. GCC will treat the directory after the flag as if it were the <code>includes</code> directory.</p>\n<p>For instance, if you have a file called <code>myheader.h</code> in your own directory, you could say <code>#include &lt;myheader.h&gt;</code> if you called GCC with the flag <code>-I .</code> (indicating that it should search for includes in the current directory.)</p>\n<p>Without the <code>-I</code> flag, you will have to use <code>#include &quot;myheader.h&quot;</code> to include the file, or move <code>myheader.h</code> to the <code>include</code> directory of your compiler.</p>\n'}, {'answer_id': 49533474, 'author': 'Jigar Karangiya', 'author_id': 9563528, 'author_profile': 'https://Stackoverflow.com/users/9563528', 'pm_score': 3, 'selected': False, 'text': '<blockquote>\n  <p>the " &lt; filename > " searches in standard C library locations</p>\n  \n  <p>whereas "filename" searches in the current directory as well.</p>\n</blockquote>\n\n<p>Ideally, you would use &lt;...> for standard C libraries and "..." for libraries that you write and are present in the current directory.</p>\n'}, {'answer_id': 49789599, 'author': 'Chayim Friedman', 'author_id': 7884305, 'author_profile': 'https://Stackoverflow.com/users/7884305', 'pm_score': 4, 'selected': False, 'text': "<p>When you use <code>#include &lt;filename&gt;</code>, the pre-processor looking for the file in directory of C\\C++ header files (stdio.h\\cstdio, string, vector, etc.). But, when you use <code>#include &quot;filename&quot;</code> first, the pre-processor is looking for the file in the current directory, and if it doesn't here - the pre-processor will look for it in the directory of C\\C++ header files.</p>\n"}, {'answer_id': 51892905, 'author': 'Darshan L', 'author_id': 5347487, 'author_profile': 'https://Stackoverflow.com/users/5347487', 'pm_score': 3, 'selected': False, 'text': '<h2>Form 1 - #include &lt; xxx &gt;</h2>\n<p>First, looks for the presence of header file in the current directory from where directive is invoked. If not found, then it searches in the preconfigured list of standard system directories.</p>\n<h2>Form 2 - #include &quot;xxx&quot;</h2>\n<p>This looks for the presence of header file in the current directory from where directive is invoked.</p>\n<hr />\n<p>The exact search directory list depends on the target system, how GCC is configured, and where it is installed.\nYou can find the search directory list of your GCC compiler by running it with -v option.</p>\n<p>You can add additional directories to the search path by using - I<em>dir</em>, which causes dir to be searched after the current directory (for the quote form of the directive) and ahead of the standard system directories.</p>\n<hr />\n<p>Basically, the form &quot;xxx&quot; is nothing but search in current directory; if not found falling back the form </p>\n'}, {'answer_id': 51907153, 'author': 'LocalHost', 'author_id': 9121710, 'author_profile': 'https://Stackoverflow.com/users/9121710', 'pm_score': -1, 'selected': False, 'text': '<p>There exists two ways to write #include statement.These are:</p>\n\n<pre><code>#include"filename"\n#include&lt;filename&gt;\n</code></pre>\n\n<p>The meaning of each form is </p>\n\n<pre><code>#include"mylib.h"\n</code></pre>\n\n<p>This command would look for the file <code>mylib.h</code> in the current directory as well as the specified list of directories as mentioned n the include search path that might have been set up.</p>\n\n<pre><code>#include&lt;mylib.h&gt;\n</code></pre>\n\n<p>This command would look for the file <code>mylib.h</code> in the specified list of directories only.</p>\n\n<p>The include search path is nothing but a list of directories that would be searched for the file being included.Different C compilers let you set the search path in different manners.</p>\n'}, {'answer_id': 52633884, 'author': 'Hogstrom', 'author_id': 6943197, 'author_profile': 'https://Stackoverflow.com/users/6943197', 'pm_score': 2, 'selected': False, 'text': '<p>To see the search order on your system using gcc, based on current configuration , you can execute the following command.  You can find more detail on this command <a href="https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html" rel="nofollow noreferrer">here</a></p>\n\n<p><code>cpp -v /dev/null -o /dev/null</code></p>\n\n<blockquote>\n  <p>Apple LLVM version 10.0.0 (clang-1000.10.44.2) <br>\n  Target: x86_64-apple-darwin18.0.0 <br>\n  Thread model: posix InstalledDir: Library/Developer/CommandLineTools/usr/bin<br>\n  "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple\n  x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage\n  -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name null -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 409.12 -v -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/10.0.0 -isysroot\n  /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk\n  -I/usr/local/include -fdebug-compilation-dir /Users/hogstrom -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -traditional-cpp -o - -x c /dev/null <br/>\n  clang -cc1 version 10.0.0 (clang-1000.10.44.2) default target x86_64-apple-darwin18.0.0 ignoring\n  nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/local/include"\n  ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/Library/Frameworks"<br>\n  <strong>#include "..." search starts here:</strong><br>\n  <strong>#include &lt;...> search starts here:</strong><br>\n  <strong>/usr/local/include</strong>  <br>\n  <strong>/Library/Developer/CommandLineTools/usr/lib/clang/10.0.0/include</strong> <br>\n  <strong>/Library/Developer/CommandLineTools/usr/include</strong> <br> \n  <strong>/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include</strong> <br>\n  <strong>/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks</strong> (framework directory)<br>\n   End of search list.</p>\n</blockquote>\n'}, {'answer_id': 59496298, 'author': 'Kalana', 'author_id': 11383441, 'author_profile': 'https://Stackoverflow.com/users/11383441', 'pm_score': 3, 'selected': False, 'text': '<p><strong><code>#include &lt;filename&gt;</code></strong>  </p>\n\n<ul>\n<li>The preprocessor searches in an implementation-dependent manner. It tells the compiler to search directory where system header files are held. </li>\n<li>This method usually use to find standard header files.</li>\n</ul>\n\n<p><strong><code>#include "filename"</code></strong></p>\n\n<ul>\n<li>This tell compiler to search header files where program is running. If it was failed it behave like <code>#include &lt;filename&gt;</code> and search that header file at where system header files stored.</li>\n<li>This method usually used for identify user defined header files(header files which are created by user). There for don\'t use this if you want to call standard library because it takes more compiling time than <code>#include &lt;filename&gt;</code>.</li>\n</ul>\n'}, {'answer_id': 60480645, 'author': 'IAmAUser', 'author_id': 12739607, 'author_profile': 'https://Stackoverflow.com/users/12739607', 'pm_score': 2, 'selected': False, 'text': '<pre class="lang-c prettyprint-override"><code>#include &lt;file&gt; \n</code></pre>\n<p>Includes a file where the default include directory is.</p>\n<pre class="lang-c prettyprint-override"><code>#include &quot;file&quot; \n</code></pre>\n<p>Includes a file in the current directory in which it was compiled. Double quotes can specify a full file path to a different location as well.</p>\n'}, {'answer_id': 64982454, 'author': 'Saptarshi das', 'author_id': 10326781, 'author_profile': 'https://Stackoverflow.com/users/10326781', 'pm_score': 2, 'selected': False, 'text': '<p><strong>In general the difference is where the preprocessor searches for the header file:</strong></p>\n<p><strong>#include is a preprocessor directive to include header file. Both #include are used to add or include header file in the program, but first is to include system header files and later one for user defined header files.</strong></p>\n<ol>\n<li><strong>#include &lt;filename&gt;</strong> is used to include the system library header file in the program, means the C/C++ preprocessor will search for the filename where the C library files are stored or predefined system header files are stored.</li>\n<li><strong>#include &quot;filename&quot;</strong> is used to include user defined header file in the program, means the C/C++ preprocessor will search for the filename in the current directory the program is in and then follows the search path used for the #include &lt;filename&gt;</li>\n</ol>\n<p>Check the gcc docs <a href="https://gcc.gnu.org/onlinedocs/gcc-3.2.1/gcc/Include-Files-and-VMS.html" rel="nofollow noreferrer">gcc include files</a></p>\n'}, {'answer_id': 66401239, 'author': 'Paul Yang', 'author_id': 15039201, 'author_profile': 'https://Stackoverflow.com/users/15039201', 'pm_score': 2, 'selected': False, 'text': '<p><code>&quot;&quot;</code> will search <code>./</code> first. Then search the default include path.\nYou can use command like this to print the default include path:</p>\n<pre><code>gcc -v -o a a.c\n</code></pre>\n<p>Here are some examples to make thing more clear:\nthe code a.c works</p>\n<pre class="lang-c prettyprint-override"><code>// a.c\n#include &quot;stdio.h&quot;\nint main() {\n        int a = 3;\n        printf(&quot;a = %d\\n&quot;, a);\n        return 0;\n\n}\n</code></pre>\n<p>the code of b.c works too</p>\n<pre class="lang-c prettyprint-override"><code>// b.c\n#include &lt;stdio.h&gt;\nint main() {\n        int a = 3;\n        printf(&quot;a = %d\\n&quot;, a);\n        return 0;\n\n}\n</code></pre>\n<p>but when I create a new file named <code>stdio.h</code> in current directory</p>\n<pre class="lang-c prettyprint-override"><code>// stdio.h\ninline int foo()\n{\n        return 10;\n}\n</code></pre>\n<p><code>a.c</code> will generate compile error, but <code>b.c</code> still works</p>\n<p>and &quot;&quot;, &lt;&gt; can be used together with the same file name. since the search path priority is different.\nso <code>d.c</code> also works</p>\n<pre class="lang-c prettyprint-override"><code>// d.c\n#include &lt;stdio.h&gt;\n#include &quot;stdio.h&quot;\nint main()\n{\n        int a = 0;\n\n        a = foo();\n\n        printf(&quot;a=%d\\n&quot;, a);\n\n        return 0;\n}\n</code></pre>\n'}, {'answer_id': 68311198, 'author': 'david', 'author_id': 1335492, 'author_profile': 'https://Stackoverflow.com/users/1335492', 'pm_score': 0, 'selected': False, 'text': '<p>The implementation-defined warnings generated by the compiler can (and will) treat system libraries differently than program libraries.</p>\n<p>So</p>\n<p><code>#include &lt;myFilename&gt;</code></p>\n<p>-- which in effect declares that myFilename is in the system library location -- may well (and probably will) hide dead code and unused variable warnings etc, that would show up when you use:</p>\n<p><code>#include &quot;myFilename&quot;</code></p>\n'}]
['https://Stackoverflow.com/questions/21593', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2399/']