]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/cpp/header-files/include-syntax.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / cpp / header-files / include-syntax.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. index:: #include
7
8.. _include-syntax:
9
10Include Syntax
11**************
12
13Both user and system header files are included using the preprocessing
14directive :samp:`#include`. It has two variants:
15
16:samp:`#include <{file}>`
17 This variant is used for system header files. It searches for a file
18 named :samp:`{file}` in a standard list of system directories. You can prepend
19 directories to this list with the :option:`-I` option (see :ref:`invocation`).
20
21:samp:`#include "{file}"`
22 This variant is used for header files of your own program. It
23 searches for a file named :samp:`{file}` first in the directory containing
24 the current file, then in the quote directories and then the same
25 directories used for ``<file>``. You can prepend directories
26 to the list of quote directories with the :option:`-iquote` option.
27
28The argument of :samp:`#include`, whether delimited with quote marks or
29angle brackets, behaves like a string constant in that comments are not
30recognized, and macro names are not expanded. Thus, ``#include
31<x/*y>`` specifies inclusion of a system header file named :samp:`x/*y`.
32
33However, if backslashes occur within :samp:`{file}`, they are considered
34ordinary text characters, not escape characters. None of the character
35escape sequences appropriate to string constants in C are processed.
36Thus, ``#include "x\n\\y"`` specifies a filename containing three
37backslashes. (Some systems interpret :samp:`\\` as a pathname separator.
38All of these also interpret :samp:`/` the same way. It is most portable
39to use only :samp:`/`.)
40
41It is an error if there is anything (other than comments) on the line
3ed1b4ce 42after the file name.