• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/cpp/
1<html lang="en">
2<head>
3<title>The preprocessing language - 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="Overview.html#Overview" title="Overview">
9<link rel="prev" href="Tokenization.html#Tokenization" title="Tokenization">
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="The-preprocessing-language"></a>
53<p>
54Previous:&nbsp;<a rel="previous" accesskey="p" href="Tokenization.html#Tokenization">Tokenization</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="Overview.html#Overview">Overview</a>
56<hr>
57</div>
58
59<h3 class="section">1.4 The preprocessing language</h3>
60
61<p><a name="index-directives-21"></a><a name="index-preprocessing-directives-22"></a><a name="index-directive-line-23"></a><a name="index-directive-name-24"></a>
62After tokenization, the stream of tokens may simply be passed straight
63to the compiler's parser.  However, if it contains any operations in the
64<dfn>preprocessing language</dfn>, it will be transformed first.  This stage
65corresponds roughly to the standard's &ldquo;translation phase 4&rdquo; and is
66what most people think of as the preprocessor's job.
67
68   <p>The preprocessing language consists of <dfn>directives</dfn> to be executed
69and <dfn>macros</dfn> to be expanded.  Its primary capabilities are:
70
71     <ul>
72<li>Inclusion of header files.  These are files of declarations that can be
73substituted into your program.
74
75     <li>Macro expansion.  You can define <dfn>macros</dfn>, which are abbreviations
76for arbitrary fragments of C code.  The preprocessor will replace the
77macros with their definitions throughout the program.  Some macros are
78automatically defined for you.
79
80     <li>Conditional compilation.  You can include or exclude parts of the
81program according to various conditions.
82
83     <li>Line control.  If you use a program to combine or rearrange source files
84into an intermediate file which is then compiled, you can use line
85control to inform the compiler where each source line originally came
86from.
87
88     <li>Diagnostics.  You can detect problems at compile time and issue errors
89or warnings. 
90</ul>
91
92   <p>There are a few more, less useful, features.
93
94   <p>Except for expansion of predefined macros, all these operations are
95triggered with <dfn>preprocessing directives</dfn>.  Preprocessing directives
96are lines in your program that start with &lsquo;<samp><span class="samp">#</span></samp>&rsquo;.  Whitespace is
97allowed before and after the &lsquo;<samp><span class="samp">#</span></samp>&rsquo;.  The &lsquo;<samp><span class="samp">#</span></samp>&rsquo; is followed by an
98identifier, the <dfn>directive name</dfn>.  It specifies the operation to
99perform.  Directives are commonly referred to as &lsquo;<samp><span class="samp">#</span><var>name</var></samp>&rsquo;
100where <var>name</var> is the directive name.  For example, &lsquo;<samp><span class="samp">#define</span></samp>&rsquo; is
101the directive that defines a macro.
102
103   <p>The &lsquo;<samp><span class="samp">#</span></samp>&rsquo; which begins a directive cannot come from a macro
104expansion.  Also, the directive name is not macro expanded.  Thus, if
105<code>foo</code> is defined as a macro expanding to <code>define</code>, that does
106not make &lsquo;<samp><span class="samp">#foo</span></samp>&rsquo; a valid preprocessing directive.
107
108   <p>The set of valid directive names is fixed.  Programs cannot define new
109preprocessing directives.
110
111   <p>Some directives require arguments; these make up the rest of the
112directive line and must be separated from the directive name by
113whitespace.  For example, &lsquo;<samp><span class="samp">#define</span></samp>&rsquo; must be followed by a macro
114name and the intended expansion of the macro.
115
116   <p>A preprocessing directive cannot cover more than one line.  The line
117may, however, be continued with backslash-newline, or by a block comment
118which extends past the end of the line.  In either case, when the
119directive is processed, the continuations have already been merged with
120the first line to make one long line.
121
122   </body></html>
123
124