1<html lang="en"> 2<head> 3<title>Include Syntax - The C Preprocessor</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="The C Preprocessor"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Header-Files.html#Header-Files" title="Header Files"> 9<link rel="next" href="Include-Operation.html#Include-Operation" title="Include Operation"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12Copyright (C) 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 131997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 142008, 2009, 2010, 2011 15Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation. A copy of 20the license is included in the 21section entitled ``GNU Free Documentation License''. 22 23This manual contains no Invariant Sections. The Front-Cover Texts are 24(a) (see below), and the Back-Cover Texts are (b) (see below). 25 26(a) The FSF's Front-Cover Text is: 27 28 A GNU Manual 29 30(b) The FSF's Back-Cover Text is: 31 32 You have freedom to copy and modify this GNU Manual, like GNU 33 software. Copies published by the Free Software Foundation raise 34 funds for GNU development. 35--> 36<meta http-equiv="Content-Style-Type" content="text/css"> 37<style type="text/css"><!-- 38 pre.display { font-family:inherit } 39 pre.format { font-family:inherit } 40 pre.smalldisplay { font-family:inherit; font-size:smaller } 41 pre.smallformat { font-family:inherit; font-size:smaller } 42 pre.smallexample { font-size:smaller } 43 pre.smalllisp { font-size:smaller } 44 span.sc { font-variant:small-caps } 45 span.roman { font-family:serif; font-weight:normal; } 46 span.sansserif { font-family:sans-serif; font-weight:normal; } 47--></style> 48<link rel="stylesheet" type="text/css" href="../cs.css"> 49</head> 50<body> 51<div class="node"> 52<a name="Include-Syntax"></a> 53<p> 54Next: <a rel="next" accesskey="n" href="Include-Operation.html#Include-Operation">Include Operation</a>, 55Up: <a rel="up" accesskey="u" href="Header-Files.html#Header-Files">Header Files</a> 56<hr> 57</div> 58 59<h3 class="section">2.1 Include Syntax</h3> 60 61<p><a name="index-g_t_0023include-27"></a>Both user and system header files are included using the preprocessing 62directive ‘<samp><span class="samp">#include</span></samp>’. It has two variants: 63 64 <dl> 65<dt><code>#include <</code><var>file</var><code>></code><dd>This variant is used for system header files. It searches for a file 66named <var>file</var> in a standard list of system directories. You can prepend 67directories to this list with the <samp><span class="option">-I</span></samp> option (see <a href="Invocation.html#Invocation">Invocation</a>). 68 69 <br><dt><code>#include "</code><var>file</var><code>"</code><dd>This variant is used for header files of your own program. It 70searches for a file named <var>file</var> first in the directory containing 71the current file, then in the quote directories and then the same 72directories used for <code><</code><var>file</var><code>></code>. You can prepend directories 73to the list of quote directories with the <samp><span class="option">-iquote</span></samp> option. 74</dl> 75 76 <p>The argument of ‘<samp><span class="samp">#include</span></samp>’, whether delimited with quote marks or 77angle brackets, behaves like a string constant in that comments are not 78recognized, and macro names are not expanded. Thus, <code>#include <x/*y><!-- /@w --></code> specifies inclusion of a system header file named <samp><span class="file">x/*y</span></samp>. 79 80 <p>However, if backslashes occur within <var>file</var>, they are considered 81ordinary text characters, not escape characters. None of the character 82escape sequences appropriate to string constants in C are processed. 83Thus, <code>#include "x\n\\y"<!-- /@w --></code> specifies a filename containing three 84backslashes. (Some systems interpret ‘<samp><span class="samp">\</span></samp>’ as a pathname separator. 85All of these also interpret ‘<samp><span class="samp">/</span></samp>’ the same way. It is most portable 86to use only ‘<samp><span class="samp">/</span></samp>’.) 87 88 <p>It is an error if there is anything (other than comments) on the line 89after the file name. 90 91 </body></html> 92 93