• 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>Standard Predefined Macros - 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="Predefined-Macros.html#Predefined-Macros" title="Predefined Macros">
9<link rel="next" href="Common-Predefined-Macros.html#Common-Predefined-Macros" title="Common Predefined Macros">
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="Standard-Predefined-Macros"></a>
53<p>
54Next:&nbsp;<a rel="next" accesskey="n" href="Common-Predefined-Macros.html#Common-Predefined-Macros">Common Predefined Macros</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="Predefined-Macros.html#Predefined-Macros">Predefined Macros</a>
56<hr>
57</div>
58
59<h4 class="subsection">3.7.1 Standard Predefined Macros</h4>
60
61<p><a name="index-standard-predefined-macros_002e-60"></a>
62The standard predefined macros are specified by the relevant
63language standards, so they are available with all compilers that
64implement those standards.  Older compilers may not provide all of
65them.  Their names all start with double underscores.
66
67     <dl>
68<dt><code>__FILE__</code><dd>This macro expands to the name of the current input file, in the form of
69a C string constant.  This is the path by which the preprocessor opened
70the file, not the short name specified in &lsquo;<samp><span class="samp">#include</span></samp>&rsquo; or as the
71input file name argument.  For example,
72<code>"/usr/local/include/myheader.h"</code> is a possible expansion of this
73macro.
74
75     <br><dt><code>__LINE__</code><dd>This macro expands to the current input line number, in the form of a
76decimal integer constant.  While we call it a predefined macro, it's
77a pretty strange macro, since its &ldquo;definition&rdquo; changes with each
78new line of source code. 
79</dl>
80
81   <p><code>__FILE__</code> and <code>__LINE__</code> are useful in generating an error
82message to report an inconsistency detected by the program; the message
83can state the source line at which the inconsistency was detected.  For
84example,
85
86<pre class="smallexample">     fprintf (stderr, "Internal error: "
87                      "negative string length "
88                      "%d at %s, line %d.",
89              length, __FILE__, __LINE__);
90</pre>
91   <p>An &lsquo;<samp><span class="samp">#include</span></samp>&rsquo; directive changes the expansions of <code>__FILE__</code>
92and <code>__LINE__</code> to correspond to the included file.  At the end of
93that file, when processing resumes on the input file that contained
94the &lsquo;<samp><span class="samp">#include</span></samp>&rsquo; directive, the expansions of <code>__FILE__</code> and
95<code>__LINE__</code> revert to the values they had before the
96&lsquo;<samp><span class="samp">#include</span></samp>&rsquo; (but <code>__LINE__</code> is then incremented by one as
97processing moves to the line after the &lsquo;<samp><span class="samp">#include</span></samp>&rsquo;).
98
99   <p>A &lsquo;<samp><span class="samp">#line</span></samp>&rsquo; directive changes <code>__LINE__</code>, and may change
100<code>__FILE__</code> as well.  See <a href="Line-Control.html#Line-Control">Line Control</a>.
101
102   <p>C99 introduces <code>__func__</code>, and GCC has provided <code>__FUNCTION__</code>
103for a long time.  Both of these are strings containing the name of the
104current function (there are slight semantic differences; see the GCC
105manual).  Neither of them is a macro; the preprocessor does not know the
106name of the current function.  They tend to be useful in conjunction
107with <code>__FILE__</code> and <code>__LINE__</code>, though.
108
109     <dl>
110<dt><code>__DATE__</code><dd>This macro expands to a string constant that describes the date on which
111the preprocessor is being run.  The string constant contains eleven
112characters and looks like <code>"Feb&nbsp;12&nbsp;1996"<!-- /@w --></code>.  If the day of the
113month is less than 10, it is padded with a space on the left.
114
115     <p>If GCC cannot determine the current date, it will emit a warning message
116(once per compilation) and <code>__DATE__</code> will expand to
117<code>"???&nbsp;??&nbsp;????"<!-- /@w --></code>.
118
119     <br><dt><code>__TIME__</code><dd>This macro expands to a string constant that describes the time at
120which the preprocessor is being run.  The string constant contains
121eight characters and looks like <code>"23:59:01"</code>.
122
123     <p>If GCC cannot determine the current time, it will emit a warning message
124(once per compilation) and <code>__TIME__</code> will expand to
125<code>"??:??:??"</code>.
126
127     <br><dt><code>__STDC__</code><dd>In normal operation, this macro expands to the constant 1, to signify
128that this compiler conforms to ISO Standard C.  If GNU CPP is used with
129a compiler other than GCC, this is not necessarily true; however, the
130preprocessor always conforms to the standard unless the
131<samp><span class="option">-traditional-cpp</span></samp> option is used.
132
133     <p>This macro is not defined if the <samp><span class="option">-traditional-cpp</span></samp> option is used.
134
135     <p>On some hosts, the system compiler uses a different convention, where
136<code>__STDC__</code> is normally 0, but is 1 if the user specifies strict
137conformance to the C Standard.  CPP follows the host convention when
138processing system header files, but when processing user files
139<code>__STDC__</code> is always 1.  This has been reported to cause problems;
140for instance, some versions of Solaris provide X Windows headers that
141expect <code>__STDC__</code> to be either undefined or 1.  See <a href="Invocation.html#Invocation">Invocation</a>.
142
143     <br><dt><code>__STDC_VERSION__</code><dd>This macro expands to the C Standard's version number, a long integer
144constant of the form <var>yyyy</var><var>mm</var><code>L</code> where <var>yyyy</var> and
145<var>mm</var> are the year and month of the Standard version.  This signifies
146which version of the C Standard the compiler conforms to.  Like
147<code>__STDC__</code>, this is not necessarily accurate for the entire
148implementation, unless GNU CPP is being used with GCC.
149
150     <p>The value <code>199409L</code> signifies the 1989 C standard as amended in
1511994, which is the current default; the value <code>199901L</code> signifies
152the 1999 revision of the C standard.  Support for the 1999 revision is
153not yet complete.
154
155     <p>This macro is not defined if the <samp><span class="option">-traditional-cpp</span></samp> option is
156used, nor when compiling C++ or Objective-C.
157
158     <br><dt><code>__STDC_HOSTED__</code><dd>This macro is defined, with value 1, if the compiler's target is a
159<dfn>hosted environment</dfn>.  A hosted environment has the complete
160facilities of the standard C library available.
161
162     <br><dt><code>__cplusplus</code><dd>This macro is defined when the C++ compiler is in use.  You can use
163<code>__cplusplus</code> to test whether a header is compiled by a C compiler
164or a C++ compiler.  This macro is similar to <code>__STDC_VERSION__</code>, in
165that it expands to a version number.  A fully conforming implementation
166of the 1998 C++ standard will define this macro to <code>199711L</code>.  The
167GNU C++ compiler is not yet fully conforming, so it uses <code>1</code>
168instead.  It is hoped to complete the implementation of standard C++
169in the near future.
170
171     <br><dt><code>__OBJC__</code><dd>This macro is defined, with value 1, when the Objective-C compiler is in
172use.  You can use <code>__OBJC__</code> to test whether a header is compiled
173by a C compiler or an Objective-C compiler.
174
175     <br><dt><code>__ASSEMBLER__</code><dd>This macro is defined with value 1 when preprocessing assembly
176language.
177
178   </dl>
179
180   </body></html>
181
182