• 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>Elif - 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="Conditional-Syntax.html#Conditional-Syntax" title="Conditional Syntax">
9<link rel="prev" href="Else.html#Else" title="Else">
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="Elif"></a>
53<p>
54Previous:&nbsp;<a rel="previous" accesskey="p" href="Else.html#Else">Else</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="Conditional-Syntax.html#Conditional-Syntax">Conditional Syntax</a>
56<hr>
57</div>
58
59<h4 class="subsection">4.2.5 Elif</h4>
60
61<p><a name="index-g_t_0023elif-91"></a>One common case of nested conditionals is used to check for more than two
62possible alternatives.  For example, you might have
63
64<pre class="smallexample">     #if X == 1
65     ...
66     #else /* X != 1 */
67     #if X == 2
68     ...
69     #else /* X != 2 */
70     ...
71     #endif /* X != 2 */
72     #endif /* X != 1 */
73</pre>
74   <p>Another conditional directive, &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo;, allows this to be
75abbreviated as follows:
76
77<pre class="smallexample">     #if X == 1
78     ...
79     #elif X == 2
80     ...
81     #else /* X != 2 and X != 1*/
82     ...
83     #endif /* X != 2 and X != 1*/
84</pre>
85   <p>&lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; stands for &ldquo;else if&rdquo;.  Like &lsquo;<samp><span class="samp">#else</span></samp>&rsquo;, it goes in the
86middle of a conditional group and subdivides it; it does not require a
87matching &lsquo;<samp><span class="samp">#endif</span></samp>&rsquo; of its own.  Like &lsquo;<samp><span class="samp">#if</span></samp>&rsquo;, the &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo;
88directive includes an expression to be tested.  The text following the
89&lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; is processed only if the original &lsquo;<samp><span class="samp">#if</span></samp>&rsquo;-condition
90failed and the &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; condition succeeds.
91
92   <p>More than one &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; can go in the same conditional group.  Then
93the text after each &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; is processed only if the &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo;
94condition succeeds after the original &lsquo;<samp><span class="samp">#if</span></samp>&rsquo; and all previous
95&lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; directives within it have failed.
96
97   <p>&lsquo;<samp><span class="samp">#else</span></samp>&rsquo; is allowed after any number of &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; directives, but
98&lsquo;<samp><span class="samp">#elif</span></samp>&rsquo; may not follow &lsquo;<samp><span class="samp">#else</span></samp>&rsquo;.
99
100   </body></html>
101
102