1 <html><head><title>C</title></head><body>
2 <pre><!--page 1 indent 0-->
3 N1548 Committee Draft -- December 2, 2010 ISO/IEC 9899:201x
8 INTERNATIONAL STANDARD (C)ISO/IEC ISO/IEC 9899:201x
15 <h1>Programming languages -- C</h1>
23 (Cover sheet to be provided by ISO Secretariat.)
25 This International Standard specifies the form and establishes the interpretation of
26 programs expressed in the programming language C. Its purpose is to promote
27 portability, reliability, maintainability, and efficient execution of C language programs on
28 a variety of computing systems.
30 Clauses are included that detail the C language itself and the contents of the C language
31 execution library. Annexes summarize aspects of both of them, and enumerate factors
32 that influence the portability of C programs.
34 Although this International Standard is intended to guide knowledgeable C language
35 programmers as well as implementors of C language translation systems, the document
36 itself is not designed to serve as a tutorial.
38 Recipients of this draft are invited to submit, with their comments, notification of any
39 relevant patent rights of which they are aware and to provide supporting documentation.
41 Changes from the previous draft (N1256) are indicated by ''diff marks'' in the right
42 margin: deleted text is marked with ''*'', new or changed text with '' ''.
43 <!--page 2 indent 0-->
44 <!--page 3 indent 0-->
47 <a name="Contents" href="#Contents"><h2>Contents</h2></a>
49 Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
50 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
51 1. Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
52 2. Normative references . . . . . . . . . . . . . . . . . . . . . . . 2
53 3. Terms, definitions, and symbols . . . . . . . . . . . . . . . . . . . 3
54 4. Conformance . . . . . . . . . . . . . . . . . . . . . . . . . . 8
55 5. Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 10
56 5.1 Conceptual models . . . . . . . . . . . . . . . . . . . . . 10
57 5.1.1 Translation environment . . . . . . . . . . . . . . . . 10
58 5.1.2 Execution environments . . . . . . . . . . . . . . . . 12
59 5.2 Environmental considerations . . . . . . . . . . . . . . . . . 22
60 5.2.1 Character sets . . . . . . . . . . . . . . . . . . . . 22
61 5.2.2 Character display semantics . . . . . . . . . . . . . . 24
62 5.2.3 Signals and interrupts . . . . . . . . . . . . . . . . . 25
63 5.2.4 Environmental limits . . . . . . . . . . . . . . . . . 25
64 6. Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
65 6.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . 35
66 6.2 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . 35
67 6.2.1 Scopes of identifiers . . . . . . . . . . . . . . . . . 35
68 6.2.2 Linkages of identifiers . . . . . . . . . . . . . . . . . 36
69 6.2.3 Name spaces of identifiers . . . . . . . . . . . . . . . 37
70 6.2.4 Storage durations of objects . . . . . . . . . . . . . . 38
71 6.2.5 Types . . . . . . . . . . . . . . . . . . . . . . . 39
72 6.2.6 Representations of types . . . . . . . . . . . . . . . . 44
73 6.2.7 Compatible type and composite type . . . . . . . . . . . 47
74 6.2.8 Alignment of objects . . . . . . . . . . . . . . . . . 48
75 6.3 Conversions . . . . . . . . . . . . . . . . . . . . . . . . 50
76 6.3.1 Arithmetic operands . . . . . . . . . . . . . . . . . 50
77 6.3.2 Other operands . . . . . . . . . . . . . . . . . . . 54
78 6.4 Lexical elements . . . . . . . . . . . . . . . . . . . . . . 57
79 6.4.1 Keywords . . . . . . . . . . . . . . . . . . . . . . 58
80 6.4.2 Identifiers . . . . . . . . . . . . . . . . . . . . . . 59
81 6.4.3 Universal character names . . . . . . . . . . . . . . . 61
82 6.4.4 Constants . . . . . . . . . . . . . . . . . . . . . . 62
83 6.4.5 String literals . . . . . . . . . . . . . . . . . . . . 70
84 6.4.6 Punctuators . . . . . . . . . . . . . . . . . . . . . 72
85 6.4.7 Header names . . . . . . . . . . . . . . . . . . . . 73
86 6.4.8 Preprocessing numbers . . . . . . . . . . . . . . . . 74
87 6.4.9 Comments . . . . . . . . . . . . . . . . . . . . . 75
88 <!--page 4 indent -1-->
89 6.5 Expressions . . . . . . . . . . . . . . . . . . . . . . . . 76
90 6.5.1 Primary expressions . . . . . . . . . . . . . . . . . 78
91 6.5.2 Postfix operators . . . . . . . . . . . . . . . . . . . 79
92 6.5.3 Unary operators . . . . . . . . . . . . . . . . . . . 88
93 6.5.4 Cast operators . . . . . . . . . . . . . . . . . . . . 91
94 6.5.5 Multiplicative operators . . . . . . . . . . . . . . . . 92
95 6.5.6 Additive operators . . . . . . . . . . . . . . . . . . 92
96 6.5.7 Bitwise shift operators . . . . . . . . . . . . . . . . . 94
97 6.5.8 Relational operators . . . . . . . . . . . . . . . . . . 95
98 6.5.9 Equality operators . . . . . . . . . . . . . . . . . . 96
99 6.5.10 Bitwise AND operator . . . . . . . . . . . . . . . . . 97
100 6.5.11 Bitwise exclusive OR operator . . . . . . . . . . . . . 98
101 6.5.12 Bitwise inclusive OR operator . . . . . . . . . . . . . . 98
102 6.5.13 Logical AND operator . . . . . . . . . . . . . . . . . 99
103 6.5.14 Logical OR operator . . . . . . . . . . . . . . . . . 99
104 6.5.15 Conditional operator . . . . . . . . . . . . . . . . . 100
105 6.5.16 Assignment operators . . . . . . . . . . . . . . . . . 101
106 6.5.17 Comma operator . . . . . . . . . . . . . . . . . . . 104
107 6.6 Constant expressions . . . . . . . . . . . . . . . . . . . . . 105
108 6.7 Declarations . . . . . . . . . . . . . . . . . . . . . . . . 107
109 6.7.1 Storage-class specifiers . . . . . . . . . . . . . . . . 108
110 6.7.2 Type specifiers . . . . . . . . . . . . . . . . . . . . 109
111 6.7.3 Type qualifiers . . . . . . . . . . . . . . . . . . . . 120
112 6.7.4 Function specifiers . . . . . . . . . . . . . . . . . . 124
113 6.7.5 Alignment specifier . . . . . . . . . . . . . . . . . . 126
114 6.7.6 Declarators . . . . . . . . . . . . . . . . . . . . . 127
115 6.7.7 Type names . . . . . . . . . . . . . . . . . . . . . 135
116 6.7.8 Type definitions . . . . . . . . . . . . . . . . . . . 136
117 6.7.9 Initialization . . . . . . . . . . . . . . . . . . . . 138
118 6.7.10 Static assertions . . . . . . . . . . . . . . . . . . . 144
119 6.8 Statements and blocks . . . . . . . . . . . . . . . . . . . . 145
120 6.8.1 Labeled statements . . . . . . . . . . . . . . . . . . 145
121 6.8.2 Compound statement . . . . . . . . . . . . . . . . . 146
122 6.8.3 Expression and null statements . . . . . . . . . . . . . 146
123 6.8.4 Selection statements . . . . . . . . . . . . . . . . . 147
124 6.8.5 Iteration statements . . . . . . . . . . . . . . . . . . 149
125 6.8.6 Jump statements . . . . . . . . . . . . . . . . . . . 150
126 6.9 External definitions . . . . . . . . . . . . . . . . . . . . . 154
127 6.9.1 Function definitions . . . . . . . . . . . . . . . . . . 155
128 6.9.2 External object definitions . . . . . . . . . . . . . . . 157
129 6.10 Preprocessing directives . . . . . . . . . . . . . . . . . . . 159
130 6.10.1 Conditional inclusion . . . . . . . . . . . . . . . . . 161
131 6.10.2 Source file inclusion . . . . . . . . . . . . . . . . . 163
132 6.10.3 Macro replacement . . . . . . . . . . . . . . . . . . 165
133 <!--page 5 indent 0-->
134 6.10.4 Line control . . . . . . . . . . . . . . . . . . . . . 172
135 6.10.5 Error directive . . . . . . . . . . . . . . . . . . . . 173
136 6.10.6 Pragma directive . . . . . . . . . . . . . . . . . . . 173
137 6.10.7 Null directive . . . . . . . . . . . . . . . . . . . . 174
138 6.10.8 Predefined macro names . . . . . . . . . . . . . . . . 174
139 6.10.9 Pragma operator . . . . . . . . . . . . . . . . . . . 176
140 6.11 Future language directions . . . . . . . . . . . . . . . . . . 178
141 6.11.1 Floating types . . . . . . . . . . . . . . . . . . . . 178
142 6.11.2 Linkages of identifiers . . . . . . . . . . . . . . . . . 178
143 6.11.3 External names . . . . . . . . . . . . . . . . . . . 178
144 6.11.4 Character escape sequences . . . . . . . . . . . . . . 178
145 6.11.5 Storage-class specifiers . . . . . . . . . . . . . . . . 178
146 6.11.6 Function declarators . . . . . . . . . . . . . . . . . 178
147 6.11.7 Function definitions . . . . . . . . . . . . . . . . . . 178
148 6.11.8 Pragma directives . . . . . . . . . . . . . . . . . . 178
149 6.11.9 Predefined macro names . . . . . . . . . . . . . . . . 178
150 7. Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
151 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 179
152 7.1.1 Definitions of terms . . . . . . . . . . . . . . . . . . 179
153 7.1.2 Standard headers . . . . . . . . . . . . . . . . . . . 180
154 7.1.3 Reserved identifiers . . . . . . . . . . . . . . . . . . 181
155 7.1.4 Use of library functions . . . . . . . . . . . . . . . . 182
156 7.2 Diagnostics <assert.h> . . . . . . . . . . . . . . . . . . 185
157 7.2.1 Program diagnostics . . . . . . . . . . . . . . . . . 185
158 7.3 Complex arithmetic <complex.h> . . . . . . . . . . . . . . 187
159 7.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . 187
160 7.3.2 Conventions . . . . . . . . . . . . . . . . . . . . . 188
161 7.3.3 Branch cuts . . . . . . . . . . . . . . . . . . . . . 188
162 7.3.4 The CX_LIMITED_RANGE pragma . . . . . . . . . . . 188
163 7.3.5 Trigonometric functions . . . . . . . . . . . . . . . . 189
164 7.3.6 Hyperbolic functions . . . . . . . . . . . . . . . . . 191
165 7.3.7 Exponential and logarithmic functions . . . . . . . . . . 193
166 7.3.8 Power and absolute-value functions . . . . . . . . . . . 194
167 7.3.9 Manipulation functions . . . . . . . . . . . . . . . . 195
168 7.4 Character handling <ctype.h> . . . . . . . . . . . . . . . . 199
169 7.4.1 Character classification functions . . . . . . . . . . . . 199
170 7.4.2 Character case mapping functions . . . . . . . . . . . . 202
171 7.5 Errors <errno.h> . . . . . . . . . . . . . . . . . . . . . 204
172 7.6 Floating-point environment <fenv.h> . . . . . . . . . . . . . 205
173 7.6.1 The FENV_ACCESS pragma . . . . . . . . . . . . . . 207
174 7.6.2 Floating-point exceptions . . . . . . . . . . . . . . . 208
175 7.6.3 Rounding . . . . . . . . . . . . . . . . . . . . . . 211
176 7.6.4 Environment . . . . . . . . . . . . . . . . . . . . 212
177 7.7 Characteristics of floating types <float.h> . . . . . . . . . . . 215
178 <!--page 6 indent -1-->
179 7.8 Format conversion of integer types <inttypes.h> . . . . . . . . 216
180 7.8.1 Macros for format specifiers . . . . . . . . . . . . . . 216
181 7.8.2 Functions for greatest-width integer types . . . . . . . . . 217
182 7.9 Alternative spellings <iso646.h> . . . . . . . . . . . . . . . 220
183 7.10 Sizes of integer types <limits.h> . . . . . . . . . . . . . . 221
184 7.11 Localization <locale.h> . . . . . . . . . . . . . . . . . . 222
185 7.11.1 Locale control . . . . . . . . . . . . . . . . . . . . 223
186 7.11.2 Numeric formatting convention inquiry . . . . . . . . . . 224
187 7.12 Mathematics <math.h> . . . . . . . . . . . . . . . . . . . 230
188 7.12.1 Treatment of error conditions . . . . . . . . . . . . . . 232
189 7.12.2 The FP_CONTRACT pragma . . . . . . . . . . . . . . 234
190 7.12.3 Classification macros . . . . . . . . . . . . . . . . . 234
191 7.12.4 Trigonometric functions . . . . . . . . . . . . . . . . 237
192 7.12.5 Hyperbolic functions . . . . . . . . . . . . . . . . . 239
193 7.12.6 Exponential and logarithmic functions . . . . . . . . . . 241
194 7.12.7 Power and absolute-value functions . . . . . . . . . . . 246
195 7.12.8 Error and gamma functions . . . . . . . . . . . . . . . 248
196 7.12.9 Nearest integer functions . . . . . . . . . . . . . . . . 250
197 7.12.10 Remainder functions . . . . . . . . . . . . . . . . . 253
198 7.12.11 Manipulation functions . . . . . . . . . . . . . . . . 254
199 7.12.12 Maximum, minimum, and positive difference functions . . . 256
200 7.12.13 Floating multiply-add . . . . . . . . . . . . . . . . . 257
201 7.12.14 Comparison macros . . . . . . . . . . . . . . . . . . 258
202 7.13 Nonlocal jumps <setjmp.h> . . . . . . . . . . . . . . . . 261
203 7.13.1 Save calling environment . . . . . . . . . . . . . . . 261
204 7.13.2 Restore calling environment . . . . . . . . . . . . . . 262
205 7.14 Signal handling <signal.h> . . . . . . . . . . . . . . . . . 264
206 7.14.1 Specify signal handling . . . . . . . . . . . . . . . . 265
207 7.14.2 Send signal . . . . . . . . . . . . . . . . . . . . . 266
208 7.15 Alignment <stdalign.h> . . . . . . . . . . . . . . . . . 267
209 7.16 Variable arguments <stdarg.h> . . . . . . . . . . . . . . . 268
210 7.16.1 Variable argument list access macros . . . . . . . . . . . 268
211 7.17 Atomics <stdatomic.h> . . . . . . . . . . . . . . . . . . 272
212 7.17.1 Introduction . . . . . . . . . . . . . . . . . . . . . 272
213 7.17.2 Initialization . . . . . . . . . . . . . . . . . . . . 273
214 7.17.3 Order and consistency . . . . . . . . . . . . . . . . . 274
215 7.17.4 Fences . . . . . . . . . . . . . . . . . . . . . . . 277
216 7.17.5 Lock-free property . . . . . . . . . . . . . . . . . . 278
217 7.17.6 Atomic integer and address types . . . . . . . . . . . . 279
218 7.17.7 Operations on atomic types . . . . . . . . . . . . . . . 281
219 7.17.8 Atomic flag type and operations . . . . . . . . . . . . . 284
220 7.18 Boolean type and values <stdbool.h> . . . . . . . . . . . . 286
221 7.19 Common definitions <stddef.h> . . . . . . . . . . . . . . . 287
222 7.20 Integer types <stdint.h> . . . . . . . . . . . . . . . . . . 289
223 <!--page 7 indent -1-->
224 7.20.1 Integer types . . . . . . . . . . . . . . . . . . . . 289
225 7.20.2 Limits of specified-width integer types . . . . . . . . . . 291
226 7.20.3 Limits of other integer types . . . . . . . . . . . . . . 293
227 7.20.4 Macros for integer constants . . . . . . . . . . . . . . 294
228 7.21 Input/output <stdio.h> . . . . . . . . . . . . . . . . . . 296
229 7.21.1 Introduction . . . . . . . . . . . . . . . . . . . . . 296
230 7.21.2 Streams . . . . . . . . . . . . . . . . . . . . . . 298
231 7.21.3 Files . . . . . . . . . . . . . . . . . . . . . . . . 300
232 7.21.4 Operations on files . . . . . . . . . . . . . . . . . . 302
233 7.21.5 File access functions . . . . . . . . . . . . . . . . . 304
234 7.21.6 Formatted input/output functions . . . . . . . . . . . . 309
235 7.21.7 Character input/output functions . . . . . . . . . . . . . 330
236 7.21.8 Direct input/output functions . . . . . . . . . . . . . . 334
237 7.21.9 File positioning functions . . . . . . . . . . . . . . . 335
238 7.21.10 Error-handling functions . . . . . . . . . . . . . . . . 338
239 7.22 General utilities <stdlib.h> . . . . . . . . . . . . . . . . 340
240 7.22.1 Numeric conversion functions . . . . . . . . . . . . . . 341
241 7.22.2 Pseudo-random sequence generation functions . . . . . . . 346
242 7.22.3 Memory management functions . . . . . . . . . . . . . 347
243 7.22.4 Communication with the environment . . . . . . . . . . 349
244 7.22.5 Searching and sorting utilities . . . . . . . . . . . . . . 353
245 7.22.6 Integer arithmetic functions . . . . . . . . . . . . . . 355
246 7.22.7 Multibyte/wide character conversion functions . . . . . . . 356
247 7.22.8 Multibyte/wide string conversion functions . . . . . . . . 358
248 7.23 String handling <string.h> . . . . . . . . . . . . . . . . . 360
249 7.23.1 String function conventions . . . . . . . . . . . . . . . 360
250 7.23.2 Copying functions . . . . . . . . . . . . . . . . . . 360
251 7.23.3 Concatenation functions . . . . . . . . . . . . . . . . 362
252 7.23.4 Comparison functions . . . . . . . . . . . . . . . . . 363
253 7.23.5 Search functions . . . . . . . . . . . . . . . . . . . 365
254 7.23.6 Miscellaneous functions . . . . . . . . . . . . . . . . 368
255 7.24 Type-generic math <tgmath.h> . . . . . . . . . . . . . . . 370
256 7.25 Threads <threads.h> . . . . . . . . . . . . . . . . . . . 373
257 7.25.1 Introduction . . . . . . . . . . . . . . . . . . . . . 373
258 7.25.2 Initialization functions . . . . . . . . . . . . . . . . . 375
259 7.25.3 Condition variable functions . . . . . . . . . . . . . . 375
260 7.25.4 Mutex functions . . . . . . . . . . . . . . . . . . . 377
261 7.25.5 Thread functions . . . . . . . . . . . . . . . . . . . 380
262 7.25.6 Thread-specific storage functions . . . . . . . . . . . . 382
263 7.25.7 Time functions . . . . . . . . . . . . . . . . . . . . 384
264 7.26 Date and time <time.h> . . . . . . . . . . . . . . . . . . 385
265 7.26.1 Components of time . . . . . . . . . . . . . . . . . 385
266 7.26.2 Time manipulation functions . . . . . . . . . . . . . . 386
267 7.26.3 Time conversion functions . . . . . . . . . . . . . . . 388
268 <!--page 8 indent -1-->
269 7.27 Unicode utilities <uchar.h> . . . . . . . . . . . . . . . . . 395
270 7.27.1 Restartable multibyte/wide character conversion functions . . 395
271 7.28 Extended multibyte and wide character utilities <wchar.h> . . . . . 399
272 7.28.1 Introduction . . . . . . . . . . . . . . . . . . . . . 399
273 7.28.2 Formatted wide character input/output functions . . . . . . 400
274 7.28.3 Wide character input/output functions . . . . . . . . . . 418
275 7.28.4 General wide string utilities . . . . . . . . . . . . . . 422
276 7.28.4.1 Wide string numeric conversion functions . . . . . 423
277 7.28.4.2 Wide string copying functions . . . . . . . . . . 427
278 7.28.4.3 Wide string concatenation functions . . . . . . . 429
279 7.28.4.4 Wide string comparison functions . . . . . . . . 430
280 7.28.4.5 Wide string search functions . . . . . . . . . . 432
281 7.28.4.6 Miscellaneous functions . . . . . . . . . . . . 436
282 7.28.5 Wide character time conversion functions . . . . . . . . . 436
283 7.28.6 Extended multibyte/wide character conversion utilities . . . . 437
284 7.28.6.1 Single-byte/wide character conversion functions . . . 438
285 7.28.6.2 Conversion state functions . . . . . . . . . . . 438
286 7.28.6.3 Restartable multibyte/wide character conversion
287 functions . . . . . . . . . . . . . . . . . . 439
288 7.28.6.4 Restartable multibyte/wide string conversion
289 functions . . . . . . . . . . . . . . . . . . 441
290 7.29 Wide character classification and mapping utilities <wctype.h> . . . 444
291 7.29.1 Introduction . . . . . . . . . . . . . . . . . . . . . 444
292 7.29.2 Wide character classification utilities . . . . . . . . . . . 445
293 7.29.2.1 Wide character classification functions . . . . . . 445
294 7.29.2.2 Extensible wide character classification
295 functions . . . . . . . . . . . . . . . . . . 448
296 7.29.3 Wide character case mapping utilities . . . . . . . . . . . 450
297 7.29.3.1 Wide character case mapping functions . . . . . . 450
298 7.29.3.2 Extensible wide character case mapping
299 functions . . . . . . . . . . . . . . . . . . 450
300 7.30 Future library directions . . . . . . . . . . . . . . . . . . . 452
301 7.30.1 Complex arithmetic <complex.h> . . . . . . . . . . . 452
302 7.30.2 Character handling <ctype.h> . . . . . . . . . . . . 452
303 7.30.3 Errors <errno.h> . . . . . . . . . . . . . . . . . 452
304 7.30.4 Format conversion of integer types <inttypes.h> . . . . 452
305 7.30.5 Localization <locale.h> . . . . . . . . . . . . . . 452
306 7.30.6 Signal handling <signal.h> . . . . . . . . . . . . . 452
307 7.30.7 Boolean type and values <stdbool.h> . . . . . . . . . 452
308 7.30.8 Integer types <stdint.h> . . . . . . . . . . . . . . 452
309 7.30.9 Input/output <stdio.h> . . . . . . . . . . . . . . . 453
310 7.30.10 General utilities <stdlib.h> . . . . . . . . . . . . . 453
311 7.30.11 String handling <string.h> . . . . . . . . . . . . . 453
312 <!--page 9 indent 0-->
313 7.30.12 Extended multibyte and wide character utilities
314 <wchar.h> . . . . . . . . . . . . . . . . . . . . 453
315 7.30.13 Wide character classification and mapping utilities
316 <wctype.h> . . . . . . . . . . . . . . . . . . . . 453
317 Annex A (informative) Language syntax summary . . . . . . . . . . . . 454
318 A.1 Lexical grammar . . . . . . . . . . . . . . . . . . . . . . 454
319 A.2 Phrase structure grammar . . . . . . . . . . . . . . . . . . . 461
320 A.3 Preprocessing directives . . . . . . . . . . . . . . . . . . . 469
321 Annex B (informative) Library summary . . . . . . . . . . . . . . . . 471
322 B.1 Diagnostics <assert.h> . . . . . . . . . . . . . . . . . . 471
323 B.2 Complex <complex.h> . . . . . . . . . . . . . . . . . . . 471
324 B.3 Character handling <ctype.h> . . . . . . . . . . . . . . . . 473
325 B.4 Errors <errno.h> . . . . . . . . . . . . . . . . . . . . . 473
326 B.5 Floating-point environment <fenv.h> . . . . . . . . . . . . . 473
327 B.6 Characteristics of floating types <float.h> . . . . . . . . . . . 474
328 B.7 Format conversion of integer types <inttypes.h> . . . . . . . . 474
329 B.8 Alternative spellings <iso646.h> . . . . . . . . . . . . . . . 475
330 B.9 Sizes of integer types <limits.h> . . . . . . . . . . . . . . 475
331 B.10 Localization <locale.h> . . . . . . . . . . . . . . . . . . 475
332 B.11 Mathematics <math.h> . . . . . . . . . . . . . . . . . . . 475
333 B.12 Nonlocal jumps <setjmp.h> . . . . . . . . . . . . . . . . 480
334 B.13 Signal handling <signal.h> . . . . . . . . . . . . . . . . . 480
335 B.14 Alignment <stdalign.h> . . . . . . . . . . . . . . . . . 481
336 B.15 Variable arguments <stdarg.h> . . . . . . . . . . . . . . . 481
337 B.16 Atomics <stdatomic.h> . . . . . . . . . . . . . . . . . . 481
338 B.17 Boolean type and values <stdbool.h> . . . . . . . . . . . . 483
339 B.18 Common definitions <stddef.h> . . . . . . . . . . . . . . . 483
340 B.19 Integer types <stdint.h> . . . . . . . . . . . . . . . . . . 483
341 B.20 Input/output <stdio.h> . . . . . . . . . . . . . . . . . . 484
342 B.21 General utilities <stdlib.h> . . . . . . . . . . . . . . . . 487
343 B.22 String handling <string.h> . . . . . . . . . . . . . . . . . 489
344 B.23 Type-generic math <tgmath.h> . . . . . . . . . . . . . . . 491
345 B.24 Threads <threads.h> . . . . . . . . . . . . . . . . . . . 491
346 B.25 Date and time <time.h> . . . . . . . . . . . . . . . . . . 492
347 B.26 Unicode utilities <uchar.h> . . . . . . . . . . . . . . . . . 493
348 B.27 Extended multibyte/wide character utilities <wchar.h> . . . . . . 493
349 B.28 Wide character classification and mapping utilities <wctype.h> . . . 498
350 Annex C (informative) Sequence points . . . . . . . . . . . . . . . . . 499
351 Annex D (normative) Universal character names for identifiers . . . . . . . 500
352 D.1 Ranges of characters allowed . . . . . . . . . . . . . . . . . 500
353 D.2 Ranges of characters disallowed initially . . . . . . . . . . . . . 500
354 Annex E (informative) Implementation limits . . . . . . . . . . . . . . 501
355 <!--page 10 indent 0-->
356 Annex F (normative) IEC 60559 floating-point arithmetic . . . . . . . . . . 503
357 F.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 503
358 F.2 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 503
359 F.3 Operators and functions . . . . . . . . . . . . . . . . . . . 504
360 F.4 Floating to integer conversion . . . . . . . . . . . . . . . . . 506
361 F.5 Binary-decimal conversion . . . . . . . . . . . . . . . . . . 506
362 F.6 The return statement . . . . . . . . . . . . . . . . . . . . 507
363 F.7 Contracted expressions . . . . . . . . . . . . . . . . . . . . 507
364 F.8 Floating-point environment . . . . . . . . . . . . . . . . . . 507
365 F.9 Optimization . . . . . . . . . . . . . . . . . . . . . . . . 510
366 F.10 Mathematics <math.h> . . . . . . . . . . . . . . . . . . . 513
367 F.10.1 Trigonometric functions . . . . . . . . . . . . . . . . 514
368 F.10.2 Hyperbolic functions . . . . . . . . . . . . . . . . . 516
369 F.10.3 Exponential and logarithmic functions . . . . . . . . . . 516
370 F.10.4 Power and absolute value functions . . . . . . . . . . . 520
371 F.10.5 Error and gamma functions . . . . . . . . . . . . . . . 521
372 F.10.6 Nearest integer functions . . . . . . . . . . . . . . . . 522
373 F.10.7 Remainder functions . . . . . . . . . . . . . . . . . 524
374 F.10.8 Manipulation functions . . . . . . . . . . . . . . . . 525
375 F.10.9 Maximum, minimum, and positive difference functions . . . 526
376 F.10.10 Floating multiply-add . . . . . . . . . . . . . . . . . 526
377 F.10.11 Comparison macros . . . . . . . . . . . . . . . . . . 527
378 Annex G (normative) IEC 60559-compatible complex arithmetic . . . . . . . 528
379 G.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 528
380 G.2 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
381 G.3 Conventions . . . . . . . . . . . . . . . . . . . . . . . . 528
382 G.4 Conversions . . . . . . . . . . . . . . . . . . . . . . . . 529
383 G.4.1 Imaginary types . . . . . . . . . . . . . . . . . . . 529
384 G.4.2 Real and imaginary . . . . . . . . . . . . . . . . . . 529
385 G.4.3 Imaginary and complex . . . . . . . . . . . . . . . . 529
386 G.5 Binary operators . . . . . . . . . . . . . . . . . . . . . . 529
387 G.5.1 Multiplicative operators . . . . . . . . . . . . . . . . 530
388 G.5.2 Additive operators . . . . . . . . . . . . . . . . . . 533
389 G.6 Complex arithmetic <complex.h> . . . . . . . . . . . . . . 533
390 G.6.1 Trigonometric functions . . . . . . . . . . . . . . . . 535
391 G.6.2 Hyperbolic functions . . . . . . . . . . . . . . . . . 535
392 G.6.3 Exponential and logarithmic functions . . . . . . . . . . 539
393 G.6.4 Power and absolute-value functions . . . . . . . . . . . 540
394 G.7 Type-generic math <tgmath.h> . . . . . . . . . . . . . . . 541
395 Annex H (informative) Language independent arithmetic . . . . . . . . . . 542
396 H.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . 542
397 H.2 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
398 H.3 Notification . . . . . . . . . . . . . . . . . . . . . . . . 546
399 <!--page 11 indent 0-->
400 Annex I (informative) Common warnings . . . . . . . . . . . . . . . . 548
401 Annex J (informative) Portability issues . . . . . . . . . . . . . . . . . 550
402 J.1 Unspecified behavior . . . . . . . . . . . . . . . . . . . . . 550
403 J.2 Undefined behavior . . . . . . . . . . . . . . . . . . . . . 553
404 J.3 Implementation-defined behavior . . . . . . . . . . . . . . . . 566
405 J.4 Locale-specific behavior . . . . . . . . . . . . . . . . . . . 574
406 J.5 Common extensions . . . . . . . . . . . . . . . . . . . . . 575
407 Annex K (normative) Bounds-checking interfaces . . . . . . . . . . . . . 578
408 K.1 Background . . . . . . . . . . . . . . . . . . . . . . . . 578
409 K.2 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
410 K.3 Library . . . . . . . . . . . . . . . . . . . . . . . . . . 579
411 K.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . 579
412 K.3.1.1 Standard headers . . . . . . . . . . . . . . . 579
413 K.3.1.2 Reserved identifiers . . . . . . . . . . . . . . 580
414 K.3.1.3 Use of errno . . . . . . . . . . . . . . . . . 580
415 K.3.1.4 Runtime-constraint violations . . . . . . . . . . 580
416 K.3.2 Errors <errno.h> . . . . . . . . . . . . . . . . . 581
417 K.3.3 Common definitions <stddef.h> . . . . . . . . . . . 581
418 K.3.4 Integer types <stdint.h> . . . . . . . . . . . . . . 581
419 K.3.5 Input/output <stdio.h> . . . . . . . . . . . . . . . 582
420 K.3.5.1 Operations on files . . . . . . . . . . . . . . 582
421 K.3.5.2 File access functions . . . . . . . . . . . . . . 584
422 K.3.5.3 Formatted input/output functions . . . . . . . . . 587
423 K.3.5.4 Character input/output functions . . . . . . . . . 598
424 K.3.6 General utilities <stdlib.h> . . . . . . . . . . . . . 600
425 K.3.6.1 Runtime-constraint handling . . . . . . . . . . 600
426 K.3.6.2 Communication with the environment . . . . . . . 602
427 K.3.6.3 Searching and sorting utilities . . . . . . . . . . 603
428 K.3.6.4 Multibyte/wide character conversion functions . . . 606
429 K.3.6.5 Multibyte/wide string conversion functions . . . . . 607
430 K.3.7 String handling <string.h> . . . . . . . . . . . . . 610
431 K.3.7.1 Copying functions . . . . . . . . . . . . . . 610
432 K.3.7.2 Concatenation functions . . . . . . . . . . . . 613
433 K.3.7.3 Search functions . . . . . . . . . . . . . . . 616
434 K.3.7.4 Miscellaneous functions . . . . . . . . . . . . 617
435 K.3.8 Date and time <time.h> . . . . . . . . . . . . . . . 620
436 K.3.8.1 Components of time . . . . . . . . . . . . . . 620
437 K.3.8.2 Time conversion functions . . . . . . . . . . . 620
438 K.3.9 Extended multibyte and wide character utilities
439 <wchar.h> . . . . . . . . . . . . . . . . . . . . 623
440 K.3.9.1 Formatted wide character input/output functions . . . 624
441 K.3.9.2 General wide string utilities . . . . . . . . . . . 635
442 <!--page 12 indent 0-->
443 K.3.9.3 Extended multibyte/wide character conversion
444 utilities . . . . . . . . . . . . . . . . . . . 643
445 Annex L (normative) Analyzability . . . . . . . . . . . . . . . . . . 648
446 L.1 Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . 648
447 L.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . 648
448 L.3 Requirements . . . . . . . . . . . . . . . . . . . . . . . . 649
449 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
450 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
451 <!--page 13 indent 4-->
454 <a name="Foreword" href="#Foreword"><h2>Foreword</h2></a>
456 ISO (the International Organization for Standardization) and IEC (the International
457 Electrotechnical Commission) form the specialized system for worldwide
458 standardization. National bodies that are member of ISO or IEC participate in the
459 development of International Standards through technical committees established by the
460 respective organization to deal with particular fields of technical activity. ISO and IEC
461 technical committees collaborate in fields of mutual interest. Other international
462 organizations, governmental and non-governmental, in liaison with ISO and IEC, also
463 take part in the work.
465 International Standards are drafted in accordance with the rules given in the ISO/IEC
466 Directives, Part 2. This International Standard was drafted in accordance with the fifth
469 In the field of information technology, ISO and IEC have established a joint technical
470 committee, ISO/IEC JTC 1. Draft International Standards adopted by the joint technical
471 committee are circulated to national bodies for voting. Publication as an International
472 Standard requires approval by at least 75% of the national bodies casting a vote.
474 Attention is drawn to the possibility that some of the elements of this document may be
475 the subject of patent rights. ISO and IEC shall not be held responsible for identifying any
476 or all such patent rights.
478 This International Standard was prepared by Joint Technical Committee ISO/IEC JTC 1,
479 Information technology, Subcommittee SC 22, Programming languages, their
480 environments and system software interfaces. The Working Group responsible for this
481 standard (WG 14) maintains a site on the World Wide Web at http://www.open-
482 std.org/JTC1/SC22/WG14/ containing additional information relevant to this
483 standard such as a Rationale for many of the decisions made during its preparation and a
484 log of Defect Reports and Responses.
486 This third edition cancels and replaces the second edition, ISO/IEC 9899:1999, as
487 corrected by ISO/IEC 9899:1999/Cor 1:2001, ISO/IEC 9899:1999/Cor 2:2004, and
488 ISO/IEC 9899:1999/Cor 3:2007. Major changes from the previous edition include:
490 <li> conditional (optional) features (including some that were previously mandatory)
491 <li> support for multiple threads of execution including an improved memory sequencing
492 model, atomic objects, and thread-local storage (<stdatomic.h> and
494 <li> additional floating-point characteristic macros (<float.h>)
495 <li> querying and specifying alignment of objects (<stdalign.h>, <stdlib.h>)
496 <li> Unicode characters and strings (<uchar.h>) (originally specified in
497 ISO/IEC TR 19769:2004)
498 <li> type-generic expressions
499 <!--page 14 indent 4-->
500 <li> static assertions
501 <li> anonymous structures and unions
502 <li> no-return functions
503 <li> macros to create complex numbers (<complex.h>)
504 <li> support for opening files for exclusive access
505 <li> removed the gets function (<stdio.h>)
506 <li> added the aligned_alloc, at_quick_exit, and quick_exit functions
508 <li> (conditional) support for bounds-checking interfaces (originally specified in
509 ISO/IEC TR 24731-1:2007)
510 <li> (conditional) support for analyzability
513 Major changes in the second edition included:
515 <li> restricted character set support via digraphs and <iso646.h> (originally specified
517 <li> wide character library support in <wchar.h> and <wctype.h> (originally
519 <li> more precise aliasing rules via effective type
520 <li> restricted pointers
521 <li> variable length arrays
522 <li> flexible array members
523 <li> static and type qualifiers in parameter array declarators
524 <li> complex (and imaginary) support in <complex.h>
525 <li> type-generic math macros in <tgmath.h>
526 <li> the long long int type and library functions
527 <li> increased minimum translation limits
528 <li> additional floating-point characteristics in <float.h>
529 <li> remove implicit int
530 <li> reliable integer division
531 <li> universal character names (\u and \U)
532 <li> extended identifiers
533 <li> hexadecimal floating-point constants and %a and %A printf/scanf conversion
535 <!--page 15 indent 0-->
536 <li> compound literals
537 <li> designated initializers
539 <li> extended integer types and library functions in <inttypes.h> and <stdint.h>
540 <li> remove implicit function declaration
541 <li> preprocessor arithmetic done in intmax_t/uintmax_t
542 <li> mixed declarations and code
543 <li> new block scopes for selection and iteration statements
544 <li> integer constant type rules
545 <li> integer promotion rules
546 <li> macros with a variable number of arguments
547 <li> the vscanf family of functions in <stdio.h> and <wchar.h>
548 <li> additional math library functions in <math.h>
549 <li> treatment of error conditions by math library functions (math_errhandling)
550 <li> floating-point environment access in <fenv.h>
551 <li> IEC 60559 (also known as IEC 559 or IEEE arithmetic) support
552 <li> trailing comma allowed in enum declaration
553 <li> %lf conversion specifier allowed in printf
554 <li> inline functions
555 <li> the snprintf family of functions in <stdio.h>
556 <li> boolean type in <stdbool.h>
557 <li> idempotent type qualifiers
558 <li> empty macro arguments
559 <li> new structure type compatibility rules (tag compatibility)
560 <li> additional predefined macro names
561 <li> _Pragma preprocessing operator
562 <li> standard pragmas
563 <li> __func__ predefined identifier
565 <li> additional strftime conversion specifiers
566 <li> LIA compatibility annex
567 <!--page 16 indent 4-->
568 <li> deprecate ungetc at the beginning of a binary file
569 <li> remove deprecation of aliased array parameters
570 <li> conversion of array to pointer not limited to lvalues
571 <li> relaxed constraints on aggregate and union initialization
572 <li> relaxed restrictions on portable header names
573 <li> return without expression not permitted in function that returns a value (and vice
577 Annexes D, F, G, K, and L form a normative part of this standard; annexes A, B, C, E, H, *
578 I, J, the bibliography, and the index are for information only. In accordance with Part 2 of
579 the ISO/IEC Directives, this foreword, the introduction, notes, footnotes, and examples
580 are also for information only.
581 <!--page 17 indent 4-->
583 <a name="Introduction" href="#Introduction"><h2>Introduction</h2></a>
585 With the introduction of new devices and extended character sets, new features may be
586 added to this International Standard. Subclauses in the language and library clauses warn
587 implementors and programmers of usages which, though valid in themselves, may
588 conflict with future additions.
590 Certain features are obsolescent, which means that they may be considered for
591 withdrawal in future revisions of this International Standard. They are retained because
592 of their widespread use, but their use in new implementations (for implementation
593 features) or new programs (for language [<a href="#6.11">6.11</a>] or library features [<a href="#7.30">7.30</a>]) is discouraged.
595 This International Standard is divided into four major subdivisions:
597 <li> preliminary elements (clauses 1-4);
598 <li> the characteristics of environments that translate and execute C programs (clause 5);
599 <li> the language syntax, constraints, and semantics (clause 6);
600 <li> the library facilities (clause 7).
603 Examples are provided to illustrate possible forms of the constructions described.
604 Footnotes are provided to emphasize consequences of the rules described in that
605 subclause or elsewhere in this International Standard. References are used to refer to
606 other related subclauses. Recommendations are provided to give advice or guidance to
607 implementors. Annexes provide additional information and summarize the information
608 contained in this International Standard. A bibliography lists documents that were
609 referred to during the preparation of the standard.
611 The language clause (clause 6) is derived from ''The C Reference Manual''.
613 The library clause (clause 7) is based on the 1984 /usr/group Standard.
614 <!--page 18 indent 0-->
615 <!--page 19 indent 4-->
617 <h1>Programming languages -- C</h1>
622 <a name="1" href="#1"><h2>1. Scope</h2></a>
624 This International Standard specifies the form and establishes the interpretation of
625 programs written in the C programming language.<sup><a href="#note1"><b>1)</b></a></sup> It specifies
627 <li> the representation of C programs;
628 <li> the syntax and constraints of the C language;
629 <li> the semantic rules for interpreting C programs;
630 <li> the representation of input data to be processed by C programs;
631 <li> the representation of output data produced by C programs;
632 <li> the restrictions and limits imposed by a conforming implementation of C.
635 This International Standard does not specify
637 <li> the mechanism by which C programs are transformed for use by a data-processing
639 <li> the mechanism by which C programs are invoked for use by a data-processing
641 <li> the mechanism by which input data are transformed for use by a C program;
642 <li> the mechanism by which output data are transformed after being produced by a C
644 <li> the size or complexity of a program and its data that will exceed the capacity of any
645 specific data-processing system or the capacity of a particular processor;
646 <li> all minimal requirements of a data-processing system that is capable of supporting a
647 conforming implementation.
650 <!--page 20 indent 4-->
654 <p><a name="note1">1)</a> This International Standard is designed to promote the portability of C programs among a variety of
655 data-processing systems. It is intended for use by implementors and programmers.
658 <a name="2" href="#2"><h2>2. Normative references</h2></a>
660 The following referenced documents are indispensable for the application of this
661 document. For dated references, only the edition cited applies. For undated references,
662 the latest edition of the referenced document (including any amendments) applies.
664 ISO 31-11:1992, Quantities and units -- Part 11: Mathematical signs and symbols for
665 use in the physical sciences and technology.
667 ISO/IEC 646, Information technology -- ISO 7-bit coded character set for information
670 ISO/IEC 2382-1:1993, Information technology -- Vocabulary -- Part 1: Fundamental
673 ISO 4217, Codes for the representation of currencies and funds.
675 ISO 8601, Data elements and interchange formats -- Information interchange --
676 Representation of dates and times.
678 ISO/IEC 10646 (all parts), Information technology -- Universal Multiple-Octet Coded
681 IEC 60559:1989, Binary floating-point arithmetic for microprocessor systems (previously
682 designated IEC 559:1989).
683 <!--page 21 indent 4-->
685 <a name="3" href="#3"><h2>3. Terms, definitions, and symbols</h2></a>
687 For the purposes of this International Standard, the following definitions apply. Other
688 terms are defined where they appear in italic type or on the left side of a syntax rule.
689 Terms explicitly defined in this International Standard are not to be presumed to refer
690 implicitly to similar terms defined elsewhere. Terms not defined in this International
691 Standard are to be interpreted according to ISO/IEC 2382-1. Mathematical symbols not
692 defined in this International Standard are to be interpreted according to ISO 31-11.
694 <a name="3.1" href="#3.1"><h3>3.1</h3></a>
697 <execution-time action> to read or modify the value of an object
699 NOTE 1 Where only one of these two actions is meant, ''read'' or ''modify'' is used.
702 NOTE 2 ''Modify'' includes the case where the new value being stored is the same as the previous value.
705 NOTE 3 Expressions that are not evaluated do not access objects.
708 <a name="3.2" href="#3.2"><h3>3.2</h3></a>
711 requirement that objects of a particular type be located on storage boundaries with
712 addresses that are particular multiples of a byte address
714 <a name="3.3" href="#3.3"><h3>3.3</h3></a>
718 actual parameter (deprecated)
719 expression in the comma-separated list bounded by the parentheses in a function call
720 expression, or a sequence of preprocessing tokens in the comma-separated list bounded
721 by the parentheses in a function-like macro invocation
723 <a name="3.4" href="#3.4"><h3>3.4</h3></a>
726 external appearance or action
728 <a name="3.4.1" href="#3.4.1"><h4>3.4.1</h4></a>
730 implementation-defined behavior
731 unspecified behavior where each implementation documents how the choice is made
733 EXAMPLE An example of implementation-defined behavior is the propagation of the high-order bit
734 when a signed integer is shifted right.
737 <a name="3.4.2" href="#3.4.2"><h4>3.4.2</h4></a>
739 locale-specific behavior
740 behavior that depends on local conventions of nationality, culture, and language that each
741 implementation documents
742 <!--page 22 indent 4-->
744 EXAMPLE An example of locale-specific behavior is whether the islower function returns true for
745 characters other than the 26 lowercase Latin letters.
748 <a name="3.4.3" href="#3.4.3"><h4>3.4.3</h4></a>
751 behavior, upon use of a nonportable or erroneous program construct or of erroneous data,
752 for which this International Standard imposes no requirements
754 NOTE Possible undefined behavior ranges from ignoring the situation completely with unpredictable
755 results, to behaving during translation or program execution in a documented manner characteristic of the
756 environment (with or without the issuance of a diagnostic message), to terminating a translation or
757 execution (with the issuance of a diagnostic message).
760 EXAMPLE An example of undefined behavior is the behavior on integer overflow.
763 <a name="3.4.4" href="#3.4.4"><h4>3.4.4</h4></a>
766 use of an unspecified value, or other behavior where this International Standard provides
767 two or more possibilities and imposes no further requirements on which is chosen in any
770 EXAMPLE An example of unspecified behavior is the order in which the arguments to a function are
774 <a name="3.5" href="#3.5"><h3>3.5</h3></a>
777 unit of data storage in the execution environment large enough to hold an object that may
778 have one of two values
780 NOTE It need not be possible to express the address of each individual bit of an object.
783 <a name="3.6" href="#3.6"><h3>3.6</h3></a>
786 addressable unit of data storage large enough to hold any member of the basic character
787 set of the execution environment
789 NOTE 1 It is possible to express the address of each individual byte of an object uniquely.
792 NOTE 2 A byte is composed of a contiguous sequence of bits, the number of which is implementation-
793 defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order
797 <a name="3.7" href="#3.7"><h3>3.7</h3></a>
800 <abstract> member of a set of elements used for the organization, control, or
801 representation of data
803 <a name="3.7.1" href="#3.7.1"><h4>3.7.1</h4></a>
806 single-byte character
807 <C> bit representation that fits in a byte
808 <!--page 23 indent 4-->
810 <a name="3.7.2" href="#3.7.2"><h4>3.7.2</h4></a>
813 sequence of one or more bytes representing a member of the extended character set of
814 either the source or the execution environment
816 NOTE The extended character set is a superset of the basic character set.
819 <a name="3.7.3" href="#3.7.3"><h4>3.7.3</h4></a>
822 bit representation that fits in an object of type wchar_t, capable of representing any
823 character in the current locale
825 <a name="3.8" href="#3.8"><h3>3.8</h3></a>
828 restriction, either syntactic or semantic, by which the exposition of language elements is
831 <a name="3.9" href="#3.9"><h3>3.9</h3></a>
833 correctly rounded result
834 representation in the result format that is nearest in value, subject to the current rounding
835 mode, to what the result would be given unlimited range and precision
837 <a name="3.10" href="#3.10"><h3>3.10</h3></a>
840 message belonging to an implementation-defined subset of the implementation's message
843 <a name="3.11" href="#3.11"><h3>3.11</h3></a>
846 reference to a later subclause of this International Standard that contains additional
847 information relevant to this subclause
849 <a name="3.12" href="#3.12"><h3>3.12</h3></a>
852 particular set of software, running in a particular translation environment under particular
853 control options, that performs translation of programs for, and supports execution of
854 functions in, a particular execution environment
856 <a name="3.13" href="#3.13"><h3>3.13</h3></a>
859 restriction imposed upon programs by the implementation
861 <a name="3.14" href="#3.14"><h3>3.14</h3></a>
864 either an object of scalar type, or a maximal sequence of adjacent bit-fields all having
866 <!--page 24 indent 4-->
868 NOTE 1 Two threads of execution can update and access separate memory locations without interfering
872 NOTE 2 A bit-field and an adjacent non-bit-field member are in separate memory locations. The same
873 applies to two bit-fields, if one is declared inside a nested structure declaration and the other is not, or if the
874 two are separated by a zero-length bit-field declaration, or if they are separated by a non-bit-field member
875 declaration. It is not safe to concurrently update two non-atomic bit-fields in the same structure if all
876 members declared between them are also (non-zero-length) bit-fields, no matter what the sizes of those
877 intervening bit-fields happen to be.
880 EXAMPLE A structure declared as
884 int b:5, c:11, :0, d:8;
885 struct { int ee:8; } e;
887 contains four separate memory locations: The member a, and bit-fields d and e.ee are each separate
888 memory locations, and can be modified concurrently without interfering with each other. The bit-fields b
889 and c together constitute the fourth memory location. The bit-fields b and c cannot be concurrently
890 modified, but b and a, for example, can be.
893 <a name="3.15" href="#3.15"><h3>3.15</h3></a>
896 region of data storage in the execution environment, the contents of which can represent
899 NOTE When referenced, an object may be interpreted as having a particular type; see <a href="#6.3.2.1">6.3.2.1</a>.
902 <a name="3.16" href="#3.16"><h3>3.16</h3></a>
906 formal argument (deprecated)
907 object declared as part of a function declaration or definition that acquires a value on
908 entry to the function, or an identifier from the comma-separated list bounded by the
909 parentheses immediately following the macro name in a function-like macro definition
911 <a name="3.17" href="#3.17"><h3>3.17</h3></a>
914 specification that is strongly recommended as being in keeping with the intent of the
915 standard, but that may be impractical for some implementations
917 <a name="3.18" href="#3.18"><h3>3.18</h3></a>
920 requirement on a program when calling a library function
922 NOTE 1 Despite the similar terms, a runtime-constraint is not a kind of constraint as defined by <a href="#3.8">3.8</a>, and
923 need not be diagnosed at translation time.
926 NOTE 2 Implementations that support the extensions in <a href="#K">annex K</a> are required to verify that the runtime-
927 constraints for a library function are not violated by the program; see <a href="#K.3.1.4">K.3.1.4</a>.
928 <!--page 25 indent 4-->
930 <a name="3.19" href="#3.19"><h3>3.19</h3></a>
933 precise meaning of the contents of an object when interpreted as having a specific type
935 <a name="3.19.1" href="#3.19.1"><h4>3.19.1</h4></a>
937 implementation-defined value
938 unspecified value where each implementation documents how the choice is made
940 <a name="3.19.2" href="#3.19.2"><h4>3.19.2</h4></a>
943 either an unspecified value or a trap representation
945 <a name="3.19.3" href="#3.19.3"><h4>3.19.3</h4></a>
948 valid value of the relevant type where this International Standard imposes no
949 requirements on which value is chosen in any instance
951 NOTE An unspecified value cannot be a trap representation.
954 <a name="3.19.4" href="#3.19.4"><h4>3.19.4</h4></a>
957 an object representation that need not represent a value of the object type
959 <a name="3.19.5" href="#3.19.5"><h4>3.19.5</h4></a>
962 interrupt execution of the program such that no further operations are performed
964 NOTE In this International Standard, when the word ''trap'' is not immediately followed by
965 ''representation'', this is the intended usage.<sup><a href="#note2"><b>2)</b></a></sup>
969 <p><a name="note2">2)</a> For example, ''Trapping or stopping (if supported) is disabled...'' (<a href="#F.8.2">F.8.2</a>). Note that fetching a trap
970 representation might perform a trap but is not required to (see <a href="#6.2.6.1">6.2.6.1</a>).
973 <a name="3.20" href="#3.20"><h3>3.20</h3></a>
976 ceiling of x: the least integer greater than or equal to x
978 EXAMPLE [^2.4^] is 3, [^-2.4^] is -2.
981 <a name="3.21" href="#3.21"><h3>3.21</h3></a>
984 floor of x: the greatest integer less than or equal to x
986 EXAMPLE [_2.4_] is 2, [_-2.4_] is -3.
991 <!--page 26 indent 4-->
993 <a name="4" href="#4"><h2>4. Conformance</h2></a>
995 In this International Standard, ''shall'' is to be interpreted as a requirement on an
996 implementation or on a program; conversely, ''shall not'' is to be interpreted as a
999 If a ''shall'' or ''shall not'' requirement that appears outside of a constraint or runtime-
1000 constraint is violated, the behavior is undefined. Undefined behavior is otherwise
1001 indicated in this International Standard by the words ''undefined behavior'' or by the
1002 omission of any explicit definition of behavior. There is no difference in emphasis among
1003 these three; they all describe ''behavior that is undefined''.
1005 A program that is correct in all other aspects, operating on correct data, containing
1006 unspecified behavior shall be a correct program and act in accordance with <a href="#5.1.2.3">5.1.2.3</a>.
1008 The implementation shall not successfully translate a preprocessing translation unit
1009 containing a #error preprocessing directive unless it is part of a group skipped by
1010 conditional inclusion.
1012 A strictly conforming program shall use only those features of the language and library
1013 specified in this International Standard.<sup><a href="#note3"><b>3)</b></a></sup> It shall not produce output dependent on any
1014 unspecified, undefined, or implementation-defined behavior, and shall not exceed any
1015 minimum implementation limit.
1017 The two forms of conforming implementation are hosted and freestanding. A conforming
1018 hosted implementation shall accept any strictly conforming program. A conforming
1019 freestanding implementation shall accept any strictly conforming program that does not
1020 use complex types and in which the use of the features specified in the library clause
1021 (clause 7) is confined to the contents of the standard headers <float.h>,
1022 <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>,
1023 <stddef.h>, and <stdint.h>. A conforming implementation may have extensions
1024 (including additional library functions), provided they do not alter the behavior of any
1025 strictly conforming program.<sup><a href="#note4"><b>4)</b></a></sup>
1029 <!--page 27 indent 4-->
1031 A conforming program is one that is acceptable to a conforming implementation.<sup><a href="#note5"><b>5)</b></a></sup>
1033 An implementation shall be accompanied by a document that defines all implementation-
1034 defined and locale-specific characteristics and all extensions.
1035 Forward references: conditional inclusion (<a href="#6.10.1">6.10.1</a>), error directive (<a href="#6.10.5">6.10.5</a>),
1036 characteristics of floating types <float.h> (<a href="#7.7">7.7</a>), alternative spellings <iso646.h>
1037 (<a href="#7.9">7.9</a>), sizes of integer types <limits.h> (<a href="#7.10">7.10</a>), alignment <stdalign.h> (<a href="#7.15">7.15</a>),
1038 variable arguments <stdarg.h> (<a href="#7.16">7.16</a>), boolean type and values <stdbool.h>
1039 (<a href="#7.18">7.18</a>), common definitions <stddef.h> (<a href="#7.19">7.19</a>), integer types <stdint.h> (<a href="#7.20">7.20</a>).
1044 <!--page 28 indent 4-->
1047 <p><a name="note3">3)</a> A strictly conforming program can use conditional features (see <a href="#6.10.8.3">6.10.8.3</a>) provided the use is guarded
1048 by an appropriate conditional inclusion preprocessing directive using the related macro. For example:
1051 #ifdef __STDC_IEC_559__ /* FE_UPWARD defined */
1053 fesetround(FE_UPWARD);
1058 <p><a name="note4">4)</a> This implies that a conforming implementation reserves no identifiers other than those explicitly
1059 reserved in this International Standard.
1061 <p><a name="note5">5)</a> Strictly conforming programs are intended to be maximally portable among conforming
1062 implementations. Conforming programs may depend upon nonportable features of a conforming
1066 <a name="5" href="#5"><h2>5. Environment</h2></a>
1068 An implementation translates C source files and executes C programs in two data-
1069 processing-system environments, which will be called the translation environment and
1070 the execution environment in this International Standard. Their characteristics define and
1071 constrain the results of executing conforming C programs constructed according to the
1072 syntactic and semantic rules for conforming implementations.
1073 Forward references: In this clause, only a few of many possible forward references
1076 <a name="5.1" href="#5.1"><h3>5.1 Conceptual models</h3></a>
1078 <a name="5.1.1" href="#5.1.1"><h4>5.1.1 Translation environment</h4></a>
1080 <a name="5.1.1.1" href="#5.1.1.1"><h5>5.1.1.1 Program structure</h5></a>
1082 A C program need not all be translated at the same time. The text of the program is kept
1083 in units called source files, (or preprocessing files) in this International Standard. A
1084 source file together with all the headers and source files included via the preprocessing
1085 directive #include is known as a preprocessing translation unit. After preprocessing, a
1086 preprocessing translation unit is called a translation unit. Previously translated translation
1087 units may be preserved individually or in libraries. The separate translation units of a
1088 program communicate by (for example) calls to functions whose identifiers have external
1089 linkage, manipulation of objects whose identifiers have external linkage, or manipulation
1090 of data files. Translation units may be separately translated and then later linked to
1091 produce an executable program.
1092 Forward references: linkages of identifiers (<a href="#6.2.2">6.2.2</a>), external definitions (<a href="#6.9">6.9</a>),
1093 preprocessing directives (<a href="#6.10">6.10</a>).
1095 <a name="5.1.1.2" href="#5.1.1.2"><h5>5.1.1.2 Translation phases</h5></a>
1097 The precedence among the syntax rules of translation is specified by the following
1098 phases.<sup><a href="#note6"><b>6)</b></a></sup>
1100 <li> Physical source file multibyte characters are mapped, in an implementation-
1101 defined manner, to the source character set (introducing new-line characters for
1102 end-of-line indicators) if necessary. Trigraph sequences are replaced by
1103 corresponding single-character internal representations.
1107 <!--page 29 indent 0-->
1108 <li> Each instance of a backslash character (\) immediately followed by a new-line
1109 character is deleted, splicing physical source lines to form logical source lines.
1110 Only the last backslash on any physical source line shall be eligible for being part
1111 of such a splice. A source file that is not empty shall end in a new-line character,
1112 which shall not be immediately preceded by a backslash character before any such
1113 splicing takes place.
1114 <li> The source file is decomposed into preprocessing tokens<sup><a href="#note7"><b>7)</b></a></sup> and sequences of
1115 white-space characters (including comments). A source file shall not end in a
1116 partial preprocessing token or in a partial comment. Each comment is replaced by
1117 one space character. New-line characters are retained. Whether each nonempty
1118 sequence of white-space characters other than new-line is retained or replaced by
1119 one space character is implementation-defined.
1120 <li> Preprocessing directives are executed, macro invocations are expanded, and
1121 _Pragma unary operator expressions are executed. If a character sequence that
1122 matches the syntax of a universal character name is produced by token
1123 concatenation (<a href="#6.10.3.3">6.10.3.3</a>), the behavior is undefined. A #include preprocessing
1124 directive causes the named header or source file to be processed from phase 1
1125 through phase 4, recursively. All preprocessing directives are then deleted.
1126 <li> Each source character set member and escape sequence in character constants and
1127 string literals is converted to the corresponding member of the execution character
1128 set; if there is no corresponding member, it is converted to an implementation-
1129 defined member other than the null (wide) character.<sup><a href="#note8"><b>8)</b></a></sup>
1130 <li> Adjacent string literal tokens are concatenated.
1131 <li> White-space characters separating tokens are no longer significant. Each
1132 preprocessing token is converted into a token. The resulting tokens are
1133 syntactically and semantically analyzed and translated as a translation unit.
1134 <li> All external object and function references are resolved. Library components are
1135 linked to satisfy external references to functions and objects not defined in the
1136 current translation. All such translator output is collected into a program image
1137 which contains information needed for execution in its execution environment.
1139 Forward references: universal character names (<a href="#6.4.3">6.4.3</a>), lexical elements (<a href="#6.4">6.4</a>),
1140 preprocessing directives (<a href="#6.10">6.10</a>), trigraph sequences (<a href="#5.2.1.1">5.2.1.1</a>), external definitions (<a href="#6.9">6.9</a>).
1144 <!--page 30 indent 4-->
1147 <p><a name="note6">6)</a> Implementations shall behave as if these separate phases occur, even though many are typically folded
1148 together in practice. Source files, translation units, and translated translation units need not
1149 necessarily be stored as files, nor need there be any one-to-one correspondence between these entities
1150 and any external representation. The description is conceptual only, and does not specify any
1151 particular implementation.
1153 <p><a name="note7">7)</a> As described in <a href="#6.4">6.4</a>, the process of dividing a source file's characters into preprocessing tokens is
1154 context-dependent. For example, see the handling of < within a #include preprocessing directive.
1156 <p><a name="note8">8)</a> An implementation need not convert all non-corresponding source characters to the same execution
1160 <a name="5.1.1.3" href="#5.1.1.3"><h5>5.1.1.3 Diagnostics</h5></a>
1162 A conforming implementation shall produce at least one diagnostic message (identified in
1163 an implementation-defined manner) if a preprocessing translation unit or translation unit
1164 contains a violation of any syntax rule or constraint, even if the behavior is also explicitly
1165 specified as undefined or implementation-defined. Diagnostic messages need not be
1166 produced in other circumstances.<sup><a href="#note9"><b>9)</b></a></sup>
1168 EXAMPLE An implementation shall issue a diagnostic for the translation unit:
1172 because in those cases where wording in this International Standard describes the behavior for a construct
1173 as being both a constraint error and resulting in undefined behavior, the constraint error shall be diagnosed.
1177 <p><a name="note9">9)</a> The intent is that an implementation should identify the nature of, and where possible localize, each
1178 violation. Of course, an implementation is free to produce any number of diagnostics as long as a
1179 valid program is still correctly translated. It may also successfully translate an invalid program.
1182 <a name="5.1.2" href="#5.1.2"><h4>5.1.2 Execution environments</h4></a>
1184 Two execution environments are defined: freestanding and hosted. In both cases,
1185 program startup occurs when a designated C function is called by the execution
1186 environment. All objects with static storage duration shall be initialized (set to their
1187 initial values) before program startup. The manner and timing of such initialization are
1188 otherwise unspecified. Program termination returns control to the execution
1190 Forward references: storage durations of objects (<a href="#6.2.4">6.2.4</a>), initialization (<a href="#6.7.9">6.7.9</a>).
1192 <a name="5.1.2.1" href="#5.1.2.1"><h5>5.1.2.1 Freestanding environment</h5></a>
1194 In a freestanding environment (in which C program execution may take place without any
1195 benefit of an operating system), the name and type of the function called at program
1196 startup are implementation-defined. Any library facilities available to a freestanding
1197 program, other than the minimal set required by clause 4, are implementation-defined.
1199 The effect of program termination in a freestanding environment is implementation-
1202 <a name="5.1.2.2" href="#5.1.2.2"><h5>5.1.2.2 Hosted environment</h5></a>
1204 A hosted environment need not be provided, but shall conform to the following
1205 specifications if present.
1210 <!--page 31 indent 4-->
1212 <a name="5.1.2.2.1" href="#5.1.2.2.1"><h5>5.1.2.2.1 Program startup</h5></a>
1214 The function called at program startup is named main. The implementation declares no
1215 prototype for this function. It shall be defined with a return type of int and with no
1218 int main(void) { /* ... */ }</pre>
1219 or with two parameters (referred to here as argc and argv, though any names may be
1220 used, as they are local to the function in which they are declared):
1222 int main(int argc, char *argv[]) { /* ... */ }</pre>
1223 or equivalent;<sup><a href="#note10"><b>10)</b></a></sup> or in some other implementation-defined manner.
1225 If they are declared, the parameters to the main function shall obey the following
1228 <li> The value of argc shall be nonnegative.
1229 <li> argv[argc] shall be a null pointer.
1230 <li> If the value of argc is greater than zero, the array members argv[0] through
1231 argv[argc-1] inclusive shall contain pointers to strings, which are given
1232 implementation-defined values by the host environment prior to program startup. The
1233 intent is to supply to the program information determined prior to program startup
1234 from elsewhere in the hosted environment. If the host environment is not capable of
1235 supplying strings with letters in both uppercase and lowercase, the implementation
1236 shall ensure that the strings are received in lowercase.
1237 <li> If the value of argc is greater than zero, the string pointed to by argv[0]
1238 represents the program name; argv[0][0] shall be the null character if the
1239 program name is not available from the host environment. If the value of argc is
1240 greater than one, the strings pointed to by argv[1] through argv[argc-1]
1241 represent the program parameters.
1242 <li> The parameters argc and argv and the strings pointed to by the argv array shall
1243 be modifiable by the program, and retain their last-stored values between program
1244 startup and program termination.
1248 <p><a name="note10">10)</a> Thus, int can be replaced by a typedef name defined as int, or the type of argv can be written as
1249 char ** argv, and so on.
1252 <a name="5.1.2.2.2" href="#5.1.2.2.2"><h5>5.1.2.2.2 Program execution</h5></a>
1254 In a hosted environment, a program may use all the functions, macros, type definitions,
1255 and objects described in the library clause (clause 7).
1260 <!--page 32 indent 4-->
1262 <a name="5.1.2.2.3" href="#5.1.2.2.3"><h5>5.1.2.2.3 Program termination</h5></a>
1264 If the return type of the main function is a type compatible with int, a return from the
1265 initial call to the main function is equivalent to calling the exit function with the value
1266 returned by the main function as its argument;<sup><a href="#note11"><b>11)</b></a></sup> reaching the } that terminates the
1267 main function returns a value of 0. If the return type is not compatible with int, the
1268 termination status returned to the host environment is unspecified.
1269 Forward references: definition of terms (<a href="#7.1.1">7.1.1</a>), the exit function (<a href="#7.22.4.4">7.22.4.4</a>).
1272 <p><a name="note11">11)</a> In accordance with <a href="#6.2.4">6.2.4</a>, the lifetimes of objects with automatic storage duration declared in main
1273 will have ended in the former case, even where they would not have in the latter.
1276 <a name="5.1.2.3" href="#5.1.2.3"><h5>5.1.2.3 Program execution</h5></a>
1278 The semantic descriptions in this International Standard describe the behavior of an
1279 abstract machine in which issues of optimization are irrelevant.
1281 Accessing a volatile object, modifying an object, modifying a file, or calling a function
1282 that does any of those operations are all side effects,<sup><a href="#note12"><b>12)</b></a></sup> which are changes in the state of
1283 the execution environment. Evaluation of an expression in general includes both value
1284 computations and initiation of side effects. Value computation for an lvalue expression
1285 includes determining the identity of the designated object.
1287 Sequenced before is an asymmetric, transitive, pair-wise relation between evaluations
1288 executed by a single thread, which induces a partial order among those evaluations.
1289 Given any two evaluations A and B, if A is sequenced before B, then the execution of A
1290 shall precede the execution of B. (Conversely, if A is sequenced before B, then B is
1291 sequenced after A.) If A is not sequenced before or after B, then A and B are
1292 unsequenced. Evaluations A and B are indeterminately sequenced when A is sequenced
1293 either before or after B, but it is unspecified which.<sup><a href="#note13"><b>13)</b></a></sup> The presence of a sequence point
1294 between the evaluation of expressions A and B implies that every value computation and
1295 side effect associated with A is sequenced before every value computation and side effect
1296 associated with B. (A summary of the sequence points is given in <a href="#C">annex C</a>.)
1298 In the abstract machine, all expressions are evaluated as specified by the semantics. An
1299 actual implementation need not evaluate part of an expression if it can deduce that its
1300 value is not used and that no needed side effects are produced (including any caused by
1302 <!--page 33 indent 5-->
1303 calling a function or accessing a volatile object).
1305 When the processing of the abstract machine is interrupted by receipt of a signal, the
1306 values of objects that are neither lock-free atomic objects nor of type volatile
1307 sig_atomic_t are unspecified, and the value of any object that is modified by the
1308 handler that is neither a lock-free atomic object nor of type volatile
1309 sig_atomic_t becomes undefined.
1311 The least requirements on a conforming implementation are:
1313 <li> Accesses to volatile objects are evaluated strictly according to the rules of the abstract
1315 <li> At program termination, all data written into files shall be identical to the result that
1316 execution of the program according to the abstract semantics would have produced.
1317 <li> The input and output dynamics of interactive devices shall take place as specified in
1318 <a href="#7.21.3">7.21.3</a>. The intent of these requirements is that unbuffered or line-buffered output
1319 appear as soon as possible, to ensure that prompting messages actually appear prior to
1320 a program waiting for input.
1322 This is the observable behavior of the program.
1324 What constitutes an interactive device is implementation-defined.
1326 More stringent correspondences between abstract and actual semantics may be defined by
1327 each implementation.
1329 EXAMPLE 1 An implementation might define a one-to-one correspondence between abstract and actual
1330 semantics: at every sequence point, the values of the actual objects would agree with those specified by the
1331 abstract semantics. The keyword volatile would then be redundant.
1333 Alternatively, an implementation might perform various optimizations within each translation unit, such
1334 that the actual semantics would agree with the abstract semantics only when making function calls across
1335 translation unit boundaries. In such an implementation, at the time of each function entry and function
1336 return where the calling function and the called function are in different translation units, the values of all
1337 externally linked objects and of all objects accessible via pointers therein would agree with the abstract
1338 semantics. Furthermore, at the time of each such function entry the values of the parameters of the called
1339 function and of all objects accessible via pointers therein would agree with the abstract semantics. In this
1340 type of implementation, objects referred to by interrupt service routines activated by the signal function
1341 would require explicit specification of volatile storage, as well as other implementation-defined
1345 EXAMPLE 2 In executing the fragment
1350 the ''integer promotions'' require that the abstract machine promote the value of each variable to int size
1351 and then add the two ints and truncate the sum. Provided the addition of two chars can be done without
1352 overflow, or with overflow wrapping silently to produce the correct result, the actual execution need only
1353 produce the same result, possibly omitting the promotions.
1354 <!--page 34 indent 5-->
1356 EXAMPLE 3 Similarly, in the fragment
1362 the multiplication may be executed using single-precision arithmetic if the implementation can ascertain
1363 that the result would be the same as if it were executed using double-precision arithmetic (for example, if d
1364 were replaced by the constant 2.0, which has type double).
1367 EXAMPLE 4 Implementations employing wide registers have to take care to honor appropriate
1368 semantics. Values are independent of whether they are represented in a register or in memory. For
1369 example, an implicit spilling of a register is not permitted to alter the value. Also, an explicit store and load
1370 is required to round to the precision of the storage type. In particular, casts and assignments are required to
1371 perform their specified conversion. For the fragment
1375 d1 = f = expression;
1376 d2 = (float) expression;</pre>
1377 the values assigned to d1 and d2 are required to have been converted to float.
1380 EXAMPLE 5 Rearrangement for floating-point expressions is often restricted because of limitations in
1381 precision as well as range. The implementation cannot generally apply the mathematical associative rules
1382 for addition or multiplication, nor the distributive rule, because of roundoff error, even in the absence of
1383 overflow and underflow. Likewise, implementations cannot generally replace decimal constants in order to
1384 rearrange expressions. In the following fragment, rearrangements suggested by mathematical rules for real
1385 numbers are often not valid (see <a href="#F.9">F.9</a>).
1389 x = (x * y) * z; // not equivalent to x *= y * z;
1390 z = (x - y) + y ; // not equivalent to z = x;
1391 z = x + x * y; // not equivalent to z = x * (1.0 + y);
1392 y = x / 5.0; // not equivalent to y = x * 0.2;</pre>
1395 EXAMPLE 6 To illustrate the grouping behavior of expressions, in the following fragment
1399 a = a + 32760 + b + 5;</pre>
1400 the expression statement behaves exactly the same as
1402 a = (((a + 32760) + b) + 5);</pre>
1403 due to the associativity and precedence of these operators. Thus, the result of the sum (a + 32760) is
1404 next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in
1405 which overflows produce an explicit trap and in which the range of values representable by an int is
1406 [-32768, +32767], the implementation cannot rewrite this expression as
1408 a = ((a + b) + 32765);</pre>
1409 since if the values for a and b were, respectively, -32754 and -15, the sum a + b would produce a trap
1410 while the original expression would not; nor can the expression be rewritten either as
1411 <!--page 35 indent 5-->
1413 a = ((a + 32765) + b);</pre>
1416 a = (a + (b + 32765));</pre>
1417 since the values for a and b might have been, respectively, 4 and -8 or -17 and 12. However, on a machine
1418 in which overflow silently generates some value and where positive and negative overflows cancel, the
1419 above expression statement can be rewritten by the implementation in any of the above ways because the
1420 same result will occur.
1423 EXAMPLE 7 The grouping of an expression does not completely determine its evaluation. In the
1426 #include <stdio.h>
1430 sum = sum * 10 - '0' + (*p++ = getchar());</pre>
1431 the expression statement is grouped as if it were written as
1433 sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));</pre>
1434 but the actual increment of p can occur at any time between the previous sequence point and the next
1435 sequence point (the ;), and the call to getchar can occur at any point prior to the need of its returned
1438 Forward references: expressions (<a href="#6.5">6.5</a>), type qualifiers (<a href="#6.7.3">6.7.3</a>), statements (<a href="#6.8">6.8</a>), the
1439 signal function (<a href="#7.14">7.14</a>), files (<a href="#7.21.3">7.21.3</a>).
1442 <p><a name="note12">12)</a> The IEC 60559 standard for binary floating-point arithmetic requires certain user-accessible status
1443 flags and control modes. Floating-point operations implicitly set the status flags; modes affect result
1444 values of floating-point operations. Implementations that support such floating-point state are
1445 required to regard changes to it as side effects -- see <a href="#F">annex F</a> for details. The floating-point
1446 environment library <fenv.h> provides a programming facility for indicating when these side
1447 effects matter, freeing the implementations in other cases.
1449 <p><a name="note13">13)</a> The executions of unsequenced evaluations can interleave. Indeterminately sequenced evaluations
1450 cannot interleave, but can be executed in any order.
1453 <a name="5.1.2.4" href="#5.1.2.4"><h5>5.1.2.4 Multi-threaded executions and data races</h5></a>
1455 Under a hosted implementation, a program can have more than one thread of execution
1456 (or thread) running concurrently. The execution of each thread proceeds as defined by
1457 the remainder of this standard. The execution of the entire program consists of an
1458 execution of all of its threads.<sup><a href="#note14"><b>14)</b></a></sup> Under a freestanding implementation, it is
1459 implementation-defined whether a program can have more than one thread of execution.
1461 The value of an object visible to a thread T at a particular point is the initial value of the
1462 object, a value stored in the object by T , or a value stored in the object by another thread,
1463 according to the rules below.
1465 NOTE 1 In some cases, there may instead be undefined behavior. Much of this section is motivated by
1466 the desire to support atomic operations with explicit and detailed visibility constraints. However, it also
1467 implicitly supports a simpler view for more restricted programs.
1470 Two expression evaluations conflict if one of them modifies a memory location and the
1471 other one reads or modifies the same memory location.
1476 <!--page 36 indent 5-->
1478 The library defines a number of atomic operations (<a href="#7.17">7.17</a>) and operations on mutexes
1479 (<a href="#7.25.4">7.25.4</a>) that are specially identified as synchronization operations. These operations play
1480 a special role in making assignments in one thread visible to another. A synchronization
1481 operation on one or more memory locations is either an acquire operation, a release
1482 operation, both an acquire and release operation, or a consume operation. A
1483 synchronization operation without an associated memory location is a fence and can be
1484 either an acquire fence, a release fence, or both an acquire and release fence. In addition,
1485 there are relaxed atomic operations, which are not synchronization operations, and
1486 atomic read-modify-write operations, which have special characteristics.
1488 NOTE 2 For example, a call that acquires a mutex will perform an acquire operation on the locations
1489 composing the mutex. Correspondingly, a call that releases the same mutex will perform a release
1490 operation on those same locations. Informally, performing a release operation on A forces prior side effects
1491 on other memory locations to become visible to other threads that later perform an acquire or consume
1492 operation on A. We do not include relaxed atomic operations as synchronization operations although, like
1493 synchronization operations, they cannot contribute to data races.
1496 All modifications to a particular atomic object M occur in some particular total order,
1497 called the modification order of M. If A and B are modifications of an atomic object M,
1498 and A happens before B, then A shall precede B in the modification order of M, which is
1501 NOTE 3 This states that the modification orders must respect the ''happens before'' relation.
1504 NOTE 4 There is a separate order for each atomic object. There is no requirement that these can be
1505 combined into a single total order for all objects. In general this will be impossible since different threads
1506 may observe modifications to different variables in inconsistent orders.
1509 A release sequence on an atomic object M is a maximal contiguous sub-sequence of side
1510 effects in the modification order of M, where the first operation is a release and every
1511 subsequent operation either is performed by the same thread that performed the release or
1512 is an atomic read-modify-write operation.
1514 Certain library calls synchronize with other library calls performed by another thread. In
1515 particular, an atomic operation A that performs a release operation on an object M
1516 synchronizes with an atomic operation B that performs an acquire operation on M and
1517 reads a value written by any side effect in the release sequence headed by A.
1519 NOTE 5 Except in the specified cases, reading a later value does not necessarily ensure visibility as
1520 described below. Such a requirement would sometimes interfere with efficient implementation.
1523 NOTE 6 The specifications of the synchronization operations define when one reads the value written by
1524 another. For atomic variables, the definition is clear. All operations on a given mutex occur in a single total
1525 order. Each mutex acquisition ''reads the value written'' by the last mutex release.
1528 An evaluation A carries a dependency <sup><a href="#note15"><b>15)</b></a></sup> to an evaluation B if:
1531 <!--page 37 indent 5-->
1533 <li> the value of A is used as an operand of B, unless:
1535 <li> B is an invocation of the kill_dependency macro,
1537 <li> A is the left operand of a && or || operator,
1539 <li> A is the left operand of a ? : operator, or
1541 <li> A is the left operand of a , operator;
1544 <li> A writes a scalar object or bit-field M, B reads from M the value written by A, and A
1545 is sequenced before B, or
1546 <li> for some evaluation X, A carries a dependency to X and X carries a dependency to B.
1549 An evaluation A is dependency-ordered before<sup><a href="#note16"><b>16)</b></a></sup> an evaluation B if:
1551 <li> A performs a release operation on an atomic object M, and B performs a consume
1552 operation on M and reads a value written by any side effect in the release sequence
1554 <li> for some evaluation X, A is dependency-ordered before X and X carries a
1558 An evaluation A inter-thread happens before an evaluation B if A synchronizes with B, A
1559 is dependency-ordered before B, or, for some evaluation X:
1561 <li> A synchronizes with X and X is sequenced before B,
1562 <li> A is sequenced before X and X inter-thread happens before B, or
1563 <li> A inter-thread happens before X and X inter-thread happens before B.
1566 NOTE 7 The ''inter-thread happens before'' relation describes arbitrary concatenations of ''sequenced
1567 before'', ''synchronizes with'', and ''dependency-ordered before'' relationships, with two exceptions. The
1568 first exception is that a concatenation is not permitted to end with ''dependency-ordered before'' followed
1569 by ''sequenced before''. The reason for this limitation is that a consume operation participating in a
1570 ''dependency-ordered before'' relationship provides ordering only with respect to operations to which this
1571 consume operation actually carries a dependency. The reason that this limitation applies only to the end of
1572 such a concatenation is that any subsequent release operation will provide the required ordering for a prior
1573 consume operation. The second exception is that a concatenation is not permitted to consist entirely of
1574 ''sequenced before''. The reasons for this limitation are (1) to permit ''inter-thread happens before'' to be
1575 transitively closed and (2) the ''happens before'' relation, defined below, provides for relationships
1576 consisting entirely of ''sequenced before''.
1579 An evaluation A happens before an evaluation B if A is sequenced before B or A inter-
1580 thread happens before B.
1584 <!--page 38 indent 5-->
1586 A visible side effect A on an object M with respect to a value computation B of M
1587 satisfies the conditions:
1589 <li> A happens before B, and
1590 <li> there is no other side effect X to M such that A happens before X and X happens
1593 The value of a non-atomic scalar object M, as determined by evaluation B, shall be the
1594 value stored by the visible side effect A.
1596 NOTE 8 If there is ambiguity about which side effect to a non-atomic object is visible, then there is a data
1597 race and the behavior is undefined.
1600 NOTE 9 This states that operations on ordinary variables are not visibly reordered. This is not actually
1601 detectable without data races, but it is necessary to ensure that data races, as defined here, and with suitable
1602 restrictions on the use of atomics, correspond to data races in a simple interleaved (sequentially consistent)
1606 The visible sequence of side effects on an atomic object M, with respect to a value
1607 computation B of M, is a maximal contiguous sub-sequence of side effects in the
1608 modification order of M, where the first side effect is visible with respect to B, and for
1609 every subsequent side effect, it is not the case that B happens before it. The value of an
1610 atomic object M, as determined by evaluation B, shall be the value stored by some
1611 operation in the visible sequence of M with respect to B. Furthermore, if a value
1612 computation A of an atomic object M happens before a value computation B of M, and
1613 the value computed by A corresponds to the value stored by side effect X, then the value
1614 computed by B shall either equal the value computed by A, or be the value stored by side
1615 effect Y , where Y follows X in the modification order of M.
1617 NOTE 10 This effectively disallows compiler reordering of atomic operations to a single object, even if
1618 both operations are ''relaxed'' loads. By doing so, we effectively make the ''cache coherence'' guarantee
1619 provided by most hardware available to C atomic operations.
1622 NOTE 11 The visible sequence depends on the ''happens before'' relation, which in turn depends on the
1623 values observed by loads of atomics, which we are restricting here. The intended reading is that there must
1624 exist an association of atomic loads with modifications they observe that, together with suitably chosen
1625 modification orders and the ''happens before'' relation derived as described above, satisfy the resulting
1626 constraints as imposed here.
1629 The execution of a program contains a data race if it contains two conflicting actions in
1630 different threads, at least one of which is not atomic, and neither happens before the
1631 other. Any such data race results in undefined behavior.
1633 NOTE 12 It can be shown that programs that correctly use simple mutexes and
1634 memory_order_seq_cst operations to prevent all data races, and use no other synchronization
1635 operations, behave as though the operations executed by their constituent threads were simply interleaved,
1636 with each value computation of an object being the last value stored in that interleaving. This is normally
1637 referred to as ''sequential consistency''. However, this applies only to data-race-free programs, and data-
1638 race-free programs cannot observe most program transformations that do not change single-threaded
1639 program semantics. In fact, most single-threaded program transformations continue to be allowed, since
1640 any program that behaves differently as a result must contain undefined behavior.
1641 <!--page 39 indent 5-->
1643 NOTE 13 Compiler transformations that introduce assignments to a potentially shared memory location
1644 that would not be modified by the abstract machine are generally precluded by this standard, since such an
1645 assignment might overwrite another assignment by a different thread in cases in which an abstract machine
1646 execution would not have encountered a data race. This includes implementations of data member
1647 assignment that overwrite adjacent members in separate memory locations. We also generally preclude
1648 reordering of atomic loads in cases in which the atomics in question may alias, since this may violate the
1649 "visible sequence" rules.
1652 NOTE 14 Transformations that introduce a speculative read of a potentially shared memory location may
1653 not preserve the semantics of the program as defined in this standard, since they potentially introduce a data
1654 race. However, they are typically valid in the context of an optimizing compiler that targets a specific
1655 machine with well-defined semantics for data races. They would be invalid for a hypothetical machine that
1656 is not tolerant of races or provides hardware race detection.
1657 <!--page 40 indent 4-->
1660 <p><a name="note14">14)</a> The execution can usually be viewed as an interleaving of all of the threads. However, some kinds of
1661 atomic operations, for example, allow executions inconsistent with a simple interleaving as described
1664 <p><a name="note15">15)</a> The ''carries a dependency'' relation is a subset of the ''sequenced before'' relation, and is similarly
1665 strictly intra-thread.
1667 <p><a name="note16">16)</a> The ''dependency-ordered before'' relation is analogous to the ''synchronizes with'' relation, but uses
1668 release/consume in place of release/acquire.
1671 <a name="5.2" href="#5.2"><h3>5.2 Environmental considerations</h3></a>
1673 <a name="5.2.1" href="#5.2.1"><h4>5.2.1 Character sets</h4></a>
1675 Two sets of characters and their associated collating sequences shall be defined: the set in
1676 which source files are written (the source character set), and the set interpreted in the
1677 execution environment (the execution character set). Each set is further divided into a
1678 basic character set, whose contents are given by this subclause, and a set of zero or more
1679 locale-specific members (which are not members of the basic character set) called
1680 extended characters. The combined set is also called the extended character set. The
1681 values of the members of the execution character set are implementation-defined.
1683 In a character constant or string literal, members of the execution character set shall be
1684 represented by corresponding members of the source character set or by escape
1685 sequences consisting of the backslash \ followed by one or more characters. A byte with
1686 all bits set to 0, called the null character, shall exist in the basic execution character set; it
1687 is used to terminate a character string.
1689 Both the basic source and basic execution character sets shall have the following
1690 members: the 26 uppercase letters of the Latin alphabet
1692 A B C D E F G H I J K L M
1693 N O P Q R S T U V W X Y Z</pre>
1694 the 26 lowercase letters of the Latin alphabet
1696 a b c d e f g h i j k l m
1697 n o p q r s t u v w x y z</pre>
1698 the 10 decimal digits
1700 0 1 2 3 4 5 6 7 8 9</pre>
1701 the following 29 graphic characters
1703 ! " # % & ' ( ) * + , - . / :
1704 ; < = > ? [ \ ] ^ _ { | } ~</pre>
1705 the space character, and control characters representing horizontal tab, vertical tab, and
1706 form feed. The representation of each member of the source and execution basic
1707 character sets shall fit in a byte. In both the source and execution basic character sets, the
1708 value of each character after 0 in the above list of decimal digits shall be one greater than
1709 the value of the previous. In source files, there shall be some way of indicating the end of
1710 each line of text; this International Standard treats such an end-of-line indicator as if it
1711 were a single new-line character. In the basic execution character set, there shall be
1712 control characters representing alert, backspace, carriage return, and new line. If any
1713 other characters are encountered in a source file (except in an identifier, a character
1714 constant, a string literal, a header name, a comment, or a preprocessing token that is never
1715 <!--page 41 indent 4-->
1716 converted to a token), the behavior is undefined.
1718 A letter is an uppercase letter or a lowercase letter as defined above; in this International
1719 Standard the term does not include other characters that are letters in other alphabets.
1721 The universal character name construct provides a way to name other characters.
1722 Forward references: universal character names (<a href="#6.4.3">6.4.3</a>), character constants (<a href="#6.4.4.4">6.4.4.4</a>),
1723 preprocessing directives (<a href="#6.10">6.10</a>), string literals (<a href="#6.4.5">6.4.5</a>), comments (<a href="#6.4.9">6.4.9</a>), string (<a href="#7.1.1">7.1.1</a>).
1725 <a name="5.2.1.1" href="#5.2.1.1"><h5>5.2.1.1 Trigraph sequences</h5></a>
1727 Before any other processing takes place, each occurrence of one of the following
1728 sequences of three characters (called trigraph sequences<sup><a href="#note17"><b>17)</b></a></sup>) is replaced with the
1729 corresponding single character.
1732 ??( [ ??' ^ ??> }
1733 ??/ \ ??< { ??- ~</pre>
1734 No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listed
1735 above is not changed.
1739 ??=define arraycheck(a, b) a??(b??) ??!??! b??(a??)</pre>
1742 #define arraycheck(a, b) a[b] || b[a]</pre>
1745 EXAMPLE 2 The following source line
1747 printf("Eh???/n");</pre>
1748 becomes (after replacement of the trigraph sequence ??/)
1750 printf("Eh?\n");</pre>
1754 <p><a name="note17">17)</a> The trigraph sequences enable the input of characters that are not defined in the Invariant Code Set as
1755 described in ISO/IEC 646, which is a subset of the seven-bit US ASCII code set.
1758 <a name="5.2.1.2" href="#5.2.1.2"><h5>5.2.1.2 Multibyte characters</h5></a>
1760 The source character set may contain multibyte characters, used to represent members of
1761 the extended character set. The execution character set may also contain multibyte
1762 characters, which need not have the same encoding as for the source character set. For
1763 both character sets, the following shall hold:
1765 <li> The basic character set shall be present and each character shall be encoded as a
1767 <li> The presence, meaning, and representation of any additional members is locale-
1770 <!--page 42 indent 4-->
1771 <li> A multibyte character set may have a state-dependent encoding, wherein each
1772 sequence of multibyte characters begins in an initial shift state and enters other
1773 locale-specific shift states when specific multibyte characters are encountered in the
1774 sequence. While in the initial shift state, all single-byte characters retain their usual
1775 interpretation and do not alter the shift state. The interpretation for subsequent bytes
1776 in the sequence is a function of the current shift state.
1777 <li> A byte with all bits zero shall be interpreted as a null character independent of shift
1778 state. Such a byte shall not occur as part of any other multibyte character.
1781 For source files, the following shall hold:
1783 <li> An identifier, comment, string literal, character constant, or header name shall begin
1784 and end in the initial shift state.
1785 <li> An identifier, comment, string literal, character constant, or header name shall consist
1786 of a sequence of valid multibyte characters.
1789 <a name="5.2.2" href="#5.2.2"><h4>5.2.2 Character display semantics</h4></a>
1791 The active position is that location on a display device where the next character output by
1792 the fputc function would appear. The intent of writing a printing character (as defined
1793 by the isprint function) to a display device is to display a graphic representation of
1794 that character at the active position and then advance the active position to the next
1795 position on the current line. The direction of writing is locale-specific. If the active
1796 position is at the final position of a line (if there is one), the behavior of the display device
1799 Alphabetic escape sequences representing nongraphic characters in the execution
1800 character set are intended to produce actions on display devices as follows:
1801 \a (alert) Produces an audible or visible alert without changing the active position.
1802 \b (backspace) Moves the active position to the previous position on the current line. If
1804 the active position is at the initial position of a line, the behavior of the display
1805 device is unspecified.</pre>
1806 \f ( form feed) Moves the active position to the initial position at the start of the next
1809 \n (new line) Moves the active position to the initial position of the next line.
1810 \r (carriage return) Moves the active position to the initial position of the current line.
1811 \t (horizontal tab) Moves the active position to the next horizontal tabulation position
1813 on the current line. If the active position is at or past the last defined horizontal
1814 tabulation position, the behavior of the display device is unspecified.</pre>
1815 \v (vertical tab) Moves the active position to the initial position of the next vertical
1816 <!--page 43 indent 4-->
1819 tabulation position. If the active position is at or past the last defined vertical
1820 tabulation position, the behavior of the display device is unspecified.</pre>
1821 Each of these escape sequences shall produce a unique implementation-defined value
1822 which can be stored in a single char object. The external representations in a text file
1823 need not be identical to the internal representations, and are outside the scope of this
1824 International Standard.
1825 Forward references: the isprint function (<a href="#7.4.1.8">7.4.1.8</a>), the fputc function (<a href="#7.21.7.3">7.21.7.3</a>).
1827 <a name="5.2.3" href="#5.2.3"><h4>5.2.3 Signals and interrupts</h4></a>
1829 Functions shall be implemented such that they may be interrupted at any time by a signal,
1830 or may be called by a signal handler, or both, with no alteration to earlier, but still active,
1831 invocations' control flow (after the interruption), function return values, or objects with
1832 automatic storage duration. All such objects shall be maintained outside the function
1833 image (the instructions that compose the executable representation of a function) on a
1834 per-invocation basis.
1836 <a name="5.2.4" href="#5.2.4"><h4>5.2.4 Environmental limits</h4></a>
1838 Both the translation and execution environments constrain the implementation of
1839 language translators and libraries. The following summarizes the language-related
1840 environmental limits on a conforming implementation; the library-related limits are
1841 discussed in clause 7.
1843 <a name="5.2.4.1" href="#5.2.4.1"><h5>5.2.4.1 Translation limits</h5></a>
1845 The implementation shall be able to translate and execute at least one program that
1846 contains at least one instance of every one of the following limits:<sup><a href="#note18"><b>18)</b></a></sup>
1848 <li> 127 nesting levels of blocks
1849 <li> 63 nesting levels of conditional inclusion
1850 <li> 12 pointer, array, and function declarators (in any combinations) modifying an
1851 arithmetic, structure, union, or void type in a declaration
1852 <li> 63 nesting levels of parenthesized declarators within a full declarator
1853 <li> 63 nesting levels of parenthesized expressions within a full expression
1854 <li> 63 significant initial characters in an internal identifier or a macro name (each
1855 universal character name or extended source character is considered a single
1857 <li> 31 significant initial characters in an external identifier (each universal character name
1858 specifying a short identifier of 0000FFFF or less is considered 6 characters, each
1861 <!--page 44 indent 4-->
1863 universal character name specifying a short identifier of 00010000 or more is
1864 considered 10 characters, and each extended source character is considered the same
1865 number of characters as the corresponding universal character name, if any)<sup><a href="#note19"><b>19)</b></a></sup></pre>
1866 <li> 4095 external identifiers in one translation unit
1867 <li> 511 identifiers with block scope declared in one block
1868 <li> 4095 macro identifiers simultaneously defined in one preprocessing translation unit
1869 <li> 127 parameters in one function definition
1870 <li> 127 arguments in one function call
1871 <li> 127 parameters in one macro definition
1872 <li> 127 arguments in one macro invocation
1873 <li> 4095 characters in a logical source line
1874 <li> 4095 characters in a string literal (after concatenation)
1875 <li> 65535 bytes in an object (in a hosted environment only)
1876 <li> 15 nesting levels for #included files
1877 <li> 1023 case labels for a switch statement (excluding those for any nested switch
1879 <li> 1023 members in a single structure or union
1880 <li> 1023 enumeration constants in a single enumeration
1881 <li> 63 levels of nested structure or union definitions in a single struct-declaration-list
1885 <p><a name="note18">18)</a> Implementations should avoid imposing fixed translation limits whenever possible.
1887 <p><a name="note19">19)</a> See ''future language directions'' (<a href="#6.11.3">6.11.3</a>).
1890 <a name="5.2.4.2" href="#5.2.4.2"><h5>5.2.4.2 Numerical limits</h5></a>
1892 An implementation is required to document all the limits specified in this subclause,
1893 which are specified in the headers <limits.h> and <float.h>. Additional limits are
1894 specified in <stdint.h>.
1895 Forward references: integer types <stdint.h> (<a href="#7.20">7.20</a>).
1897 <a name="5.2.4.2.1" href="#5.2.4.2.1"><h5>5.2.4.2.1 Sizes of integer types <limits.h></h5></a>
1899 The values given below shall be replaced by constant expressions suitable for use in #if
1900 preprocessing directives. Moreover, except for CHAR_BIT and MB_LEN_MAX, the
1901 following shall be replaced by expressions that have the same type as would an
1902 expression that is an object of the corresponding type converted according to the integer
1903 promotions. Their implementation-defined values shall be equal or greater in magnitude
1906 <!--page 45 indent 0-->
1907 (absolute value) to those shown, with the same sign.
1909 <li> number of bits for smallest object that is not a bit-field (byte)
1911 <li> minimum value for an object of type signed char
1912 SCHAR_MIN -127 // -(27 - 1)
1913 <li> maximum value for an object of type signed char
1914 SCHAR_MAX +127 // 27 - 1
1915 <li> maximum value for an object of type unsigned char
1916 UCHAR_MAX 255 // 28 - 1
1917 <li> minimum value for an object of type char
1919 <li> maximum value for an object of type char
1921 <li> maximum number of bytes in a multibyte character, for any supported locale
1923 <li> minimum value for an object of type short int
1924 SHRT_MIN -32767 // -(215 - 1)
1925 <li> maximum value for an object of type short int
1926 SHRT_MAX +32767 // 215 - 1
1927 <li> maximum value for an object of type unsigned short int
1928 USHRT_MAX 65535 // 216 - 1
1929 <li> minimum value for an object of type int
1930 INT_MIN -32767 // -(215 - 1)
1931 <li> maximum value for an object of type int
1932 INT_MAX +32767 // 215 - 1
1933 <li> maximum value for an object of type unsigned int
1934 UINT_MAX 65535 // 216 - 1
1935 <li> minimum value for an object of type long int
1936 LONG_MIN -2147483647 // -(231 - 1)
1937 <li> maximum value for an object of type long int
1938 LONG_MAX +2147483647 // 231 - 1
1939 <li> maximum value for an object of type unsigned long int
1940 ULONG_MAX 4294967295 // 232 - 1
1941 <!--page 46 indent 4-->
1942 <li> minimum value for an object of type long long int
1943 LLONG_MIN -9223372036854775807 // -(263 - 1)
1944 <li> maximum value for an object of type long long int
1945 LLONG_MAX +9223372036854775807 // 263 - 1
1946 <li> maximum value for an object of type unsigned long long int
1947 ULLONG_MAX 18446744073709551615 // 264 - 1
1950 If the value of an object of type char is treated as a signed integer when used in an
1951 expression, the value of CHAR_MIN shall be the same as that of SCHAR_MIN and the
1952 value of CHAR_MAX shall be the same as that of SCHAR_MAX. Otherwise, the value of
1953 CHAR_MIN shall be 0 and the value of CHAR_MAX shall be the same as that of
1954 UCHAR_MAX.<sup><a href="#note20"><b>20)</b></a></sup> The value UCHAR_MAX shall equal 2CHAR_BIT - 1.
1955 Forward references: representations of types (<a href="#6.2.6">6.2.6</a>), conditional inclusion (<a href="#6.10.1">6.10.1</a>).
1958 <p><a name="note20">20)</a> See <a href="#6.2.5">6.2.5</a>.
1961 <a name="5.2.4.2.2" href="#5.2.4.2.2"><h5>5.2.4.2.2 Characteristics of floating types <float.h></h5></a>
1963 The characteristics of floating types are defined in terms of a model that describes a
1964 representation of floating-point numbers and values that provide information about an
1965 implementation's floating-point arithmetic.<sup><a href="#note21"><b>21)</b></a></sup> The following parameters are used to
1966 define the model for each floating-point type:
1970 b base or radix of exponent representation (an integer > 1)
1971 e exponent (an integer between a minimum emin and a maximum emax )
1972 p precision (the number of base-b digits in the significand)
1973 fk nonnegative integers less than b (the significand digits)</pre>
1974 A floating-point number (x) is defined by the following model:
1977 x = sb e (Sum) f k b-k ,
1979 emin <= e <= emax</pre>
1982 In addition to normalized floating-point numbers ( f 1 > 0 if x != 0), floating types may be
1983 able to contain other kinds of floating-point numbers, such as subnormal floating-point
1984 numbers (x != 0, e = emin , f 1 = 0) and unnormalized floating-point numbers (x != 0,
1985 e > emin , f 1 = 0), and values that are not floating-point numbers, such as infinities and
1986 NaNs. A NaN is an encoding signifying Not-a-Number. A quiet NaN propagates
1987 through almost every arithmetic operation without raising a floating-point exception; a
1988 signaling NaN generally raises a floating-point exception when occurring as an
1991 <!--page 47 indent 4-->
1992 arithmetic operand.<sup><a href="#note22"><b>22)</b></a></sup>
1994 An implementation may give zero and values that are not floating-point numbers (such as
1995 infinities and NaNs) a sign or may leave them unsigned. Wherever such values are
1996 unsigned, any requirement in this International Standard to retrieve the sign shall produce
1997 an unspecified sign, and any requirement to set the sign shall be ignored.
1999 The minimum range of representable values for a floating type is the most negative finite
2000 floating-point number representable in that type through the most positive finite floating-
2001 point number representable in that type. In addition, if negative infinity is representable
2002 in a type, the range of that type is extended to all negative real numbers; likewise, if
2003 positive infinity is representable in a type, the range of that type is extended to all positive
2006 The accuracy of the floating-point operations (+, -, *, /) and of the library functions in
2007 <math.h> and <complex.h> that return floating-point results is implementation-
2008 defined, as is the accuracy of the conversion between floating-point internal
2009 representations and string representations performed by the library functions in
2010 <stdio.h>, <stdlib.h>, and <wchar.h>. The implementation may state that the
2011 accuracy is unknown.
2013 All integer values in the <float.h> header, except FLT_ROUNDS, shall be constant
2014 expressions suitable for use in #if preprocessing directives; all floating values shall be
2015 constant expressions. All except DECIMAL_DIG, FLT_EVAL_METHOD, FLT_RADIX,
2016 and FLT_ROUNDS have separate names for all three floating-point types. The floating-
2017 point model representation is provided for all values except FLT_EVAL_METHOD and
2020 The rounding mode for floating-point addition is characterized by the implementation-
2021 defined value of FLT_ROUNDS:<sup><a href="#note23"><b>23)</b></a></sup>
2026 2 toward positive infinity
2027 3 toward negative infinity</pre>
2028 All other values for FLT_ROUNDS characterize implementation-defined rounding
2032 <!--page 48 indent 5-->
2034 Except for assignment and cast (which remove all extra range and precision), the values
2035 yielded by operators with floating operands and values subject to the usual arithmetic
2036 conversions and of floating constants are evaluated to a format whose range and precision
2037 may be greater than required by the type. The use of evaluation formats is characterized
2038 by the implementation-defined value of FLT_EVAL_METHOD:<sup><a href="#note24"><b>24)</b></a></sup>
2041 0 evaluate all operations and constants just to the range and precision of the
2043 1 evaluate operations and constants of type float and double to the
2044 range and precision of the double type, evaluate long double
2045 operations and constants to the range and precision of the long double
2047 2 evaluate all operations and constants to the range and precision of the
2048 long double type.</pre>
2049 All other negative values for FLT_EVAL_METHOD characterize implementation-defined
2052 The presence or absence of subnormal numbers is characterized by the implementation-
2053 defined values of FLT_HAS_SUBNORM, DBL_HAS_SUBNORM, and
2057 -1 indeterminable<sup><a href="#note25"><b>25)</b></a></sup>
2058 0 absent<sup><a href="#note26"><b>26)</b></a></sup> (type does not support subnormal numbers)
2059 1 present (type does support subnormal numbers)</pre>
2060 The values given in the following list shall be replaced by constant expressions with
2061 implementation-defined values that are greater or equal in magnitude (absolute value) to
2062 those shown, with the same sign:
2064 <li> radix of exponent representation, b
2070 <!--page 49 indent 0-->
2071 <li> number of base-FLT_RADIX digits in the floating-point significand, p
2075 <li> number of decimal digits, n, such that any floating-point number with p radix b digits
2076 can be rounded to a floating-point number with n decimal digits and back again
2077 without change to the value,
2079 { p log10 b if b is a power of 10
2081 { [^1 + p log10 b^] otherwise</pre>
2085 <li> number of decimal digits, n, such that any floating-point number in the widest
2086 supported floating type with pmax radix b digits can be rounded to a floating-point
2087 number with n decimal digits and back again without change to the value,
2089 { pmax log10 b if b is a power of 10
2091 { [^1 + pmax log10 b^] otherwise</pre>
2093 <li> number of decimal digits, q, such that any floating-point number with q decimal digits
2094 can be rounded into a floating-point number with p radix b digits and back again
2095 without change to the q decimal digits,
2097 { p log10 b if b is a power of 10
2099 { [_( p - 1) log10 b_] otherwise</pre>
2103 <li> minimum negative integer such that FLT_RADIX raised to one less than that power is
2104 a normalized floating-point number, emin
2108 <!--page 50 indent 5-->
2109 <li> minimum negative integer such that 10 raised to that power is in the range of
2110 normalized floating-point numbers, [^log10 b emin -1 ^]
2116 <li> maximum integer such that FLT_RADIX raised to one less than that power is a
2117 representable finite floating-point number, emax
2122 <li> maximum integer such that 10 raised to that power is in the range of representable
2123 finite floating-point numbers, [_log10 ((1 - b- p )b emax )_]
2129 LDBL_MAX_10_EXP +37</pre>
2130 The values given in the following list shall be replaced by constant expressions with
2131 implementation-defined values that are greater than or equal to those shown:
2133 <li> maximum representable finite floating-point number, (1 - b- p )b emax
2139 LDBL_MAX 1E+37</pre>
2140 The values given in the following list shall be replaced by constant expressions with
2141 implementation-defined (positive) values that are less than or equal to those shown:
2143 <li> the difference between 1 and the least value greater than 1 that is representable in the
2144 given floating point type, b1- p
2148 LDBL_EPSILON 1E-9</pre>
2149 <li> minimum normalized positive floating-point number, b emin -1
2150 <!--page 51 indent 5-->
2154 LDBL_MIN 1E-37</pre>
2155 <li> minimum positive floating-point number<sup><a href="#note27"><b>27)</b></a></sup>
2160 Recommended practice
2162 Conversion from (at least) double to decimal with DECIMAL_DIG digits and back
2163 should be the identity function.
2165 EXAMPLE 1 The following describes an artificial floating-point representation that meets the minimum
2166 requirements of this International Standard, and the appropriate values in a <float.h> header for type
2170 x = s16e (Sum) f k 16-k ,
2172 -31 <= e <= +32</pre>
2177 FLT_EPSILON 9.53674316E-07F
2181 FLT_MIN 2.93873588E-39F
2184 FLT_MAX 3.40282347E+38F
2185 FLT_MAX_10_EXP +38</pre>
2188 EXAMPLE 2 The following describes floating-point representations that also meet the requirements for
2189 single-precision and double-precision numbers in IEC 60559,<sup><a href="#note28"><b>28)</b></a></sup> and the appropriate values in a
2190 <float.h> header for types float and double:
2193 x f = s2e (Sum) f k 2-k ,
2195 -125 <= e <= +128</pre>
2199 x d = s2e (Sum) f k 2-k ,
2201 -1021 <= e <= +1024</pre>
2207 FLT_EPSILON 1.19209290E-07F // decimal constant
2208 FLT_EPSILON 0X1P-23F // hex constant
2209 FLT_DECIMAL_DIG 9</pre>
2212 <!--page 52 indent 0-->
2216 FLT_MIN 1.17549435E-38F // decimal constant
2217 FLT_MIN 0X1P-126F // hex constant
2218 FLT_TRUE_MIN 1.40129846E-45F // decimal constant
2219 FLT_TRUE_MIN 0X1P-149F // hex constant
2223 FLT_MAX 3.40282347E+38F // decimal constant
2224 FLT_MAX 0X1.fffffeP127F // hex constant
2227 DBL_EPSILON 2.2204460492503131E-16 // decimal constant
2228 DBL_EPSILON 0X1P-52 // hex constant
2232 DBL_MIN 2.2250738585072014E-308 // decimal constant
2233 DBL_MIN 0X1P-1022 // hex constant
2234 DBL_TRUE_MIN 4.9406564584124654E-324 // decimal constant
2235 DBL_TRUE_MIN 0X1P-1074 // hex constant
2239 DBL_MAX 1.7976931348623157E+308 // decimal constant
2240 DBL_MAX 0X1.fffffffffffffP1023 // hex constant
2241 DBL_MAX_10_EXP +308</pre>
2242 If a type wider than double were supported, then DECIMAL_DIG would be greater than 17. For
2243 example, if the widest type were to use the minimal-width IEC 60559 double-extended format (64 bits of
2244 precision), then DECIMAL_DIG would be 21.
2246 Forward references: conditional inclusion (<a href="#6.10.1">6.10.1</a>), complex arithmetic
2247 <complex.h> (<a href="#7.3">7.3</a>), extended multibyte and wide character utilities <wchar.h>
2248 (<a href="#7.28">7.28</a>), floating-point environment <fenv.h> (<a href="#7.6">7.6</a>), general utilities <stdlib.h>
2249 (<a href="#7.22">7.22</a>), input/output <stdio.h> (<a href="#7.21">7.21</a>), mathematics <math.h> (<a href="#7.12">7.12</a>).
2250 <!--page 53 indent 4-->
2253 <p><a name="note21">21)</a> The floating-point model is intended to clarify the description of each floating-point characteristic and
2254 does not require the floating-point arithmetic of the implementation to be identical.
2256 <p><a name="note22">22)</a> IEC 60559:1989 specifies quiet and signaling NaNs. For implementations that do not support
2257 IEC 60559:1989, the terms quiet NaN and signaling NaN are intended to apply to encodings with
2260 <p><a name="note23">23)</a> Evaluation of FLT_ROUNDS correctly reflects any execution-time change of rounding mode through
2261 the function fesetround in <fenv.h>.
2263 <p><a name="note24">24)</a> The evaluation method determines evaluation formats of expressions involving all floating types, not
2264 just real types. For example, if FLT_EVAL_METHOD is 1, then the product of two float
2265 _Complex operands is represented in the double _Complex format, and its parts are evaluated to
2268 <p><a name="note25">25)</a> Characterization as indeterminable is intended if floating-point operations do not consistently interpret
2269 subnormal representations as zero, nor as nonzero.
2271 <p><a name="note26">26)</a> Characterization as absent is intended if no floating-point operations produce subnormal results from
2272 non-subnormal inputs, even if the type format includes representations of subnormal numbers.
2274 <p><a name="note27">27)</a> If the presence or absence of subnormal numbers is indeterminable, then the value is intended to be a
2275 positive number no greater than the minimum normalized positive number for the type.
2277 <p><a name="note28">28)</a> The floating-point model in that standard sums powers of b from zero, so the values of the exponent
2278 limits are one less than shown here.
2281 <a name="6" href="#6"><h2>6. Language</h2></a>
2283 <a name="6.1" href="#6.1"><h3>6.1 Notation</h3></a>
2285 In the syntax notation used in this clause, syntactic categories (nonterminals) are
2286 indicated by italic type, and literal words and character set members (terminals) by bold
2287 type. A colon (:) following a nonterminal introduces its definition. Alternative
2288 definitions are listed on separate lines, except when prefaced by the words ''one of''. An
2289 optional symbol is indicated by the subscript ''opt'', so that
2291 { expressionopt }</pre>
2292 indicates an optional expression enclosed in braces.
2294 When syntactic categories are referred to in the main text, they are not italicized and
2295 words are separated by spaces instead of hyphens.
2297 A summary of the language syntax is given in <a href="#A">annex A</a>.
2299 <a name="6.2" href="#6.2"><h3>6.2 Concepts</h3></a>
2301 <a name="6.2.1" href="#6.2.1"><h4>6.2.1 Scopes of identifiers</h4></a>
2303 An identifier can denote an object; a function; a tag or a member of a structure, union, or
2304 enumeration; a typedef name; a label name; a macro name; or a macro parameter. The
2305 same identifier can denote different entities at different points in the program. A member
2306 of an enumeration is called an enumeration constant. Macro names and macro
2307 parameters are not considered further here, because prior to the semantic phase of
2308 program translation any occurrences of macro names in the source file are replaced by the
2309 preprocessing token sequences that constitute their macro definitions.
2311 For each different entity that an identifier designates, the identifier is visible (i.e., can be
2312 used) only within a region of program text called its scope. Different entities designated
2313 by the same identifier either have different scopes, or are in different name spaces. There
2314 are four kinds of scopes: function, file, block, and function prototype. (A function
2315 prototype is a declaration of a function that declares the types of its parameters.)
2317 A label name is the only kind of identifier that has function scope. It can be used (in a
2318 goto statement) anywhere in the function in which it appears, and is declared implicitly
2319 by its syntactic appearance (followed by a : and a statement).
2321 Every other identifier has scope determined by the placement of its declaration (in a
2322 declarator or type specifier). If the declarator or type specifier that declares the identifier
2323 appears outside of any block or list of parameters, the identifier has file scope, which
2324 terminates at the end of the translation unit. If the declarator or type specifier that
2325 declares the identifier appears inside a block or within the list of parameter declarations in
2326 a function definition, the identifier has block scope, which terminates at the end of the
2327 associated block. If the declarator or type specifier that declares the identifier appears
2328 <!--page 54 indent 4-->
2329 within the list of parameter declarations in a function prototype (not part of a function
2330 definition), the identifier has function prototype scope, which terminates at the end of the
2331 function declarator. If an identifier designates two different entities in the same name
2332 space, the scopes might overlap. If so, the scope of one entity (the inner scope) will end
2333 strictly before the scope of the other entity (the outer scope). Within the inner scope, the
2334 identifier designates the entity declared in the inner scope; the entity declared in the outer
2335 scope is hidden (and not visible) within the inner scope.
2337 Unless explicitly stated otherwise, where this International Standard uses the term
2338 ''identifier'' to refer to some entity (as opposed to the syntactic construct), it refers to the
2339 entity in the relevant name space whose declaration is visible at the point the identifier
2342 Two identifiers have the same scope if and only if their scopes terminate at the same
2345 Structure, union, and enumeration tags have scope that begins just after the appearance of
2346 the tag in a type specifier that declares the tag. Each enumeration constant has scope that
2347 begins just after the appearance of its defining enumerator in an enumerator list. Any
2348 other identifier has scope that begins just after the completion of its declarator.
2350 As a special case, a type name (which is not a declaration of an identifier) is considered to
2351 have a scope that begins just after the place within the type name where the omitted
2352 identifier would appear were it not omitted.
2353 Forward references: declarations (<a href="#6.7">6.7</a>), function calls (<a href="#6.5.2.2">6.5.2.2</a>), function definitions
2354 (<a href="#6.9.1">6.9.1</a>), identifiers (<a href="#6.4.2">6.4.2</a>), macro replacement (<a href="#6.10.3">6.10.3</a>), name spaces of identifiers (<a href="#6.2.3">6.2.3</a>),
2355 source file inclusion (<a href="#6.10.2">6.10.2</a>), statements (<a href="#6.8">6.8</a>).
2357 <a name="6.2.2" href="#6.2.2"><h4>6.2.2 Linkages of identifiers</h4></a>
2359 An identifier declared in different scopes or in the same scope more than once can be
2360 made to refer to the same object or function by a process called linkage.<sup><a href="#note29"><b>29)</b></a></sup> There are
2361 three kinds of linkage: external, internal, and none.
2363 In the set of translation units and libraries that constitutes an entire program, each
2364 declaration of a particular identifier with external linkage denotes the same object or
2365 function. Within one translation unit, each declaration of an identifier with internal
2366 linkage denotes the same object or function. Each declaration of an identifier with no
2367 linkage denotes a unique entity.
2369 If the declaration of a file scope identifier for an object or a function contains the storage-
2370 class specifier static, the identifier has internal linkage.<sup><a href="#note30"><b>30)</b></a></sup>
2374 <!--page 55 indent 4-->
2376 For an identifier declared with the storage-class specifier extern in a scope in which a
2377 prior declaration of that identifier is visible,<sup><a href="#note31"><b>31)</b></a></sup> if the prior declaration specifies internal or
2378 external linkage, the linkage of the identifier at the later declaration is the same as the
2379 linkage specified at the prior declaration. If no prior declaration is visible, or if the prior
2380 declaration specifies no linkage, then the identifier has external linkage.
2382 If the declaration of an identifier for a function has no storage-class specifier, its linkage
2383 is determined exactly as if it were declared with the storage-class specifier extern. If
2384 the declaration of an identifier for an object has file scope and no storage-class specifier,
2385 its linkage is external.
2387 The following identifiers have no linkage: an identifier declared to be anything other than
2388 an object or a function; an identifier declared to be a function parameter; a block scope
2389 identifier for an object declared without the storage-class specifier extern.
2391 If, within a translation unit, the same identifier appears with both internal and external
2392 linkage, the behavior is undefined.
2393 Forward references: declarations (<a href="#6.7">6.7</a>), expressions (<a href="#6.5">6.5</a>), external definitions (<a href="#6.9">6.9</a>),
2394 statements (<a href="#6.8">6.8</a>).
2397 <p><a name="note29">29)</a> There is no linkage between different identifiers.
2399 <p><a name="note30">30)</a> A function declaration can contain the storage-class specifier static only if it is at file scope; see
2400 <a href="#6.7.1">6.7.1</a>.
2402 <p><a name="note31">31)</a> As specified in <a href="#6.2.1">6.2.1</a>, the later declaration might hide the prior declaration.
2405 <a name="6.2.3" href="#6.2.3"><h4>6.2.3 Name spaces of identifiers</h4></a>
2407 If more than one declaration of a particular identifier is visible at any point in a
2408 translation unit, the syntactic context disambiguates uses that refer to different entities.
2409 Thus, there are separate name spaces for various categories of identifiers, as follows:
2411 <li> label names (disambiguated by the syntax of the label declaration and use);
2412 <li> the tags of structures, unions, and enumerations (disambiguated by following any<sup><a href="#note32"><b>32)</b></a></sup>
2413 of the keywords struct, union, or enum);
2414 <li> the members of structures or unions; each structure or union has a separate name
2415 space for its members (disambiguated by the type of the expression used to access the
2416 member via the . or -> operator);
2417 <li> all other identifiers, called ordinary identifiers (declared in ordinary declarators or as
2418 enumeration constants).
2420 Forward references: enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>), labeled statements (<a href="#6.8.1">6.8.1</a>),
2421 structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), structure and union members (<a href="#6.5.2.3">6.5.2.3</a>), tags
2422 (<a href="#6.7.2.3">6.7.2.3</a>), the goto statement (<a href="#6.8.6.1">6.8.6.1</a>).
2424 <!--page 56 indent 4-->
2427 <p><a name="note32">32)</a> There is only one name space for tags even though three are possible.
2430 <a name="6.2.4" href="#6.2.4"><h4>6.2.4 Storage durations of objects</h4></a>
2432 An object has a storage duration that determines its lifetime. There are four storage
2433 durations: static, thread, automatic, and allocated. Allocated storage is described in
2434 <a href="#7.22.3">7.22.3</a>.
2436 The lifetime of an object is the portion of program execution during which storage is
2437 guaranteed to be reserved for it. An object exists, has a constant address,<sup><a href="#note33"><b>33)</b></a></sup> and retains
2438 its last-stored value throughout its lifetime.<sup><a href="#note34"><b>34)</b></a></sup> If an object is referred to outside of its
2439 lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when
2440 the object it points to (or just past) reaches the end of its lifetime.
2442 An object whose identifier is declared without the storage-class specifier
2443 _Thread_local, and either with external or internal linkage or with the storage-class
2444 specifier static, has static storage duration. Its lifetime is the entire execution of the
2445 program and its stored value is initialized only once, prior to program startup.
2447 An object whose identifier is declared with the storage-class specifier _Thread_local
2448 has thread storage duration. Its lifetime is the entire execution of the thread for which it
2449 is created, and its stored value is initialized when the thread is started. There is a distinct
2450 object per thread, and use of the declared name in an expression refers to the object
2451 associated with the thread evaluating the expression. The result of attempting to
2452 indirectly access an object with thread storage duration from a thread other than the one
2453 with which the object is associated is implementation-defined.
2455 An object whose identifier is declared with no linkage and without the storage-class
2456 specifier static has automatic storage duration, as do some compound literals. The
2457 result of attempting to indirectly access an object with automatic storage duration from a
2458 thread other than the one with which the object is associated is implementation-defined.
2460 For such an object that does not have a variable length array type, its lifetime extends
2461 from entry into the block with which it is associated until execution of that block ends in
2462 any way. (Entering an enclosed block or calling a function suspends, but does not end,
2463 execution of the current block.) If the block is entered recursively, a new instance of the
2464 object is created each time. The initial value of the object is indeterminate. If an
2465 initialization is specified for the object, it is performed each time the declaration or
2466 compound literal is reached in the execution of the block; otherwise, the value becomes
2467 indeterminate each time the declaration is reached.
2471 <!--page 57 indent 4-->
2473 For such an object that does have a variable length array type, its lifetime extends from
2474 the declaration of the object until execution of the program leaves the scope of the
2475 declaration.<sup><a href="#note35"><b>35)</b></a></sup> If the scope is entered recursively, a new instance of the object is created
2476 each time. The initial value of the object is indeterminate.
2478 A non-lvalue expression with structure or union type, where the structure or union
2479 contains a member with array type (including, recursively, members of all contained
2480 structures and unions) refers to an object with automatic storage duration and temporary
2481 lifetime.<sup><a href="#note36"><b>36)</b></a></sup> Its lifetime begins when the expression is evaluated and its initial value is the
2482 value of the expression. Its lifetime ends when the evaluation of the containing full
2483 expression or full declarator ends. Any attempt to modify an object with temporary
2484 lifetime results in undefined behavior.
2485 Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), compound literals (<a href="#6.5.2.5">6.5.2.5</a>), declarators
2486 (<a href="#6.7.6">6.7.6</a>), function calls (<a href="#6.5.2.2">6.5.2.2</a>), initialization (<a href="#6.7.9">6.7.9</a>), statements (<a href="#6.8">6.8</a>).
2489 <p><a name="note33">33)</a> The term ''constant address'' means that two pointers to the object constructed at possibly different
2490 times will compare equal. The address may be different during two different executions of the same
2493 <p><a name="note34">34)</a> In the case of a volatile object, the last store need not be explicit in the program.
2495 <p><a name="note35">35)</a> Leaving the innermost block containing the declaration, or jumping to a point in that block or an
2496 embedded block prior to the declaration, leaves the scope of the declaration.
2498 <p><a name="note36">36)</a> The address of such an object is taken implicitly when an array member is accessed.
2501 <a name="6.2.5" href="#6.2.5"><h4>6.2.5 Types</h4></a>
2503 The meaning of a value stored in an object or returned by a function is determined by the
2504 type of the expression used to access it. (An identifier declared to be an object is the
2505 simplest such expression; the type is specified in the declaration of the identifier.) Types
2506 are partitioned into object types (types that describe objects) and function types (types
2507 that describe functions). At various points within a translation unit an object type may be
2508 incomplete (lacking sufficient information to determine the size of objects of that type) or
2509 complete (having sufficient information).<sup><a href="#note37"><b>37)</b></a></sup>
2511 An object declared as type _Bool is large enough to store the values 0 and 1.
2513 An object declared as type char is large enough to store any member of the basic
2514 execution character set. If a member of the basic execution character set is stored in a
2515 char object, its value is guaranteed to be nonnegative. If any other character is stored in
2516 a char object, the resulting value is implementation-defined but shall be within the range
2517 of values that can be represented in that type.
2519 There are five standard signed integer types, designated as signed char, short
2520 int, int, long int, and long long int. (These and other types may be
2521 designated in several additional ways, as described in <a href="#6.7.2">6.7.2</a>.) There may also be
2522 implementation-defined extended signed integer types.<sup><a href="#note38"><b>38)</b></a></sup> The standard and extended
2523 signed integer types are collectively called signed integer types.<sup><a href="#note39"><b>39)</b></a></sup>
2525 <!--page 58 indent 5-->
2527 An object declared as type signed char occupies the same amount of storage as a
2528 ''plain'' char object. A ''plain'' int object has the natural size suggested by the
2529 architecture of the execution environment (large enough to contain any value in the range
2530 INT_MIN to INT_MAX as defined in the header <limits.h>).
2532 For each of the signed integer types, there is a corresponding (but different) unsigned
2533 integer type (designated with the keyword unsigned) that uses the same amount of
2534 storage (including sign information) and has the same alignment requirements. The type
2535 _Bool and the unsigned integer types that correspond to the standard signed integer
2536 types are the standard unsigned integer types. The unsigned integer types that
2537 correspond to the extended signed integer types are the extended unsigned integer types.
2538 The standard and extended unsigned integer types are collectively called unsigned integer
2539 types.<sup><a href="#note40"><b>40)</b></a></sup>
2541 The standard signed integer types and standard unsigned integer types are collectively
2542 called the standard integer types, the extended signed integer types and extended
2543 unsigned integer types are collectively called the extended integer types.
2545 For any two integer types with the same signedness and different integer conversion rank
2546 (see <a href="#6.3.1.1">6.3.1.1</a>), the range of values of the type with smaller integer conversion rank is a
2547 subrange of the values of the other type.
2549 The range of nonnegative values of a signed integer type is a subrange of the
2550 corresponding unsigned integer type, and the representation of the same value in each
2551 type is the same.<sup><a href="#note41"><b>41)</b></a></sup> A computation involving unsigned operands can never overflow,
2552 because a result that cannot be represented by the resulting unsigned integer type is
2553 reduced modulo the number that is one greater than the largest value that can be
2554 represented by the resulting type.
2556 There are three real floating types, designated as float, double, and long
2557 double.<sup><a href="#note42"><b>42)</b></a></sup> The set of values of the type float is a subset of the set of values of the
2558 type double; the set of values of the type double is a subset of the set of values of the
2562 <!--page 59 indent 5-->
2564 There are three complex types, designated as float _Complex, double
2565 _Complex, and long double _Complex.<sup><a href="#note43"><b>43)</b></a></sup> (Complex types are a conditional
2566 feature that implementations need not support; see <a href="#6.10.8.3">6.10.8.3</a>.) The real floating and
2567 complex types are collectively called the floating types.
2569 For each floating type there is a corresponding real type, which is always a real floating
2570 type. For real floating types, it is the same type. For complex types, it is the type given
2571 by deleting the keyword _Complex from the type name.
2573 Each complex type has the same representation and alignment requirements as an array
2574 type containing exactly two elements of the corresponding real type; the first element is
2575 equal to the real part, and the second element to the imaginary part, of the complex
2578 The type char, the signed and unsigned integer types, and the floating types are
2579 collectively called the basic types. The basic types are complete object types. Even if the
2580 implementation defines two or more basic types to have the same representation, they are
2581 nevertheless different types.<sup><a href="#note44"><b>44)</b></a></sup>
2583 The three types char, signed char, and unsigned char are collectively called
2584 the character types. The implementation shall define char to have the same range,
2585 representation, and behavior as either signed char or unsigned char.<sup><a href="#note45"><b>45)</b></a></sup>
2587 An enumeration comprises a set of named integer constant values. Each distinct
2588 enumeration constitutes a different enumerated type.
2590 The type char, the signed and unsigned integer types, and the enumerated types are
2591 collectively called integer types. The integer and real floating types are collectively called
2594 Integer and floating types are collectively called arithmetic types. Each arithmetic type
2595 belongs to one type domain: the real type domain comprises the real types, the complex
2596 type domain comprises the complex types.
2598 The void type comprises an empty set of values; it is an incomplete object type that
2599 cannot be completed.
2603 <!--page 60 indent 5-->
2605 Any number of derived types can be constructed from the object and function types, as
2608 <li> An array type describes a contiguously allocated nonempty set of objects with a
2609 particular member object type, called the element type. The element type shall be
2610 complete whenever the array type is specified. Array types are characterized by their
2611 element type and by the number of elements in the array. An array type is said to be
2612 derived from its element type, and if its element type is T , the array type is sometimes
2613 called ''array of T ''. The construction of an array type from an element type is called
2614 ''array type derivation''.
2615 <li> A structure type describes a sequentially allocated nonempty set of member objects
2616 (and, in certain circumstances, an incomplete array), each of which has an optionally
2617 specified name and possibly distinct type.
2618 <li> A union type describes an overlapping nonempty set of member objects, each of
2619 which has an optionally specified name and possibly distinct type.
2620 <li> A function type describes a function with specified return type. A function type is
2621 characterized by its return type and the number and types of its parameters. A
2622 function type is said to be derived from its return type, and if its return type is T , the
2623 function type is sometimes called ''function returning T ''. The construction of a
2624 function type from a return type is called ''function type derivation''.
2625 <li> A pointer type may be derived from a function type or an object type, called the
2626 referenced type. A pointer type describes an object whose value provides a reference
2627 to an entity of the referenced type. A pointer type derived from the referenced type T
2628 is sometimes called ''pointer to T ''. The construction of a pointer type from a
2629 referenced type is called ''pointer type derivation''. A pointer type is a complete
2631 <li> An atomic type describes the type designated by the construct _Atomic ( type-
2632 name ). (Atomic types are a conditional feature that implementations need not
2633 support; see <a href="#6.10.8.3">6.10.8.3</a>.)
2635 These methods of constructing derived types can be applied recursively.
2637 Arithmetic types and pointer types are collectively called scalar types. Array and
2638 structure types are collectively called aggregate types.<sup><a href="#note46"><b>46)</b></a></sup>
2640 An array type of unknown size is an incomplete type. It is completed, for an identifier of
2641 that type, by specifying the size in a later declaration (with internal or external linkage).
2642 A structure or union type of unknown content (as described in <a href="#6.7.2.3">6.7.2.3</a>) is an incomplete
2645 <!--page 61 indent 5-->
2646 type. It is completed, for all declarations of that type, by declaring the same structure or
2647 union tag with its defining content later in the same scope.
2649 A type has known constant size if the type is not incomplete and is not a variable length
2652 Array, function, and pointer types are collectively called derived declarator types. A
2653 declarator type derivation from a type T is the construction of a derived declarator type
2654 from T by the application of an array-type, a function-type, or a pointer-type derivation to
2657 A type is characterized by its type category, which is either the outermost derivation of a
2658 derived type (as noted above in the construction of derived types), or the type itself if the
2659 type consists of no derived types.
2661 Any type so far mentioned is an unqualified type. Each unqualified type has several
2662 qualified versions of its type,<sup><a href="#note47"><b>47)</b></a></sup> corresponding to the combinations of one, two, or all
2663 three of the const, volatile, and restrict qualifiers. The qualified or unqualified
2664 versions of a type are distinct types that belong to the same type category and have the
2665 same representation and alignment requirements.<sup><a href="#note48"><b>48)</b></a></sup> A derived type is not qualified by the
2666 qualifiers (if any) of the type from which it is derived.
2668 Further, there is the _Atomic qualifier. The presence of the _Atomic qualifier
2669 designates an atomic type. The size, representation, and alignment of an atomic type
2670 need not be the same as those of the corresponding unqualified type. Therefore, this
2671 Standard explicitly uses the phrase ''atomic, qualified or unqualified type'' whenever the
2672 atomic version of a type is permitted along with the other qualified versions of a type.
2673 The phrase ''qualified or unqualified type'', without specific mention of atomic, does not
2674 include the atomic types.
2676 A pointer to void shall have the same representation and alignment requirements as a
2677 pointer to a character type.48) Similarly, pointers to qualified or unqualified versions of
2678 compatible types shall have the same representation and alignment requirements. All
2679 pointers to structure types shall have the same representation and alignment requirements
2680 as each other. All pointers to union types shall have the same representation and
2681 alignment requirements as each other. Pointers to other types need not have the same
2682 representation or alignment requirements.
2684 EXAMPLE 1 The type designated as ''float *'' has type ''pointer to float''. Its type category is
2685 pointer, not a floating type. The const-qualified version of this type is designated as ''float * const''
2686 whereas the type designated as ''const float *'' is not a qualified type -- its type is ''pointer to const-
2689 <!--page 62 indent 5-->
2690 qualified float'' and is a pointer to a qualified type.
2693 EXAMPLE 2 The type designated as ''struct tag (*[5])(float)'' has type ''array of pointer to
2694 function returning struct tag''. The array has length five and the function has a single parameter of type
2695 float. Its type category is array.
2697 Forward references: compatible type and composite type (<a href="#6.2.7">6.2.7</a>), declarations (<a href="#6.7">6.7</a>).
2700 <p><a name="note37">37)</a> A type may be incomplete or complete throughout an entire translation unit, or it may change states at
2701 different points within a translation unit.
2703 <p><a name="note38">38)</a> Implementation-defined keywords shall have the form of an identifier reserved for any use as
2704 described in <a href="#7.1.3">7.1.3</a>.
2706 <p><a name="note39">39)</a> Therefore, any statement in this Standard about signed integer types also applies to the extended
2707 signed integer types.
2709 <p><a name="note40">40)</a> Therefore, any statement in this Standard about unsigned integer types also applies to the extended
2710 unsigned integer types.
2712 <p><a name="note41">41)</a> The same representation and alignment requirements are meant to imply interchangeability as
2713 arguments to functions, return values from functions, and members of unions.
2715 <p><a name="note42">42)</a> See ''future language directions'' (<a href="#6.11.1">6.11.1</a>).
2717 <p><a name="note43">43)</a> A specification for imaginary types is in <a href="#G">annex G</a>.
2719 <p><a name="note44">44)</a> An implementation may define new keywords that provide alternative ways to designate a basic (or
2720 any other) type; this does not violate the requirement that all basic types be different.
2721 Implementation-defined keywords shall have the form of an identifier reserved for any use as
2722 described in <a href="#7.1.3">7.1.3</a>.
2724 <p><a name="note45">45)</a> CHAR_MIN, defined in <limits.h>, will have one of the values 0 or SCHAR_MIN, and this can be
2725 used to distinguish the two options. Irrespective of the choice made, char is a separate type from the
2726 other two and is not compatible with either.
2728 <p><a name="note46">46)</a> Note that aggregate type does not include union type because an object with union type can only
2729 contain one member at a time.
2731 <p><a name="note47">47)</a> See <a href="#6.7.3">6.7.3</a> regarding qualified array and function types.
2733 <p><a name="note48">48)</a> The same representation and alignment requirements are meant to imply interchangeability as
2734 arguments to functions, return values from functions, and members of unions.
2737 <a name="6.2.6" href="#6.2.6"><h4>6.2.6 Representations of types</h4></a>
2739 <a name="6.2.6.1" href="#6.2.6.1"><h5>6.2.6.1 General</h5></a>
2741 The representations of all types are unspecified except as stated in this subclause.
2743 Except for bit-fields, objects are composed of contiguous sequences of one or more bytes,
2744 the number, order, and encoding of which are either explicitly specified or
2745 implementation-defined.
2747 Values stored in unsigned bit-fields and objects of type unsigned char shall be
2748 represented using a pure binary notation.<sup><a href="#note49"><b>49)</b></a></sup>
2750 Values stored in non-bit-field objects of any other object type consist of n x CHAR_BIT
2751 bits, where n is the size of an object of that type, in bytes. The value may be copied into
2752 an object of type unsigned char [n] (e.g., by memcpy); the resulting set of bytes is
2753 called the object representation of the value. Values stored in bit-fields consist of m bits,
2754 where m is the size specified for the bit-field. The object representation is the set of m
2755 bits the bit-field comprises in the addressable storage unit holding it. Two values (other
2756 than NaNs) with the same object representation compare equal, but values that compare
2757 equal may have different object representations.
2759 Certain object representations need not represent a value of the object type. If the stored
2760 value of an object has such a representation and is read by an lvalue expression that does
2761 not have character type, the behavior is undefined. If such a representation is produced
2762 by a side effect that modifies all or any part of the object by an lvalue expression that
2763 does not have character type, the behavior is undefined.<sup><a href="#note50"><b>50)</b></a></sup> Such a representation is called
2764 a trap representation.
2766 When a value is stored in an object of structure or union type, including in a member
2767 object, the bytes of the object representation that correspond to any padding bytes take
2768 unspecified values.<sup><a href="#note51"><b>51)</b></a></sup> The value of a structure or union object is never a trap
2771 <!--page 63 indent 4-->
2772 representation, even though the value of a member of the structure or union object may be
2773 a trap representation.
2775 When a value is stored in a member of an object of union type, the bytes of the object
2776 representation that do not correspond to that member but do correspond to other members
2777 take unspecified values.
2779 Where an operator is applied to a value that has more than one object representation,
2780 which object representation is used shall not affect the value of the result.<sup><a href="#note52"><b>52)</b></a></sup> Where a
2781 value is stored in an object using a type that has more than one object representation for
2782 that value, it is unspecified which representation is used, but a trap representation shall
2785 Loads and stores of objects with atomic types are done with
2786 memory_order_seq_cst semantics.
2787 Forward references: declarations (<a href="#6.7">6.7</a>), expressions (<a href="#6.5">6.5</a>), lvalues, arrays, and function
2788 designators (<a href="#6.3.2.1">6.3.2.1</a>), order and consistency (<a href="#7.17.3">7.17.3</a>).
2791 <p><a name="note49">49)</a> A positional representation for integers that uses the binary digits 0 and 1, in which the values
2792 represented by successive bits are additive, begin with 1, and are multiplied by successive integral
2793 powers of 2, except perhaps the bit with the highest position. (Adapted from the American National
2794 Dictionary for Information Processing Systems.) A byte contains CHAR_BIT bits, and the values of
2795 type unsigned char range from 0 to 2
2801 <p><a name="note50">50)</a> Thus, an automatic variable can be initialized to a trap representation without causing undefined
2802 behavior, but the value of the variable cannot be used until a proper value is stored in it.
2804 <p><a name="note51">51)</a> Thus, for example, structure assignment need not copy any padding bits.
2806 <p><a name="note52">52)</a> It is possible for objects x and y with the same effective type T to have the same value when they are
2807 accessed as objects of type T, but to have different values in other contexts. In particular, if == is
2808 defined for type T, then x == y does not imply that memcmp(&x, &y, sizeof (T)) == 0.
2809 Furthermore, x == y does not necessarily imply that x and y have the same value; other operations
2810 on values of type T may distinguish between them.
2813 <a name="6.2.6.2" href="#6.2.6.2"><h5>6.2.6.2 Integer types</h5></a>
2815 For unsigned integer types other than unsigned char, the bits of the object
2816 representation shall be divided into two groups: value bits and padding bits (there need
2817 not be any of the latter). If there are N value bits, each bit shall represent a different
2818 power of 2 between 1 and 2 N -1 , so that objects of that type shall be capable of
2819 representing values from 0 to 2 N - 1 using a pure binary representation; this shall be
2820 known as the value representation. The values of any padding bits are unspecified.<sup><a href="#note53"><b>53)</b></a></sup>
2822 For signed integer types, the bits of the object representation shall be divided into three
2823 groups: value bits, padding bits, and the sign bit. There need not be any padding bits;
2824 signed char shall not have any padding bits. There shall be exactly one sign bit.
2825 Each bit that is a value bit shall have the same value as the same bit in the object
2826 representation of the corresponding unsigned type (if there are M value bits in the signed
2827 type and N in the unsigned type, then M <= N ). If the sign bit is zero, it shall not affect
2829 <!--page 64 indent 4-->
2830 the resulting value. If the sign bit is one, the value shall be modified in one of the
2833 <li> the corresponding value with sign bit 0 is negated (sign and magnitude);
2834 <li> the sign bit has the value -(2 M ) (two's complement);
2835 <li> the sign bit has the value -(2 M - 1) (ones' complement).
2837 Which of these applies is implementation-defined, as is whether the value with sign bit 1
2838 and all value bits zero (for the first two), or with sign bit and all value bits 1 (for ones'
2839 complement), is a trap representation or a normal value. In the case of sign and
2840 magnitude and ones' complement, if this representation is a normal value it is called a
2843 If the implementation supports negative zeros, they shall be generated only by:
2845 <li> the &, |, ^, ~, <<, and >> operators with operands that produce such a value;
2846 <li> the +, -, *, /, and % operators where one operand is a negative zero and the result is
2848 <li> compound assignment operators based on the above cases.
2850 It is unspecified whether these cases actually generate a negative zero or a normal zero,
2851 and whether a negative zero becomes a normal zero when stored in an object.
2853 If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<,
2854 and >> operators with operands that would produce such a value is undefined.
2856 The values of any padding bits are unspecified.<sup><a href="#note54"><b>54)</b></a></sup> A valid (non-trap) object representation
2857 of a signed integer type where the sign bit is zero is a valid object representation of the
2858 corresponding unsigned type, and shall represent the same value. For any integer type,
2859 the object representation where all the bits are zero shall be a representation of the value
2862 The precision of an integer type is the number of bits it uses to represent values,
2863 excluding any sign and padding bits. The width of an integer type is the same but
2864 including any sign bit; thus for unsigned integer types the two values are the same, while
2865 for signed integer types the width is one greater than the precision.
2870 <!--page 65 indent 4-->
2873 <p><a name="note53">53)</a> Some combinations of padding bits might generate trap representations, for example, if one padding
2874 bit is a parity bit. Regardless, no arithmetic operation on valid values can generate a trap
2875 representation other than as part of an exceptional condition such as an overflow, and this cannot occur
2876 with unsigned types. All other combinations of padding bits are alternative object representations of
2877 the value specified by the value bits.
2879 <p><a name="note54">54)</a> Some combinations of padding bits might generate trap representations, for example, if one padding
2880 bit is a parity bit. Regardless, no arithmetic operation on valid values can generate a trap
2881 representation other than as part of an exceptional condition such as an overflow. All other
2882 combinations of padding bits are alternative object representations of the value specified by the value
2886 <a name="6.2.7" href="#6.2.7"><h4>6.2.7 Compatible type and composite type</h4></a>
2888 Two types have compatible type if their types are the same. Additional rules for
2889 determining whether two types are compatible are described in <a href="#6.7.2">6.7.2</a> for type specifiers,
2890 in <a href="#6.7.3">6.7.3</a> for type qualifiers, and in <a href="#6.7.6">6.7.6</a> for declarators.<sup><a href="#note55"><b>55)</b></a></sup> Moreover, two structure,
2891 union, or enumerated types declared in separate translation units are compatible if their
2892 tags and members satisfy the following requirements: If one is declared with a tag, the
2893 other shall be declared with the same tag. If both are completed anywhere within their
2894 respective translation units, then the following additional requirements apply: there shall
2895 be a one-to-one correspondence between their members such that each pair of
2896 corresponding members are declared with compatible types; if one member of the pair is
2897 declared with an alignment specifier, the other is declared with an equivalent alignment
2898 specifier; and if one member of the pair is declared with a name, the other is declared
2899 with the same name. For two structures, corresponding members shall be declared in the
2900 same order. For two structures or unions, corresponding bit-fields shall have the same
2901 widths. For two enumerations, corresponding members shall have the same values.
2903 All declarations that refer to the same object or function shall have compatible type;
2904 otherwise, the behavior is undefined.
2906 A composite type can be constructed from two types that are compatible; it is a type that
2907 is compatible with both of the two types and satisfies the following conditions:
2909 <li> If both types are array types, the following rules are applied:
2911 <li> If one type is an array of known constant size, the composite type is an array of
2913 <li> Otherwise, if one type is a variable length array whose size is specified by an
2914 expression that is not evaluated, the behavior is undefined.
2915 <li> Otherwise, if one type is a variable length array whose size is specified, the
2916 composite type is a variable length array of that size.
2917 <li> Otherwise, if one type is a variable length array of unspecified size, the composite
2918 type is a variable length array of unspecified size.
2919 <li> Otherwise, both types are arrays of unknown size and the composite type is an
2920 array of unknown size.
2922 The element type of the composite type is the composite type of the two element
2924 <li> If only one type is a function type with a parameter type list (a function prototype),
2925 the composite type is a function prototype with the parameter type list.
2928 <!--page 66 indent 4-->
2929 <li> If both types are function types with parameter type lists, the type of each parameter
2930 in the composite parameter type list is the composite type of the corresponding
2933 These rules apply recursively to the types from which the two types are derived.
2935 For an identifier with internal or external linkage declared in a scope in which a prior
2936 declaration of that identifier is visible,<sup><a href="#note56"><b>56)</b></a></sup> if the prior declaration specifies internal or
2937 external linkage, the type of the identifier at the later declaration becomes the composite
2939 Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>).
2941 EXAMPLE Given the following two file scope declarations:
2943 int f(int (*)(), double (*)[3]);
2944 int f(int (*)(char *), double (*)[]);</pre>
2945 The resulting composite type for the function is:
2947 int f(int (*)(char *), double (*)[3]);</pre>
2951 <p><a name="note55">55)</a> Two types need not be identical to be compatible.
2953 <p><a name="note56">56)</a> As specified in <a href="#6.2.1">6.2.1</a>, the later declaration might hide the prior declaration.
2956 <a name="6.2.8" href="#6.2.8"><h4>6.2.8 Alignment of objects</h4></a>
2958 Complete object types have alignment requirements which place restrictions on the
2959 addresses at which objects of that type may be allocated. An alignment is an
2960 implementation-defined integer value representing the number of bytes between
2961 successive addresses at which a given object can be allocated. An object type imposes an
2962 alignment requirement on every object of that type: stricter alignment can be requested
2963 using the _Alignas keyword.
2965 A fundamental alignment is represented by an alignment less than or equal to the greatest
2966 alignment supported by the implementation in all contexts, which is equal to
2967 alignof(max_align_t).
2969 An extended alignment is represented by an alignment greater than
2970 alignof(max_align_t). It is implementation-defined whether any extended
2971 alignments are supported and the contexts in which they are supported. A type having an
2972 extended alignment requirement is an over-aligned type.<sup><a href="#note57"><b>57)</b></a></sup>
2974 Alignments are represented as values of the type size_t. Valid alignments include only
2975 those values returned by an alignof expression for fundamental types, plus an
2976 additional implementation-defined set of values, which may be empty. Every valid
2977 alignment value shall be a nonnegative integral power of two.
2980 <!--page 67 indent 4-->
2982 Alignments have an order from weaker to stronger or stricter alignments. Stricter
2983 alignments have larger alignment values. An address that satisfies an alignment
2984 requirement also satisfies any weaker valid alignment requirement.
2986 The alignment requirement of a complete type can be queried using an alignof
2987 expression. The types char, signed char, and unsigned char shall have the
2988 weakest alignment requirement.
2990 Comparing alignments is meaningful and provides the obvious results:
2992 <li> Two alignments are equal when their numeric values are equal.
2993 <li> Two alignments are different when their numeric values are not equal.
2994 <li> When an alignment is larger than another it represents a stricter alignment.
2995 <!--page 68 indent 4-->
2999 <p><a name="note57">57)</a> Every over-aligned type is, or contains, a structure or union type with a member to which an extended
3000 alignment has been applied.
3003 <a name="6.3" href="#6.3"><h3>6.3 Conversions</h3></a>
3005 Several operators convert operand values from one type to another automatically. This
3006 subclause specifies the result required from such an implicit conversion, as well as those
3007 that result from a cast operation (an explicit conversion). The list in <a href="#6.3.1.8">6.3.1.8</a> summarizes
3008 the conversions performed by most ordinary operators; it is supplemented as required by
3009 the discussion of each operator in <a href="#6.5">6.5</a>.
3011 Conversion of an operand value to a compatible type causes no change to the value or the
3013 Forward references: cast operators (<a href="#6.5.4">6.5.4</a>).
3015 <a name="6.3.1" href="#6.3.1"><h4>6.3.1 Arithmetic operands</h4></a>
3017 <a name="6.3.1.1" href="#6.3.1.1"><h5>6.3.1.1 Boolean, characters, and integers</h5></a>
3019 Every integer type has an integer conversion rank defined as follows:
3021 <li> No two signed integer types shall have the same rank, even if they have the same
3023 <li> The rank of a signed integer type shall be greater than the rank of any signed integer
3024 type with less precision.
3025 <li> The rank of long long int shall be greater than the rank of long int, which
3026 shall be greater than the rank of int, which shall be greater than the rank of short
3027 int, which shall be greater than the rank of signed char.
3028 <li> The rank of any unsigned integer type shall equal the rank of the corresponding
3029 signed integer type, if any.
3030 <li> The rank of any standard integer type shall be greater than the rank of any extended
3031 integer type with the same width.
3032 <li> The rank of char shall equal the rank of signed char and unsigned char.
3033 <li> The rank of _Bool shall be less than the rank of all other standard integer types.
3034 <li> The rank of any enumerated type shall equal the rank of the compatible integer type
3035 (see <a href="#6.7.2.2">6.7.2.2</a>).
3036 <li> The rank of any extended signed integer type relative to another extended signed
3037 integer type with the same precision is implementation-defined, but still subject to the
3038 other rules for determining the integer conversion rank.
3039 <li> For all integer types T1, T2, and T3, if T1 has greater rank than T2 and T2 has
3040 greater rank than T3, then T1 has greater rank than T3.
3043 The following may be used in an expression wherever an int or unsigned int may
3045 <!--page 69 indent 4-->
3047 <li> An object or expression with an integer type (other than int or unsigned int)
3048 whose integer conversion rank is less than or equal to the rank of int and
3050 <li> A bit-field of type _Bool, int, signed int, or unsigned int.
3052 If an int can represent all values of the original type (as restricted by the width, for a
3053 bit-field), the value is converted to an int; otherwise, it is converted to an unsigned
3054 int. These are called the integer promotions.<sup><a href="#note58"><b>58)</b></a></sup> All other types are unchanged by the
3057 The integer promotions preserve value including sign. As discussed earlier, whether a
3058 ''plain'' char is treated as signed is implementation-defined.
3059 Forward references: enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>), structure and union specifiers
3060 (<a href="#6.7.2.1">6.7.2.1</a>).
3063 <p><a name="note58">58)</a> The integer promotions are applied only: as part of the usual arithmetic conversions, to certain
3064 argument expressions, to the operands of the unary +, -, and ~ operators, and to both operands of the
3065 shift operators, as specified by their respective subclauses.
3068 <a name="6.3.1.2" href="#6.3.1.2"><h5>6.3.1.2 Boolean type</h5></a>
3070 When any scalar value is converted to _Bool, the result is 0 if the value compares equal
3071 to 0; otherwise, the result is 1.<sup><a href="#note59"><b>59)</b></a></sup>
3074 <p><a name="note59">59)</a> NaNs do not compare equal to 0 and thus convert to 1.
3077 <a name="6.3.1.3" href="#6.3.1.3"><h5>6.3.1.3 Signed and unsigned integers</h5></a>
3079 When a value with integer type is converted to another integer type other than _Bool, if
3080 the value can be represented by the new type, it is unchanged.
3082 Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or
3083 subtracting one more than the maximum value that can be represented in the new type
3084 until the value is in the range of the new type.<sup><a href="#note60"><b>60)</b></a></sup>
3086 Otherwise, the new type is signed and the value cannot be represented in it; either the
3087 result is implementation-defined or an implementation-defined signal is raised.
3090 <p><a name="note60">60)</a> The rules describe arithmetic on the mathematical value, not the value of a given type of expression.
3093 <a name="6.3.1.4" href="#6.3.1.4"><h5>6.3.1.4 Real floating and integer</h5></a>
3095 When a finite value of real floating type is converted to an integer type other than _Bool,
3096 the fractional part is discarded (i.e., the value is truncated toward zero). If the value of
3097 the integral part cannot be represented by the integer type, the behavior is undefined.<sup><a href="#note61"><b>61)</b></a></sup>
3100 <!--page 70 indent 4-->
3102 When a value of integer type is converted to a real floating type, if the value being
3103 converted can be represented exactly in the new type, it is unchanged. If the value being
3104 converted is in the range of values that can be represented but cannot be represented
3105 exactly, the result is either the nearest higher or nearest lower representable value, chosen
3106 in an implementation-defined manner. If the value being converted is outside the range of
3107 values that can be represented, the behavior is undefined. Results of some implicit
3108 conversions (<a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a>) may be represented in greater precision and range than that
3109 required by the new type.
3112 <p><a name="note61">61)</a> The remaindering operation performed when a value of integer type is converted to unsigned type
3113 need not be performed when a value of real floating type is converted to unsigned type. Thus, the
3114 range of portable real floating values is (-1, Utype_MAX+1).
3117 <a name="6.3.1.5" href="#6.3.1.5"><h5>6.3.1.5 Real floating types</h5></a>
3119 When a value of real floating type is converted to a real floating type, if the value being
3120 converted can be represented exactly in the new type, it is unchanged. If the value being
3121 converted is in the range of values that can be represented but cannot be represented
3122 exactly, the result is either the nearest higher or nearest lower representable value, chosen
3123 in an implementation-defined manner. If the value being converted is outside the range of
3124 values that can be represented, the behavior is undefined. Results of some implicit
3125 conversions (<a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a>) may be represented in greater precision and range than that
3126 required by the new type.
3128 <a name="6.3.1.6" href="#6.3.1.6"><h5>6.3.1.6 Complex types</h5></a>
3130 When a value of complex type is converted to another complex type, both the real and
3131 imaginary parts follow the conversion rules for the corresponding real types.
3133 <a name="6.3.1.7" href="#6.3.1.7"><h5>6.3.1.7 Real and complex</h5></a>
3135 When a value of real type is converted to a complex type, the real part of the complex
3136 result value is determined by the rules of conversion to the corresponding real type and
3137 the imaginary part of the complex result value is a positive zero or an unsigned zero.
3139 When a value of complex type is converted to a real type, the imaginary part of the
3140 complex value is discarded and the value of the real part is converted according to the
3141 conversion rules for the corresponding real type.
3143 <a name="6.3.1.8" href="#6.3.1.8"><h5>6.3.1.8 Usual arithmetic conversions</h5></a>
3145 Many operators that expect operands of arithmetic type cause conversions and yield result
3146 types in a similar way. The purpose is to determine a common real type for the operands
3147 and result. For the specified operands, each operand is converted, without change of type
3148 domain, to a type whose corresponding real type is the common real type. Unless
3149 explicitly stated otherwise, the common real type is also the corresponding real type of
3150 the result, whose type domain is the type domain of the operands if they are the same,
3151 and complex otherwise. This pattern is called the usual arithmetic conversions:
3152 <!--page 71 indent 4-->
3155 First, if the corresponding real type of either operand is long double, the other
3156 operand is converted, without change of type domain, to a type whose
3157 corresponding real type is long double.
3158 Otherwise, if the corresponding real type of either operand is double, the other
3159 operand is converted, without change of type domain, to a type whose
3160 corresponding real type is double.
3161 Otherwise, if the corresponding real type of either operand is float, the other
3162 operand is converted, without change of type domain, to a type whose
3163 corresponding real type is float.<sup><a href="#note62"><b>62)</b></a></sup>
3164 Otherwise, the integer promotions are performed on both operands. Then the
3165 following rules are applied to the promoted operands:
3166 If both operands have the same type, then no further conversion is needed.
3167 Otherwise, if both operands have signed integer types or both have unsigned
3168 integer types, the operand with the type of lesser integer conversion rank is
3169 converted to the type of the operand with greater rank.
3170 Otherwise, if the operand that has unsigned integer type has rank greater or
3171 equal to the rank of the type of the other operand, then the operand with
3172 signed integer type is converted to the type of the operand with unsigned
3174 Otherwise, if the type of the operand with signed integer type can represent
3175 all of the values of the type of the operand with unsigned integer type, then
3176 the operand with unsigned integer type is converted to the type of the
3177 operand with signed integer type.
3178 Otherwise, both operands are converted to the unsigned integer type
3179 corresponding to the type of the operand with signed integer type.</pre>
3180 The values of floating operands and of the results of floating expressions may be
3181 represented in greater precision and range than that required by the type; the types are not
3182 changed thereby.<sup><a href="#note63"><b>63)</b></a></sup>
3187 <!--page 72 indent 4-->
3190 <p><a name="note62">62)</a> For example, addition of a double _Complex and a float entails just the conversion of the
3191 float operand to double (and yields a double _Complex result).
3193 <p><a name="note63">63)</a> The cast and assignment operators are still required to remove extra range and precision.
3196 <a name="6.3.2" href="#6.3.2"><h4>6.3.2 Other operands</h4></a>
3198 <a name="6.3.2.1" href="#6.3.2.1"><h5>6.3.2.1 Lvalues, arrays, and function designators</h5></a>
3200 An lvalue is an expression (with an object type other than void) that potentially
3201 designates an object;<sup><a href="#note64"><b>64)</b></a></sup> if an lvalue does not designate an object when it is evaluated, the
3202 behavior is undefined. When an object is said to have a particular type, the type is
3203 specified by the lvalue used to designate the object. A modifiable lvalue is an lvalue that
3204 does not have array type, does not have an incomplete type, does not have a const-
3205 qualified type, and if it is a structure or union, does not have any member (including,
3206 recursively, any member or element of all contained aggregates or unions) with a const-
3209 Except when it is the operand of the sizeof operator, the unary & operator, the ++
3210 operator, the -- operator, or the left operand of the . operator or an assignment operator,
3211 an lvalue that does not have array type is converted to the value stored in the designated
3212 object (and is no longer an lvalue); this is called lvalue conversion. If the lvalue has
3213 qualified type, the value has the unqualified version of the type of the lvalue; additionally,
3214 if the lvalue has atomic type, the value has the non-atomic version of the type of the
3215 lvalue; otherwise, the value has the type of the lvalue. If the lvalue has an incomplete
3216 type and does not have array type, the behavior is undefined. If the lvalue designates an
3217 object of automatic storage duration that could have been declared with the register
3218 storage class (never had its address taken), and that object is uninitialized (not declared
3219 with an initializer and no assignment to it has been performed prior to use), the behavior
3222 Except when it is the operand of the sizeof operator or the unary & operator, or is a
3223 string literal used to initialize an array, an expression that has type ''array of type'' is
3224 converted to an expression with type ''pointer to type'' that points to the initial element of
3225 the array object and is not an lvalue. If the array object has register storage class, the
3226 behavior is undefined.
3228 A function designator is an expression that has function type. Except when it is the
3229 operand of the sizeof operator<sup><a href="#note65"><b>65)</b></a></sup> or the unary & operator, a function designator with
3230 type ''function returning type'' is converted to an expression that has type ''pointer to
3233 <!--page 73 indent 4-->
3234 function returning type''.
3235 Forward references: address and indirection operators (<a href="#6.5.3.2">6.5.3.2</a>), assignment operators
3236 (<a href="#6.5.16">6.5.16</a>), common definitions <stddef.h> (<a href="#7.19">7.19</a>), initialization (<a href="#6.7.9">6.7.9</a>), postfix
3237 increment and decrement operators (<a href="#6.5.2.4">6.5.2.4</a>), prefix increment and decrement operators
3238 (<a href="#6.5.3.1">6.5.3.1</a>), the sizeof operator (<a href="#6.5.3.4">6.5.3.4</a>), structure and union members (<a href="#6.5.2.3">6.5.2.3</a>).
3241 <p><a name="note64">64)</a> The name ''lvalue'' comes originally from the assignment expression E1 = E2, in which the left
3242 operand E1 is required to be a (modifiable) lvalue. It is perhaps better considered as representing an
3243 object ''locator value''. What is sometimes called ''rvalue'' is in this International Standard described
3244 as the ''value of an expression''.
3245 An obvious example of an lvalue is an identifier of an object. As a further example, if E is a unary
3246 expression that is a pointer to an object, *E is an lvalue that designates the object to which E points.
3248 <p><a name="note65">65)</a> Because this conversion does not occur, the operand of the sizeof operator remains a function
3249 designator and violates the constraint in <a href="#6.5.3.4">6.5.3.4</a>.
3252 <a name="6.3.2.2" href="#6.3.2.2"><h5>6.3.2.2 void</h5></a>
3254 The (nonexistent) value of a void expression (an expression that has type void) shall not
3255 be used in any way, and implicit or explicit conversions (except to void) shall not be
3256 applied to such an expression. If an expression of any other type is evaluated as a void
3257 expression, its value or designator is discarded. (A void expression is evaluated for its
3260 <a name="6.3.2.3" href="#6.3.2.3"><h5>6.3.2.3 Pointers</h5></a>
3262 A pointer to void may be converted to or from a pointer to any object type. A pointer to
3263 any object type may be converted to a pointer to void and back again; the result shall
3264 compare equal to the original pointer.
3266 For any qualifier q, a pointer to a non-q-qualified type may be converted to a pointer to
3267 the q-qualified version of the type; the values stored in the original and converted pointers
3268 shall compare equal.
3270 An integer constant expression with the value 0, or such an expression cast to type
3271 void *, is called a null pointer constant.<sup><a href="#note66"><b>66)</b></a></sup> If a null pointer constant is converted to a
3272 pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal
3273 to a pointer to any object or function.
3275 Conversion of a null pointer to another pointer type yields a null pointer of that type.
3276 Any two null pointers shall compare equal.
3278 An integer may be converted to any pointer type. Except as previously specified, the
3279 result is implementation-defined, might not be correctly aligned, might not point to an
3280 entity of the referenced type, and might be a trap representation.<sup><a href="#note67"><b>67)</b></a></sup>
3282 Any pointer type may be converted to an integer type. Except as previously specified, the
3283 result is implementation-defined. If the result cannot be represented in the integer type,
3284 the behavior is undefined. The result need not be in the range of values of any integer
3290 <!--page 74 indent 4-->
3292 A pointer to an object type may be converted to a pointer to a different object type. If the
3293 resulting pointer is not correctly aligned<sup><a href="#note68"><b>68)</b></a></sup> for the referenced type, the behavior is
3294 undefined. Otherwise, when converted back again, the result shall compare equal to the
3295 original pointer. When a pointer to an object is converted to a pointer to a character type,
3296 the result points to the lowest addressed byte of the object. Successive increments of the
3297 result, up to the size of the object, yield pointers to the remaining bytes of the object.
3299 A pointer to a function of one type may be converted to a pointer to a function of another
3300 type and back again; the result shall compare equal to the original pointer. If a converted
3301 pointer is used to call a function whose type is not compatible with the referenced type,
3302 the behavior is undefined.
3303 Forward references: cast operators (<a href="#6.5.4">6.5.4</a>), equality operators (<a href="#6.5.9">6.5.9</a>), integer types
3304 capable of holding object pointers (<a href="#7.20.1.4">7.20.1.4</a>), simple assignment (<a href="#6.5.16.1">6.5.16.1</a>).
3309 <!--page 75 indent 4-->
3312 <p><a name="note66">66)</a> The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see <a href="#7.19">7.19</a>.
3314 <p><a name="note67">67)</a> The mapping functions for converting a pointer to an integer or an integer to a pointer are intended to
3315 be consistent with the addressing structure of the execution environment.
3317 <p><a name="note68">68)</a> In general, the concept ''correctly aligned'' is transitive: if a pointer to type A is correctly aligned for a
3318 pointer to type B, which in turn is correctly aligned for a pointer to type C, then a pointer to type A is
3319 correctly aligned for a pointer to type C.
3322 <a name="6.4" href="#6.4"><h3>6.4 Lexical elements</h3></a>
3332 preprocessing-token:
3339 each non-white-space character that cannot be one of the above</pre>
3340 <h6>Constraints</h6>
3342 Each preprocessing token that is converted to a token shall have the lexical form of a
3343 keyword, an identifier, a constant, a string literal, or a punctuator.
3346 A token is the minimal lexical element of the language in translation phases 7 and 8. The
3347 categories of tokens are: keywords, identifiers, constants, string literals, and punctuators.
3348 A preprocessing token is the minimal lexical element of the language in translation
3349 phases 3 through 6. The categories of preprocessing tokens are: header names,
3350 identifiers, preprocessing numbers, character constants, string literals, punctuators, and
3351 single non-white-space characters that do not lexically match the other preprocessing
3352 token categories.<sup><a href="#note69"><b>69)</b></a></sup> If a ' or a " character matches the last category, the behavior is
3353 undefined. Preprocessing tokens can be separated by white space; this consists of
3354 comments (described later), or white-space characters (space, horizontal tab, new-line,
3355 vertical tab, and form-feed), or both. As described in <a href="#6.10">6.10</a>, in certain circumstances
3356 during translation phase 4, white space (or the absence thereof) serves as more than
3357 preprocessing token separation. White space may appear within a preprocessing token
3358 only as part of a header name or between the quotation characters in a character constant
3363 <!--page 76 indent 4-->
3365 If the input stream has been parsed into preprocessing tokens up to a given character, the
3366 next preprocessing token is the longest sequence of characters that could constitute a
3367 preprocessing token. There is one exception to this rule: header name preprocessing
3368 tokens are recognized only within #include preprocessing directives and in
3369 implementation-defined locations within #pragma directives. In such contexts, a
3370 sequence of characters that could be either a header name or a string literal is recognized
3373 EXAMPLE 1 The program fragment 1Ex is parsed as a preprocessing number token (one that is not a
3374 valid floating or integer constant token), even though a parse as the pair of preprocessing tokens 1 and Ex
3375 might produce a valid expression (for example, if Ex were a macro defined as +1). Similarly, the program
3376 fragment 1E1 is parsed as a preprocessing number (one that is a valid floating constant token), whether or
3377 not E is a macro name.
3380 EXAMPLE 2 The program fragment x+++++y is parsed as x ++ ++ + y, which violates a constraint on
3381 increment operators, even though the parse x ++ + ++ y might yield a correct expression.
3383 Forward references: character constants (<a href="#6.4.4.4">6.4.4.4</a>), comments (<a href="#6.4.9">6.4.9</a>), expressions (<a href="#6.5">6.5</a>),
3384 floating constants (<a href="#6.4.4.2">6.4.4.2</a>), header names (<a href="#6.4.7">6.4.7</a>), macro replacement (<a href="#6.10.3">6.10.3</a>), postfix
3385 increment and decrement operators (<a href="#6.5.2.4">6.5.2.4</a>), prefix increment and decrement operators
3386 (<a href="#6.5.3.1">6.5.3.1</a>), preprocessing directives (<a href="#6.10">6.10</a>), preprocessing numbers (<a href="#6.4.8">6.4.8</a>), string literals
3387 (<a href="#6.4.5">6.4.5</a>).
3390 <p><a name="note69">69)</a> An additional category, placemarkers, is used internally in translation phase 4 (see <a href="#6.10.3.3">6.10.3.3</a>); it cannot
3391 occur in source files.
3394 <a name="6.4.1" href="#6.4.1"><h4>6.4.1 Keywords</h4></a>
3404 const register _Alignas
3405 continue restrict _Atomic
3406 default return _Bool
3408 double signed _Generic
3409 else sizeof _Imaginary
3410 enum static _Noreturn
3411 extern struct _Static_assert
3412 float switch _Thread_local
3416 The above tokens (case sensitive) are reserved (in translation phases 7 and 8) for use as
3417 keywords, and shall not be used otherwise. The keyword _Imaginary is reserved for
3418 <!--page 77 indent 4-->
3419 specifying imaginary types.<sup><a href="#note70"><b>70)</b></a></sup>
3422 <p><a name="note70">70)</a> One possible specification for imaginary types appears in <a href="#G">annex G</a>.
3425 <a name="6.4.2" href="#6.4.2"><h4>6.4.2 Identifiers</h4></a>
3427 <a name="6.4.2.1" href="#6.4.2.1"><h5>6.4.2.1 General</h5></a>
3433 identifier identifier-nondigit
3435 identifier-nondigit:
3437 universal-character-name
3438 other implementation-defined characters
3440 _ a b c d e f g h i j k l m
3441 n o p q r s t u v w x y z
3442 A B C D E F G H I J K L M
3443 N O P Q R S T U V W X Y Z
3445 0 1 2 3 4 5 6 7 8 9</pre>
3448 An identifier is a sequence of nondigit characters (including the underscore _, the
3449 lowercase and uppercase Latin letters, and other characters) and digits, which designates
3450 one or more entities as described in <a href="#6.2.1">6.2.1</a>. Lowercase and uppercase letters are distinct.
3451 There is no specific limit on the maximum length of an identifier.
3453 Each universal character name in an identifier shall designate a character whose encoding
3454 in ISO/IEC 10646 falls into one of the ranges specified in D.1.<sup><a href="#note71"><b>71)</b></a></sup> The initial character
3455 shall not be a universal character name designating a character whose encoding falls into
3456 one of the ranges specified in <a href="#D.2">D.2</a>. An implementation may allow multibyte characters
3457 that are not part of the basic source character set to appear in identifiers; which characters
3458 and their correspondence to universal character names is implementation-defined.
3462 <!--page 78 indent 4-->
3464 When preprocessing tokens are converted to tokens during translation phase 7, if a
3465 preprocessing token could be converted to either a keyword or an identifier, it is converted
3467 Implementation limits
3469 As discussed in <a href="#5.2.4.1">5.2.4.1</a>, an implementation may limit the number of significant initial
3470 characters in an identifier; the limit for an external name (an identifier that has external
3471 linkage) may be more restrictive than that for an internal name (a macro name or an
3472 identifier that does not have external linkage). The number of significant characters in an
3473 identifier is implementation-defined.
3475 Any identifiers that differ in a significant character are different identifiers. If two
3476 identifiers differ only in nonsignificant characters, the behavior is undefined.
3477 Forward references: universal character names (<a href="#6.4.3">6.4.3</a>), macro replacement (<a href="#6.10.3">6.10.3</a>).
3480 <p><a name="note71">71)</a> On systems in which linkers cannot accept extended characters, an encoding of the universal character
3481 name may be used in forming valid external identifiers. For example, some otherwise unused
3482 character or sequence of characters may be used to encode the \u in a universal character name.
3483 Extended characters may produce a long external identifier.
3486 <a name="6.4.2.2" href="#6.4.2.2"><h5>6.4.2.2 Predefined identifiers</h5></a>
3489 The identifier __func__ shall be implicitly declared by the translator as if,
3490 immediately following the opening brace of each function definition, the declaration
3492 static const char __func__[] = "function-name";</pre>
3493 appeared, where function-name is the name of the lexically-enclosing function.<sup><a href="#note72"><b>72)</b></a></sup>
3495 This name is encoded as if the implicit declaration had been written in the source
3496 character set and then translated into the execution character set as indicated in translation
3499 EXAMPLE Consider the code fragment:
3501 #include <stdio.h>
3504 printf("%s\n", __func__);
3507 Each time the function is called, it will print to the standard output stream:
3511 Forward references: function definitions (<a href="#6.9.1">6.9.1</a>).
3516 <!--page 79 indent 4-->
3519 <p><a name="note72">72)</a> Since the name __func__ is reserved for any use by the implementation (<a href="#7.1.3">7.1.3</a>), if any other
3520 identifier is explicitly declared using the name __func__, the behavior is undefined.
3523 <a name="6.4.3" href="#6.4.3"><h4>6.4.3 Universal character names</h4></a>
3527 universal-character-name:
3529 \U hex-quad hex-quad
3531 hexadecimal-digit hexadecimal-digit
3532 hexadecimal-digit hexadecimal-digit</pre>
3533 <h6>Constraints</h6>
3535 A universal character name shall not specify a character whose short identifier is less than
3536 00A0 other than 0024 ($), 0040 (@), or 0060 ('), nor one in the range D800 through
3537 DFFF inclusive.<sup><a href="#note73"><b>73)</b></a></sup>
3538 <h6>Description</h6>
3540 Universal character names may be used in identifiers, character constants, and string
3541 literals to designate characters that are not in the basic character set.
3544 The universal character name \Unnnnnnnn designates the character whose eight-digit
3545 short identifier (as specified by ISO/IEC 10646) is nnnnnnnn.<sup><a href="#note74"><b>74)</b></a></sup> Similarly, the universal
3546 character name \unnnn designates the character whose four-digit short identifier is nnnn
3547 (and whose eight-digit short identifier is 0000nnnn).
3552 <!--page 80 indent 4-->
3555 <p><a name="note73">73)</a> The disallowed characters are the characters in the basic character set and the code positions reserved
3556 by ISO/IEC 10646 for control characters, the character DELETE, and the S-zone (reserved for use by
3560 <p><a name="note74">74)</a> Short identifiers for characters were first specified in ISO/IEC 10646-1/AMD9:1997.
3563 <a name="6.4.4" href="#6.4.4"><h4>6.4.4 Constants</h4></a>
3570 enumeration-constant
3571 character-constant</pre>
3572 <h6>Constraints</h6>
3574 Each constant shall have a type and the value of a constant shall be in the range of
3575 representable values for its type.
3578 Each constant has a type, determined by its form and value, as detailed later.
3580 <a name="6.4.4.1" href="#6.4.4.1"><h5>6.4.4.1 Integer constants</h5></a>
3583 <!--page 81 indent 4-->
3586 decimal-constant integer-suffixopt
3587 octal-constant integer-suffixopt
3588 hexadecimal-constant integer-suffixopt
3591 decimal-constant digit
3594 octal-constant octal-digit
3595 hexadecimal-constant:
3596 hexadecimal-prefix hexadecimal-digit
3597 hexadecimal-constant hexadecimal-digit
3598 hexadecimal-prefix: one of
3600 nonzero-digit: one of
3604 hexadecimal-digit: one of
3609 unsigned-suffix long-suffixopt
3610 unsigned-suffix long-long-suffix
3611 long-suffix unsigned-suffixopt
3612 long-long-suffix unsigned-suffixopt
3613 unsigned-suffix: one of
3617 long-long-suffix: one of
3619 <h6>Description</h6>
3621 An integer constant begins with a digit, but has no period or exponent part. It may have a
3622 prefix that specifies its base and a suffix that specifies its type.
3624 A decimal constant begins with a nonzero digit and consists of a sequence of decimal
3625 digits. An octal constant consists of the prefix 0 optionally followed by a sequence of the
3626 digits 0 through 7 only. A hexadecimal constant consists of the prefix 0x or 0X followed
3627 by a sequence of the decimal digits and the letters a (or A) through f (or F) with values
3628 10 through 15 respectively.
3631 The value of a decimal constant is computed base 10; that of an octal constant, base 8;
3632 that of a hexadecimal constant, base 16. The lexically first digit is the most significant.
3634 The type of an integer constant is the first of the corresponding list in which its value can
3636 <!--page 82 indent 4-->
3638 Octal or Hexadecimal</pre>
3639 Suffix Decimal Constant Constant
3643 long int unsigned int
3644 long long int long int
3647 unsigned long long int</pre>
3649 u or U unsigned int unsigned int
3651 unsigned long int unsigned long int
3652 unsigned long long int unsigned long long int</pre>
3654 l or L long int long int
3656 long long int unsigned long int
3658 unsigned long long int</pre>
3660 Both u or U unsigned long int unsigned long int
3661 and l or L unsigned long long int unsigned long long int
3663 ll or LL long long int long long int
3665 unsigned long long int</pre>
3667 Both u or U unsigned long long int unsigned long long int
3670 If an integer constant cannot be represented by any type in its list, it may have an
3671 extended integer type, if the extended integer type can represent its value. If all of the
3672 types in the list for the constant are signed, the extended integer type shall be signed. If
3673 all of the types in the list for the constant are unsigned, the extended integer type shall be
3674 unsigned. If the list contains both signed and unsigned types, the extended integer type
3675 may be signed or unsigned. If an integer constant cannot be represented by any type in
3676 its list and has no extended integer type, then the integer constant has no type.
3677 <!--page 83 indent 4-->
3679 <a name="6.4.4.2" href="#6.4.4.2"><h5>6.4.4.2 Floating constants</h5></a>
3682 <!--page 84 indent 4-->
3685 decimal-floating-constant
3686 hexadecimal-floating-constant
3687 decimal-floating-constant:
3688 fractional-constant exponent-partopt floating-suffixopt
3689 digit-sequence exponent-part floating-suffixopt
3690 hexadecimal-floating-constant:
3691 hexadecimal-prefix hexadecimal-fractional-constant
3692 binary-exponent-part floating-suffixopt
3693 hexadecimal-prefix hexadecimal-digit-sequence
3694 binary-exponent-part floating-suffixopt
3695 fractional-constant:
3696 digit-sequenceopt . digit-sequence
3699 e signopt digit-sequence
3700 E signopt digit-sequence
3705 digit-sequence digit
3706 hexadecimal-fractional-constant:
3707 hexadecimal-digit-sequenceopt .
3708 hexadecimal-digit-sequence
3709 hexadecimal-digit-sequence .
3710 binary-exponent-part:
3711 p signopt digit-sequence
3712 P signopt digit-sequence
3713 hexadecimal-digit-sequence:
3715 hexadecimal-digit-sequence hexadecimal-digit
3716 floating-suffix: one of
3718 <h6>Description</h6>
3720 A floating constant has a significand part that may be followed by an exponent part and a
3721 suffix that specifies its type. The components of the significand part may include a digit
3722 sequence representing the whole-number part, followed by a period (.), followed by a
3723 digit sequence representing the fraction part. The components of the exponent part are an
3724 e, E, p, or P followed by an exponent consisting of an optionally signed digit sequence.
3725 Either the whole-number part or the fraction part has to be present; for decimal floating
3726 constants, either the period or the exponent part has to be present.
3729 The significand part is interpreted as a (decimal or hexadecimal) rational number; the
3730 digit sequence in the exponent part is interpreted as a decimal integer. For decimal
3731 floating constants, the exponent indicates the power of 10 by which the significand part is
3732 to be scaled. For hexadecimal floating constants, the exponent indicates the power of 2
3733 by which the significand part is to be scaled. For decimal floating constants, and also for
3734 hexadecimal floating constants when FLT_RADIX is not a power of 2, the result is either
3735 the nearest representable value, or the larger or smaller representable value immediately
3736 adjacent to the nearest representable value, chosen in an implementation-defined manner.
3737 For hexadecimal floating constants when FLT_RADIX is a power of 2, the result is
3740 An unsuffixed floating constant has type double. If suffixed by the letter f or F, it has
3741 type float. If suffixed by the letter l or L, it has type long double.
3743 Floating constants are converted to internal format as if at translation-time. The
3744 conversion of a floating constant shall not raise an exceptional condition or a floating-
3745 point exception at execution time. All floating constants of the same source form<sup><a href="#note75"><b>75)</b></a></sup> shall
3746 convert to the same internal format with the same value.
3747 Recommended practice
3749 The implementation should produce a diagnostic message if a hexadecimal constant
3750 cannot be represented exactly in its evaluation format; the implementation should then
3751 proceed with the translation of the program.
3753 The translation-time conversion of floating constants should match the execution-time
3754 conversion of character strings by library functions, such as strtod, given matching
3755 inputs suitable for both conversions, the same result format, and default execution-time
3756 rounding.<sup><a href="#note76"><b>76)</b></a></sup>
3758 <!--page 85 indent 4-->
3761 <p><a name="note75">75)</a> <a href="#1.23">1.23</a>, 1.230, 123e-2, 123e-02, and 1.23L are all different source forms and thus need not
3762 convert to the same internal format and value.
3764 <p><a name="note76">76)</a> The specification for the library functions recommends more accurate conversion than required for
3765 floating constants (see <a href="#7.22.1.3">7.22.1.3</a>).
3768 <a name="6.4.4.3" href="#6.4.4.3"><h5>6.4.4.3 Enumeration constants</h5></a>
3772 enumeration-constant:
3776 An identifier declared as an enumeration constant has type int.
3777 Forward references: enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>).
3779 <a name="6.4.4.4" href="#6.4.4.4"><h5>6.4.4.4 Character constants</h5></a>
3782 <!--page 86 indent 4-->
3786 L' c-char-sequence '
3787 u' c-char-sequence '
3788 U' c-char-sequence '
3791 c-char-sequence c-char
3793 any member of the source character set except
3794 the single-quote ', backslash \, or new-line character
3797 simple-escape-sequence
3798 octal-escape-sequence
3799 hexadecimal-escape-sequence
3800 universal-character-name
3801 simple-escape-sequence: one of
3803 \a \b \f \n \r \t \v
3804 octal-escape-sequence:
3806 \ octal-digit octal-digit
3807 \ octal-digit octal-digit octal-digit
3808 hexadecimal-escape-sequence:
3809 \x hexadecimal-digit
3810 hexadecimal-escape-sequence hexadecimal-digit</pre>
3811 <h6>Description</h6>
3813 An integer character constant is a sequence of one or more multibyte characters enclosed
3814 in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the
3815 letter L, u, or U. With a few exceptions detailed later, the elements of the sequence are
3816 any members of the source character set; they are mapped in an implementation-defined
3817 manner to members of the execution character set.
3819 The single-quote ', the double-quote ", the question-mark ?, the backslash \, and
3820 arbitrary integer values are representable according to the following table of escape
3828 octal character \octal digits
3829 hexadecimal character \x hexadecimal digits</pre>
3830 The double-quote " and question-mark ? are representable either by themselves or by the
3831 escape sequences \" and \?, respectively, but the single-quote ' and the backslash \
3832 shall be represented, respectively, by the escape sequences \' and \\.
3834 The octal digits that follow the backslash in an octal escape sequence are taken to be part
3835 of the construction of a single character for an integer character constant or of a single
3836 wide character for a wide character constant. The numerical value of the octal integer so
3837 formed specifies the value of the desired character or wide character.
3839 The hexadecimal digits that follow the backslash and the letter x in a hexadecimal escape
3840 sequence are taken to be part of the construction of a single character for an integer
3841 character constant or of a single wide character for a wide character constant. The
3842 numerical value of the hexadecimal integer so formed specifies the value of the desired
3843 character or wide character.
3845 Each octal or hexadecimal escape sequence is the longest sequence of characters that can
3846 constitute the escape sequence.
3848 In addition, characters not in the basic character set are representable by universal
3849 character names and certain nongraphic characters are representable by escape sequences
3850 consisting of the backslash \ followed by a lowercase letter: \a, \b, \f, \n, \r, \t,
3851 and \v.<sup><a href="#note77"><b>77)</b></a></sup>
3852 <!--page 87 indent 5-->
3853 <h6>Constraints</h6>
3855 The value of an octal or hexadecimal escape sequence shall be in the range of
3856 representable values for the corresponding type:
3858 Prefix Corresponding Type
3860 L the unsigned type corresponding to wchar_t
3865 An integer character constant has type int. The value of an integer character constant
3866 containing a single character that maps to a single-byte execution character is the
3867 numerical value of the representation of the mapped character interpreted as an integer.
3868 The value of an integer character constant containing more than one character (e.g.,
3869 'ab'), or containing a character or escape sequence that does not map to a single-byte
3870 execution character, is implementation-defined. If an integer character constant contains
3871 a single character or escape sequence, its value is the one that results when an object with
3872 type char whose value is that of the single character or escape sequence is converted to
3875 A wide character constant prefixed by the letter L has type wchar_t, an integer type
3876 defined in the <stddef.h> header; a wide character constant prefixed by the letter u or
3877 U has type char16_t or char32_t, respectively, unsigned integer types defined in the
3878 <uchar.h> header. The value of a wide character constant containing a single
3879 multibyte character that maps to a single member of the extended execution character set
3880 is the wide character corresponding to that multibyte character, as defined by the
3881 mbtowc, mbrtoc16, or mbrtoc32 function as appropriate for its type, with an
3882 implementation-defined current locale. The value of a wide character constant containing
3883 more than one multibyte character or a single multibyte character that maps to multiple
3884 members of the extended execution character set, or containing a multibyte character or
3885 escape sequence not represented in the extended execution character set, is
3886 implementation-defined.
3888 EXAMPLE 1 The construction '\0' is commonly used to represent the null character.
3891 EXAMPLE 2 Consider implementations that use two's complement representation for integers and eight
3892 bits for objects that have type char. In an implementation in which type char has the same range of
3893 values as signed char, the integer character constant '\xFF' has the value -1; if type char has the
3894 same range of values as unsigned char, the character constant '\xFF' has the value +255.
3899 <!--page 88 indent 5-->
3901 EXAMPLE 3 Even if eight bits are used for objects that have type char, the construction '\x123'
3902 specifies an integer character constant containing only one character, since a hexadecimal escape sequence
3903 is terminated only by a non-hexadecimal character. To specify an integer character constant containing the
3904 two characters whose values are '\x12' and '3', the construction '\0223' may be used, since an octal
3905 escape sequence is terminated after three octal digits. (The value of this two-character integer character
3906 constant is implementation-defined.)
3909 EXAMPLE 4 Even if 12 or more bits are used for objects that have type wchar_t, the construction
3910 L'\1234' specifies the implementation-defined value that results from the combination of the values
3913 Forward references: common definitions <stddef.h> (<a href="#7.19">7.19</a>), the mbtowc function
3914 (<a href="#7.22.7.2">7.22.7.2</a>), Unicode utilities <uchar.h> (<a href="#7.27">7.27</a>).
3917 <p><a name="note77">77)</a> The semantics of these characters were discussed in <a href="#5.2.2">5.2.2</a>. If any other character follows a backslash,
3918 the result is not a token and a diagnostic is required. See ''future language directions'' (<a href="#6.11.4">6.11.4</a>).
3921 <a name="6.4.5" href="#6.4.5"><h4>6.4.5 String literals</h4></a>
3926 encoding-prefixopt " s-char-sequenceopt "
3934 s-char-sequence s-char
3936 any member of the source character set except
3937 the double-quote ", backslash \, or new-line character
3938 escape-sequence</pre>
3939 <h6>Constraints</h6>
3941 A sequence of adjacent string literal tokens shall not include both a wide string literal and
3942 a UTF-8 string literal.
3943 <h6>Description</h6>
3945 A character string literal is a sequence of zero or more multibyte characters enclosed in
3946 double-quotes, as in "xyz". A UTF-8 string literal is the same, except prefixed by u8.
3947 A wide string literal is the same, except prefixed by the letter L, u, or U.
3949 The same considerations apply to each element of the sequence in a string literal as if it
3950 were in an integer character constant (for a character or UTF-8 string literal) or a wide
3951 character constant (for a wide string literal), except that the single-quote ' is
3952 representable either by itself or by the escape sequence \', but the double-quote " shall
3953 <!--page 89 indent 4-->
3954 be represented by the escape sequence \".
3957 In translation phase 6, the multibyte character sequences specified by any sequence of
3958 adjacent character and identically-prefixed string literal tokens are concatenated into a
3959 single multibyte character sequence. If any of the tokens has an encoding prefix, the
3960 resulting multibyte character sequence is treated as having the same prefix; otherwise, it
3961 is treated as a character string literal. Whether differently-prefixed wide string literal
3962 tokens can be concatenated and, if so, the treatment of the resulting multibyte character
3963 sequence are implementation-defined.
3965 In translation phase 7, a byte or code of value zero is appended to each multibyte
3966 character sequence that results from a string literal or literals.<sup><a href="#note78"><b>78)</b></a></sup> The multibyte character
3967 sequence is then used to initialize an array of static storage duration and length just
3968 sufficient to contain the sequence. For character string literals, the array elements have
3969 type char, and are initialized with the individual bytes of the multibyte character
3970 sequence. For UTF-8 string literals, the array elements have type char, and are
3971 initialized with the characters of the multibyte character sequence, as encoded in UTF-8.
3972 For wide string literals prefixed by the letter L, the array elements have type wchar_t
3973 and are initialized with the sequence of wide characters corresponding to the multibyte
3974 character sequence, as defined by the mbstowcs function with an implementation-
3975 defined current locale. For wide string literals prefixed by the letter u or U, the array
3976 elements have type char16_t or char32_t, respectively, and are initialized with the
3977 sequence of wide characters corresponding to the multibyte character sequence, as
3978 defined by successive calls to the mbrtoc16, or mbrtoc32 function as appropriate for
3979 its type, with an implementation-defined current locale. The value of a string literal
3980 containing a multibyte character or escape sequence not represented in the execution
3981 character set is implementation-defined.
3983 It is unspecified whether these arrays are distinct provided their elements have the
3984 appropriate values. If the program attempts to modify such an array, the behavior is
3987 EXAMPLE 1 This pair of adjacent character string literals
3990 produces a single character string literal containing the two characters whose values are '\x12' and '3',
3991 because escape sequences are converted into single members of the execution character set just prior to
3992 adjacent string literal concatenation.
3995 EXAMPLE 2 Each of the sequences of adjacent string literal tokens
3999 <!--page 90 indent 4-->
4004 L"a" L"b" L"c"</pre>
4005 is equivalent to the string literal
4008 Likewise, each of the sequences
4013 u"a" u"b" u"c"</pre>
4018 Forward references: common definitions <stddef.h> (<a href="#7.19">7.19</a>), the mbstowcs
4019 function (<a href="#7.22.8.1">7.22.8.1</a>), Unicode utilities <uchar.h> (<a href="#7.27">7.27</a>).
4022 <p><a name="note78">78)</a> A string literal need not be a string (see <a href="#7.1.1">7.1.1</a>), because a null character may be embedded in it by a
4026 <a name="6.4.6" href="#6.4.6"><h4>6.4.6 Punctuators</h4></a>
4032 ++ -- & * + - ~ !
4033 / % << >> < > <= >= == != ^ | && ||
4035 = *= /= %= += -= <<= >>= &= ^= |=
4037 <: :> <% %> %: %:%:</pre>
4040 A punctuator is a symbol that has independent syntactic and semantic significance.
4041 Depending on context, it may specify an operation to be performed (which in turn may
4042 yield a value or a function designator, produce a side effect, or some combination thereof)
4043 in which case it is known as an operator (other forms of operator also exist in some
4044 contexts). An operand is an entity on which an operator acts.
4045 <!--page 91 indent 4-->
4047 In all aspects of the language, the six tokens<sup><a href="#note79"><b>79)</b></a></sup>
4049 <: :> <% %> %: %:%:</pre>
4050 behave, respectively, the same as the six tokens
4053 except for their spelling.<sup><a href="#note80"><b>80)</b></a></sup>
4054 Forward references: expressions (<a href="#6.5">6.5</a>), declarations (<a href="#6.7">6.7</a>), preprocessing directives
4055 (<a href="#6.10">6.10</a>), statements (<a href="#6.8">6.8</a>).
4058 <p><a name="note79">79)</a> These tokens are sometimes called ''digraphs''.
4060 <p><a name="note80">80)</a> Thus [ and <: behave differently when ''stringized'' (see <a href="#6.10.3.2">6.10.3.2</a>), but can otherwise be freely
4064 <a name="6.4.7" href="#6.4.7"><h4>6.4.7 Header names</h4></a>
4069 < h-char-sequence >
4073 h-char-sequence h-char
4075 any member of the source character set except
4076 the new-line character and >
4079 q-char-sequence q-char
4081 any member of the source character set except
4082 the new-line character and "</pre>
4085 The sequences in both forms of header names are mapped in an implementation-defined
4086 manner to headers or external source file names as specified in <a href="#6.10.2">6.10.2</a>.
4088 If the characters ', \, ", //, or /* occur in the sequence between the < and > delimiters,
4089 the behavior is undefined. Similarly, if the characters ', \, //, or /* occur in the
4094 <!--page 92 indent 4-->
4095 sequence between the " delimiters, the behavior is undefined.<sup><a href="#note81"><b>81)</b></a></sup> Header name
4096 preprocessing tokens are recognized only within #include preprocessing directives and
4097 in implementation-defined locations within #pragma directives.<sup><a href="#note82"><b>82)</b></a></sup>
4099 EXAMPLE The following sequence of characters:
4102 #include <1/a.h>
4103 #define const.member@$</pre>
4104 forms the following sequence of preprocessing tokens (with each individual preprocessing token delimited
4105 by a { on the left and a } on the right).
4107 {0x3}{<}{1}{/}{a}{.}{h}{>}{1e2}
4108 {#}{include} {<1/a.h>}
4109 {#}{define} {const}{.}{member}{@}{$}</pre>
4111 Forward references: source file inclusion (<a href="#6.10.2">6.10.2</a>).
4114 <p><a name="note81">81)</a> Thus, sequences of characters that resemble escape sequences cause undefined behavior.
4116 <p><a name="note82">82)</a> For an example of a header name preprocessing token used in a #pragma directive, see <a href="#6.10.9">6.10.9</a>.
4119 <a name="6.4.8" href="#6.4.8"><h4>6.4.8 Preprocessing numbers</h4></a>
4127 pp-number identifier-nondigit
4133 <h6>Description</h6>
4135 A preprocessing number begins with a digit optionally preceded by a period (.) and may
4136 be followed by valid identifier characters and the character sequences e+, e-, E+, E-,
4139 Preprocessing number tokens lexically include all floating and integer constant tokens.
4142 A preprocessing number does not have type or a value; it acquires both after a successful
4143 conversion (as part of translation phase 7) to a floating constant token or an integer
4147 <!--page 93 indent 4-->
4149 <a name="6.4.9" href="#6.4.9"><h4>6.4.9 Comments</h4></a>
4151 Except within a character constant, a string literal, or a comment, the characters /*
4152 introduce a comment. The contents of such a comment are examined only to identify
4153 multibyte characters and to find the characters */ that terminate it.<sup><a href="#note83"><b>83)</b></a></sup>
4155 Except within a character constant, a string literal, or a comment, the characters //
4156 introduce a comment that includes all multibyte characters up to, but not including, the
4157 next new-line character. The contents of such a comment are examined only to identify
4158 multibyte characters and to find the terminating new-line character.
4162 "a//b" // four-character string literal
4163 #include "//e" // undefined behavior
4164 // */ // comment, not syntax error
4165 f = g/**//h; // equivalent to f = g / h;
4167 i(); // part of a two-line comment
4169 / j(); // part of a two-line comment
4170 #define glue(x,y) x##y
4171 glue(/,/) k(); // syntax error, not comment
4172 /*//*/ l(); // equivalent to l();
4174 + p; // equivalent to m = n + p;</pre>
4179 <!--page 94 indent 4-->
4182 <p><a name="note83">83)</a> Thus, /* ... */ comments do not nest.
4185 <a name="6.5" href="#6.5"><h3>6.5 Expressions</h3></a>
4187 An expression is a sequence of operators and operands that specifies computation of a
4188 value, or that designates an object or a function, or that generates side effects, or that
4189 performs a combination thereof. The value computations of the operands of an operator
4190 are sequenced before the value computation of the result of the operator.
4192 If a side effect on a scalar object is unsequenced relative to either a different side effect
4193 on the same scalar object or a value computation using the value of the same scalar
4194 object, the behavior is undefined. If there are multiple allowable orderings of the
4195 subexpressions of an expression, the behavior is undefined if such an unsequenced side
4196 effect occurs in any of the orderings.<sup><a href="#note84"><b>84)</b></a></sup>
4198 The grouping of operators and operands is indicated by the syntax.<sup><a href="#note85"><b>85)</b></a></sup> Except as specified
4199 later, side effects and value computations of subexpressions are unsequenced.<sup><a href="#note86"><b>86)</b></a></sup> *
4201 Some operators (the unary operator ~, and the binary operators <<, >>, &, ^, and |,
4202 collectively described as bitwise operators) are required to have operands that have
4203 integer type. These operators yield values that depend on the internal representations of
4204 integers, and have implementation-defined and undefined aspects for signed types.
4206 If an exceptional condition occurs during the evaluation of an expression (that is, if the
4207 result is not mathematically defined or not in the range of representable values for its
4208 type), the behavior is undefined.
4212 <!--page 95 indent 4-->
4214 The effective type of an object for an access to its stored value is the declared type of the
4215 object, if any.<sup><a href="#note87"><b>87)</b></a></sup> If a value is stored into an object having no declared type through an
4216 lvalue having a type that is not a character type, then the type of the lvalue becomes the
4217 effective type of the object for that access and for subsequent accesses that do not modify
4218 the stored value. If a value is copied into an object having no declared type using
4219 memcpy or memmove, or is copied as an array of character type, then the effective type
4220 of the modified object for that access and for subsequent accesses that do not modify the
4221 value is the effective type of the object from which the value is copied, if it has one. For
4222 all other accesses to an object having no declared type, the effective type of the object is
4223 simply the type of the lvalue used for the access.
4225 An object shall have its stored value accessed only by an lvalue expression that has one of
4226 the following types:<sup><a href="#note88"><b>88)</b></a></sup>
4228 <li> a type compatible with the effective type of the object,
4229 <li> a qualified version of a type compatible with the effective type of the object,
4230 <li> a type that is the signed or unsigned type corresponding to the effective type of the
4232 <li> a type that is the signed or unsigned type corresponding to a qualified version of the
4233 effective type of the object,
4234 <li> an aggregate or union type that includes one of the aforementioned types among its
4235 members (including, recursively, a member of a subaggregate or contained union), or
4236 <li> a character type.
4239 A floating expression may be contracted, that is, evaluated as though it were a single
4240 operation, thereby omitting rounding errors implied by the source code and the
4241 expression evaluation method.<sup><a href="#note89"><b>89)</b></a></sup> The FP_CONTRACT pragma in <math.h> provides a
4242 way to disallow contracted expressions. Otherwise, whether and how expressions are
4243 contracted is implementation-defined.<sup><a href="#note90"><b>90)</b></a></sup>
4244 Forward references: the FP_CONTRACT pragma (<a href="#7.12.2">7.12.2</a>), copying functions (<a href="#7.23.2">7.23.2</a>).
4247 <!--page 96 indent 4-->
4250 <p><a name="note84">84)</a> This paragraph renders undefined statement expressions such as
4262 <p><a name="note85">85)</a> The syntax specifies the precedence of operators in the evaluation of an expression, which is the same
4263 as the order of the major subclauses of this subclause, highest precedence first. Thus, for example, the
4264 expressions allowed as the operands of the binary + operator (<a href="#6.5.6">6.5.6</a>) are those expressions defined in
4265 <a href="#6.5.1">6.5.1</a> through <a href="#6.5.6">6.5.6</a>. The exceptions are cast expressions (<a href="#6.5.4">6.5.4</a>) as operands of unary operators
4266 (<a href="#6.5.3">6.5.3</a>), and an operand contained between any of the following pairs of operators: grouping
4267 parentheses () (<a href="#6.5.1">6.5.1</a>), subscripting brackets [] (<a href="#6.5.2.1">6.5.2.1</a>), function-call parentheses () (<a href="#6.5.2.2">6.5.2.2</a>), and
4268 the conditional operator ? : (<a href="#6.5.15">6.5.15</a>).
4269 Within each major subclause, the operators have the same precedence. Left- or right-associativity is
4270 indicated in each subclause by the syntax for the expressions discussed therein.
4272 <p><a name="note86">86)</a> In an expression that is evaluated more than once during the execution of a program, unsequenced and
4273 indeterminately sequenced evaluations of its subexpressions need not be performed consistently in
4274 different evaluations.
4276 <p><a name="note87">87)</a> Allocated objects have no declared type.
4278 <p><a name="note88">88)</a> The intent of this list is to specify those circumstances in which an object may or may not be aliased.
4280 <p><a name="note89">89)</a> The intermediate operations in the contracted expression are evaluated as if to infinite precision and
4281 range, while the final operation is rounded to the format determined by the expression evaluation
4282 method. A contracted expression might also omit the raising of floating-point exceptions.
4284 <p><a name="note90">90)</a> This license is specifically intended to allow implementations to exploit fast machine instructions that
4285 combine multiple C operators. As contractions potentially undermine predictability, and can even
4286 decrease accuracy for containing expressions, their use needs to be well-defined and clearly
4290 <a name="6.5.1" href="#6.5.1"><h4>6.5.1 Primary expressions</h4></a>
4299 generic-selection</pre>
4302 An identifier is a primary expression, provided it has been declared as designating an
4303 object (in which case it is an lvalue) or a function (in which case it is a function
4304 designator).<sup><a href="#note91"><b>91)</b></a></sup>
4306 A constant is a primary expression. Its type depends on its form and value, as detailed in
4307 <a href="#6.4.4">6.4.4</a>.
4309 A string literal is a primary expression. It is an lvalue with type as detailed in <a href="#6.4.5">6.4.5</a>.
4311 A parenthesized expression is a primary expression. Its type and value are identical to
4312 those of the unparenthesized expression. It is an lvalue, a function designator, or a void
4313 expression if the unparenthesized expression is, respectively, an lvalue, a function
4314 designator, or a void expression.
4315 Forward references: declarations (<a href="#6.7">6.7</a>).
4318 <p><a name="note91">91)</a> Thus, an undeclared identifier is a violation of the syntax.
4321 <a name="6.5.1.1" href="#6.5.1.1"><h5>6.5.1.1 Generic selection</h5></a>
4326 _Generic ( assignment-expression , generic-assoc-list )
4329 generic-assoc-list , generic-association
4330 generic-association:
4331 type-name : assignment-expression
4332 default : assignment-expression</pre>
4333 <h6>Constraints</h6>
4335 A generic selection shall have no more than one default generic association. The type
4336 name in a generic association shall specify a complete object type other than a variably
4338 <!--page 97 indent 4-->
4339 modified type. No two generic associations in the same generic selection shall specify
4340 compatible types. The controlling expression of a generic selection shall have type
4341 compatible with at most one of the types named in its generic association list. If a
4342 generic selection has no default generic association, its controlling expression shall
4343 have type compatible with exactly one of the types named in its generic association list.
4346 The controlling expression of a generic selection is not evaluated. If a generic selection
4347 has a generic association with a type name that is compatible with the type of the
4348 controlling expression, then the result expression of the generic selection is the
4349 expression in that generic association. Otherwise, the result expression of the generic
4350 selection is the expression in the default generic association. None of the expressions
4351 from any other generic association of the generic selection is evaluated.
4353 The type and value of a generic selection are identical to those of its result expression. It
4354 is an lvalue, a function designator, or a void expression if its result expression is,
4355 respectively, an lvalue, a function designator, or a void expression.
4357 EXAMPLE The cbrt type-generic macro could be implemented as follows:
4359 #define cbrt(X) _Generic((X), \
4360 long double: cbrtl, \
4366 <a name="6.5.2" href="#6.5.2"><h4>6.5.2 Postfix operators</h4></a>
4369 <!--page 98 indent 4-->
4373 postfix-expression [ expression ]
4374 postfix-expression ( argument-expression-listopt )
4375 postfix-expression . identifier
4376 postfix-expression -> identifier
4377 postfix-expression ++
4378 postfix-expression --
4379 ( type-name ) { initializer-list }
4380 ( type-name ) { initializer-list , }
4381 argument-expression-list:
4382 assignment-expression
4383 argument-expression-list , assignment-expression</pre>
4385 <a name="6.5.2.1" href="#6.5.2.1"><h5>6.5.2.1 Array subscripting</h5></a>
4386 <h6>Constraints</h6>
4388 One of the expressions shall have type ''pointer to complete object type'', the other
4389 expression shall have integer type, and the result has type ''type''.
4392 A postfix expression followed by an expression in square brackets [] is a subscripted
4393 designation of an element of an array object. The definition of the subscript operator []
4394 is that E1[E2] is identical to (*((E1)+(E2))). Because of the conversion rules that
4395 apply to the binary + operator, if E1 is an array object (equivalently, a pointer to the
4396 initial element of an array object) and E2 is an integer, E1[E2] designates the E2-th
4397 element of E1 (counting from zero).
4399 Successive subscript operators designate an element of a multidimensional array object.
4400 If E is an n-dimensional array (n >= 2) with dimensions i x j x . . . x k, then E (used as
4401 other than an lvalue) is converted to a pointer to an (n - 1)-dimensional array with
4402 dimensions j x . . . x k. If the unary * operator is applied to this pointer explicitly, or
4403 implicitly as a result of subscripting, the result is the referenced (n - 1)-dimensional
4404 array, which itself is converted into a pointer if used as other than an lvalue. It follows
4405 from this that arrays are stored in row-major order (last subscript varies fastest).
4407 EXAMPLE Consider the array object defined by the declaration
4410 Here x is a 3 x 5 array of ints; more precisely, x is an array of three element objects, each of which is an
4411 array of five ints. In the expression x[i], which is equivalent to (*((x)+(i))), x is first converted to
4412 a pointer to the initial array of five ints. Then i is adjusted according to the type of x, which conceptually
4413 entails multiplying i by the size of the object to which the pointer points, namely an array of five int
4414 objects. The results are added and indirection is applied to yield an array of five ints. When used in the
4415 expression x[i][j], that array is in turn converted to a pointer to the first of the ints, so x[i][j]
4418 Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), address and indirection operators
4419 (<a href="#6.5.3.2">6.5.3.2</a>), array declarators (<a href="#6.7.6.2">6.7.6.2</a>).
4421 <a name="6.5.2.2" href="#6.5.2.2"><h5>6.5.2.2 Function calls</h5></a>
4422 <h6>Constraints</h6>
4424 The expression that denotes the called function<sup><a href="#note92"><b>92)</b></a></sup> shall have type pointer to function
4425 returning void or returning a complete object type other than an array type.
4427 If the expression that denotes the called function has a type that includes a prototype, the
4428 number of arguments shall agree with the number of parameters. Each argument shall
4431 <!--page 99 indent 4-->
4432 have a type such that its value may be assigned to an object with the unqualified version
4433 of the type of its corresponding parameter.
4436 A postfix expression followed by parentheses () containing a possibly empty, comma-
4437 separated list of expressions is a function call. The postfix expression denotes the called
4438 function. The list of expressions specifies the arguments to the function.
4440 An argument may be an expression of any complete object type. In preparing for the call
4441 to a function, the arguments are evaluated, and each parameter is assigned the value of the
4442 corresponding argument.<sup><a href="#note93"><b>93)</b></a></sup>
4444 If the expression that denotes the called function has type pointer to function returning an
4445 object type, the function call expression has the same type as that object type, and has the
4446 value determined as specified in <a href="#6.8.6.4">6.8.6.4</a>. Otherwise, the function call has type void. *
4448 If the expression that denotes the called function has a type that does not include a
4449 prototype, the integer promotions are performed on each argument, and arguments that
4450 have type float are promoted to double. These are called the default argument
4451 promotions. If the number of arguments does not equal the number of parameters, the
4452 behavior is undefined. If the function is defined with a type that includes a prototype, and
4453 either the prototype ends with an ellipsis (, ...) or the types of the arguments after
4454 promotion are not compatible with the types of the parameters, the behavior is undefined.
4455 If the function is defined with a type that does not include a prototype, and the types of
4456 the arguments after promotion are not compatible with those of the parameters after
4457 promotion, the behavior is undefined, except for the following cases:
4459 <li> one promoted type is a signed integer type, the other promoted type is the
4460 corresponding unsigned integer type, and the value is representable in both types;
4461 <li> both types are pointers to qualified or unqualified versions of a character type or
4465 If the expression that denotes the called function has a type that does include a prototype,
4466 the arguments are implicitly converted, as if by assignment, to the types of the
4467 corresponding parameters, taking the type of each parameter to be the unqualified version
4468 of its declared type. The ellipsis notation in a function prototype declarator causes
4469 argument type conversion to stop after the last declared parameter. The default argument
4470 promotions are performed on trailing arguments.
4474 <!--page 100 indent 5-->
4476 No other conversions are performed implicitly; in particular, the number and types of
4477 arguments are not compared with those of the parameters in a function definition that
4478 does not include a function prototype declarator.
4480 If the function is defined with a type that is not compatible with the type (of the
4481 expression) pointed to by the expression that denotes the called function, the behavior is
4484 There is a sequence point after the evaluations of the function designator and the actual
4485 arguments but before the actual call. Every evaluation in the calling function (including
4486 other function calls) that is not otherwise specifically sequenced before or after the
4487 execution of the body of the called function is indeterminately sequenced with respect to
4488 the execution of the called function.<sup><a href="#note94"><b>94)</b></a></sup>
4490 Recursive function calls shall be permitted, both directly and indirectly through any chain
4493 EXAMPLE In the function call
4495 (*pf[f1()]) (f2(), f3() + f4())</pre>
4496 the functions f1, f2, f3, and f4 may be called in any order. All side effects have to be completed before
4497 the function pointed to by pf[f1()] is called.
4499 Forward references: function declarators (including prototypes) (<a href="#6.7.6.3">6.7.6.3</a>), function
4500 definitions (<a href="#6.9.1">6.9.1</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>), simple assignment (<a href="#6.5.16.1">6.5.16.1</a>).
4503 <p><a name="note92">92)</a> Most often, this is the result of converting an identifier that is a function designator.
4505 <p><a name="note93">93)</a> A function may change the values of its parameters, but these changes cannot affect the values of the
4506 arguments. On the other hand, it is possible to pass a pointer to an object, and the function may
4507 change the value of the object pointed to. A parameter declared to have array or function type is
4508 adjusted to have a pointer type as described in <a href="#6.9.1">6.9.1</a>.
4510 <p><a name="note94">94)</a> In other words, function executions do not ''interleave'' with each other.
4513 <a name="6.5.2.3" href="#6.5.2.3"><h5>6.5.2.3 Structure and union members</h5></a>
4514 <h6>Constraints</h6>
4516 The first operand of the . operator shall have an atomic, qualified, or unqualified
4517 structure or union type, and the second operand shall name a member of that type.
4519 The first operand of the -> operator shall have type ''pointer to atomic, qualified, or
4520 unqualified structure'' or ''pointer to atomic, qualified, or unqualified union'', and the
4521 second operand shall name a member of the type pointed to.
4524 A postfix expression followed by the . operator and an identifier designates a member of
4525 a structure or union object. The value is that of the named member,<sup><a href="#note95"><b>95)</b></a></sup> and is an lvalue if
4526 the first expression is an lvalue. If the first expression has qualified type, the result has
4527 the so-qualified version of the type of the designated member.
4529 <!--page 101 indent 4-->
4531 A postfix expression followed by the -> operator and an identifier designates a member
4532 of a structure or union object. The value is that of the named member of the object to
4533 which the first expression points, and is an lvalue.<sup><a href="#note96"><b>96)</b></a></sup> If the first expression is a pointer to
4534 a qualified type, the result has the so-qualified version of the type of the designated
4537 Accessing a member of an atomic structure or union object results in undefined
4538 behavior.<sup><a href="#note97"><b>97)</b></a></sup>
4540 One special guarantee is made in order to simplify the use of unions: if a union contains
4541 several structures that share a common initial sequence (see below), and if the union
4542 object currently contains one of these structures, it is permitted to inspect the common
4543 initial part of any of them anywhere that a declaration of the completed type of the union
4544 is visible. Two structures share a common initial sequence if corresponding members
4545 have compatible types (and, for bit-fields, the same widths) for a sequence of one or more
4548 EXAMPLE 1 If f is a function returning a structure or union, and x is a member of that structure or
4549 union, f().x is a valid postfix expression but is not an lvalue.
4554 struct s { int i; const int ci; };
4557 volatile struct s vs;</pre>
4558 the various members have the types:
4565 vs.ci volatile const int</pre>
4570 <!--page 102 indent 4-->
4572 EXAMPLE 3 The following is a valid fragment:
4588 u.nf.doublenode = <a href="#3.14">3.14</a>;
4590 if (u.n.alltypes == 1)
4591 if (sin(u.nf.doublenode) == 0.0)
4593 The following is not a valid fragment (because the union type is not visible within function f):
4595 struct t1 { int m; };
4596 struct t2 { int m; };
4597 int f(struct t1 *p1, struct t2 *p2)
4599 if (p1->m < 0)
4600 p2->m = -p2->m;
4610 return f(&u.s1, &u.s2);
4613 Forward references: address and indirection operators (<a href="#6.5.3.2">6.5.3.2</a>), structure and union
4614 specifiers (<a href="#6.7.2.1">6.7.2.1</a>).
4615 <!--page 103 indent 4-->
4618 <p><a name="note95">95)</a> If the member used to read the contents of a union object is not the same as the member last used to
4619 store a value in the object, the appropriate part of the object representation of the value is reinterpreted
4620 as an object representation in the new type as described in <a href="#6.2.6">6.2.6</a> (a process sometimes called ''type
4621 punning''). This might be a trap representation.
4623 <p><a name="note96">96)</a> If &E is a valid pointer expression (where & is the ''address-of '' operator, which generates a pointer to
4624 its operand), the expression (&E)->MOS is the same as E.MOS.
4626 <p><a name="note97">97)</a> For example, a data race would occur if access to the entire structure or union in one thread conflicts
4627 with access to a member from another thread, where at least one access is a modification. Members
4628 can be safely accessed using a non-atomic object which is assigned to or from the atomic object.
4631 <a name="6.5.2.4" href="#6.5.2.4"><h5>6.5.2.4 Postfix increment and decrement operators</h5></a>
4632 <h6>Constraints</h6>
4634 The operand of the postfix increment or decrement operator shall have atomic, qualified,
4635 or unqualified real or pointer type, and shall be a modifiable lvalue.
4638 The result of the postfix ++ operator is the value of the operand. As a side effect, the
4639 value of the operand object is incremented (that is, the value 1 of the appropriate type is
4640 added to it). See the discussions of additive operators and compound assignment for
4641 information on constraints, types, and conversions and the effects of operations on
4642 pointers. The value computation of the result is sequenced before the side effect of
4643 updating the stored value of the operand. With respect to an indeterminately-sequenced
4644 function call, the operation of postfix ++ is a single evaluation. Postfix ++ on an object
4645 with atomic type is a read-modify-write operation with memory_order_seq_cst
4646 memory order semantics.<sup><a href="#note98"><b>98)</b></a></sup>
4648 The postfix -- operator is analogous to the postfix ++ operator, except that the value of
4649 the operand is decremented (that is, the value 1 of the appropriate type is subtracted from
4651 Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
4654 <p><a name="note98">98)</a> Where a pointer to an atomic object can be formed, this is equivalent to the following code sequence
4655 where T is the type of E:
4662 } while (!atomic_compare_exchange_strong(&E, &result, tmp));</pre>
4663 with result being the result of the operation.
4666 <a name="6.5.2.5" href="#6.5.2.5"><h5>6.5.2.5 Compound literals</h5></a>
4667 <h6>Constraints</h6>
4669 The type name shall specify a complete object type or an array of unknown size, but not a
4670 variable length array type.
4672 All the constraints for initializer lists in <a href="#6.7.9">6.7.9</a> also apply to compound literals.
4675 A postfix expression that consists of a parenthesized type name followed by a brace-
4676 enclosed list of initializers is a compound literal. It provides an unnamed object whose
4677 value is given by the initializer list.<sup><a href="#note99"><b>99)</b></a></sup>
4680 <!--page 104 indent 5-->
4682 If the type name specifies an array of unknown size, the size is determined by the
4683 initializer list as specified in <a href="#6.7.9">6.7.9</a>, and the type of the compound literal is that of the
4684 completed array type. Otherwise (when the type name specifies an object type), the type
4685 of the compound literal is that specified by the type name. In either case, the result is an
4688 The value of the compound literal is that of an unnamed object initialized by the
4689 initializer list. If the compound literal occurs outside the body of a function, the object
4690 has static storage duration; otherwise, it has automatic storage duration associated with
4691 the enclosing block.
4693 All the semantic rules for initializer lists in <a href="#6.7.9">6.7.9</a> also apply to compound literals.<sup><a href="#note100"><b>100)</b></a></sup>
4695 String literals, and compound literals with const-qualified types, need not designate
4696 distinct objects.<sup><a href="#note101"><b>101)</b></a></sup>
4698 EXAMPLE 1 The file scope definition
4700 int *p = (int []){2, 4};</pre>
4701 initializes p to point to the first element of an array of two ints, the first having the value two and the
4702 second, four. The expressions in this compound literal are required to be constant. The unnamed object
4703 has static storage duration.
4706 EXAMPLE 2 In contrast, in
4715 p is assigned the address of the first element of an array of two ints, the first having the value previously
4716 pointed to by p and the second, zero. The expressions in this compound literal need not be constant. The
4717 unnamed object has automatic storage duration.
4720 EXAMPLE 3 Initializers with designations can be combined with compound literals. Structure objects
4721 created using compound literals can be passed to functions without depending on member order:
4723 drawline((struct point){.x=1, .y=1},
4724 (struct point){.x=3, .y=4});</pre>
4725 Or, if drawline instead expected pointers to struct point:
4729 <!--page 105 indent 5-->
4731 drawline(&(struct point){.x=1, .y=1},
4732 &(struct point){.x=3, .y=4});</pre>
4735 EXAMPLE 4 A read-only compound literal can be specified through constructions like:
4737 (const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6}</pre>
4740 EXAMPLE 5 The following three expressions have different meanings:
4743 (char []){"/tmp/fileXXXXXX"}
4744 (const char []){"/tmp/fileXXXXXX"}</pre>
4745 The first always has static storage duration and has type array of char, but need not be modifiable; the last
4746 two have automatic storage duration when they occur within the body of a function, and the first of these
4750 EXAMPLE 6 Like string literals, const-qualified compound literals can be placed into read-only memory
4751 and can even be shared. For example,
4753 (const char []){"abc"} == "abc"</pre>
4754 might yield 1 if the literals' storage is shared.
4757 EXAMPLE 7 Since compound literals are unnamed, a single compound literal cannot specify a circularly
4758 linked object. For example, there is no way to write a self-referential compound literal that could be used
4759 as the function argument in place of the named object endless_zeros below:
4761 struct int_list { int car; struct int_list *cdr; };
4762 struct int_list endless_zeros = {0, &endless_zeros};
4763 eval(endless_zeros);</pre>
4766 EXAMPLE 8 Each compound literal creates only a single object in a given scope:
4768 struct s { int i; };
4771 struct s *p = 0, *q;
4774 q = p, p = &((struct s){ j++ });
4775 if (j < 2) goto again;
4776 return p == q && q->i == 1;
4778 The function f() always returns the value 1.
4780 Note that if an iteration statement were used instead of an explicit goto and a labeled statement, the
4781 lifetime of the unnamed object would be the body of the loop only, and on entry next time around p would
4782 have an indeterminate value, which would result in undefined behavior.
4784 Forward references: type names (<a href="#6.7.7">6.7.7</a>), initialization (<a href="#6.7.9">6.7.9</a>).
4785 <!--page 106 indent 4-->
4788 <p><a name="note99">99)</a> Note that this differs from a cast expression. For example, a cast specifies a conversion to scalar types
4789 or void only, and the result of a cast expression is not an lvalue.
4791 <p><a name="note100">100)</a> For example, subobjects without explicit initializers are initialized to zero.
4793 <p><a name="note101">101)</a> This allows implementations to share storage for string literals and constant compound literals with
4794 the same or overlapping representations.
4797 <a name="6.5.3" href="#6.5.3"><h4>6.5.3 Unary operators</h4></a>
4805 unary-operator cast-expression
4806 sizeof unary-expression
4807 sizeof ( type-name )
4808 alignof ( type-name )
4809 unary-operator: one of
4810 & * + - ~ !</pre>
4812 <a name="6.5.3.1" href="#6.5.3.1"><h5>6.5.3.1 Prefix increment and decrement operators</h5></a>
4813 <h6>Constraints</h6>
4815 The operand of the prefix increment or decrement operator shall have atomic, qualified,
4816 or unqualified real or pointer type, and shall be a modifiable lvalue.
4819 The value of the operand of the prefix ++ operator is incremented. The result is the new
4820 value of the operand after incrementation. The expression ++E is equivalent to (E+=1).
4821 See the discussions of additive operators and compound assignment for information on
4822 constraints, types, side effects, and conversions and the effects of operations on pointers.
4824 The prefix -- operator is analogous to the prefix ++ operator, except that the value of the
4825 operand is decremented.
4826 Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
4828 <a name="6.5.3.2" href="#6.5.3.2"><h5>6.5.3.2 Address and indirection operators</h5></a>
4829 <h6>Constraints</h6>
4831 The operand of the unary & operator shall be either a function designator, the result of a
4832 [] or unary * operator, or an lvalue that designates an object that is not a bit-field and is
4833 not declared with the register storage-class specifier.
4835 The operand of the unary * operator shall have pointer type.
4838 The unary & operator yields the address of its operand. If the operand has type ''type'',
4839 the result has type ''pointer to type''. If the operand is the result of a unary * operator,
4840 neither that operator nor the & operator is evaluated and the result is as if both were
4841 omitted, except that the constraints on the operators still apply and the result is not an
4842 <!--page 107 indent 4-->
4843 lvalue. Similarly, if the operand is the result of a [] operator, neither the & operator nor
4844 the unary * that is implied by the [] is evaluated and the result is as if the & operator
4845 were removed and the [] operator were changed to a + operator. Otherwise, the result is
4846 a pointer to the object or function designated by its operand.
4848 The unary * operator denotes indirection. If the operand points to a function, the result is
4849 a function designator; if it points to an object, the result is an lvalue designating the
4850 object. If the operand has type ''pointer to type'', the result has type ''type''. If an
4851 invalid value has been assigned to the pointer, the behavior of the unary * operator is
4852 undefined.<sup><a href="#note102"><b>102)</b></a></sup>
4853 Forward references: storage-class specifiers (<a href="#6.7.1">6.7.1</a>), structure and union specifiers
4854 (<a href="#6.7.2.1">6.7.2.1</a>).
4857 <p><a name="note102">102)</a> Thus, &*E is equivalent to E (even if E is a null pointer), and &(E1[E2]) to ((E1)+(E2)). It is
4858 always true that if E is a function designator or an lvalue that is a valid operand of the unary &
4859 operator, *&E is a function designator or an lvalue equal to E. If *P is an lvalue and T is the name of
4860 an object pointer type, *(T)P is an lvalue that has a type compatible with that to which T points.
4861 Among the invalid values for dereferencing a pointer by the unary * operator are a null pointer, an
4862 address inappropriately aligned for the type of object pointed to, and the address of an object after the
4863 end of its lifetime.
4866 <a name="6.5.3.3" href="#6.5.3.3"><h5>6.5.3.3 Unary arithmetic operators</h5></a>
4867 <h6>Constraints</h6>
4869 The operand of the unary + or - operator shall have arithmetic type; of the ~ operator,
4870 integer type; of the ! operator, scalar type.
4873 The result of the unary + operator is the value of its (promoted) operand. The integer
4874 promotions are performed on the operand, and the result has the promoted type.
4876 The result of the unary - operator is the negative of its (promoted) operand. The integer
4877 promotions are performed on the operand, and the result has the promoted type.
4879 The result of the ~ operator is the bitwise complement of its (promoted) operand (that is,
4880 each bit in the result is set if and only if the corresponding bit in the converted operand is
4881 not set). The integer promotions are performed on the operand, and the result has the
4882 promoted type. If the promoted type is an unsigned type, the expression ~E is equivalent
4883 to the maximum value representable in that type minus E.
4885 The result of the logical negation operator ! is 0 if the value of its operand compares
4886 unequal to 0, 1 if the value of its operand compares equal to 0. The result has type int.
4887 The expression !E is equivalent to (0==E).
4891 <!--page 108 indent 4-->
4893 <a name="6.5.3.4" href="#6.5.3.4"><h5>6.5.3.4 The sizeof and alignof operators</h5></a>
4894 <h6>Constraints</h6>
4896 The sizeof operator shall not be applied to an expression that has function type or an
4897 incomplete type, to the parenthesized name of such a type, or to an expression that
4898 designates a bit-field member. The alignof operator shall not be applied to a function
4899 type or an incomplete type.
4902 The sizeof operator yields the size (in bytes) of its operand, which may be an
4903 expression or the parenthesized name of a type. The size is determined from the type of
4904 the operand. The result is an integer. If the type of the operand is a variable length array
4905 type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an
4908 The alignof operator yields the alignment requirement of its operand type. The result
4909 is an integer constant. When applied to an array type, the result is the alignment
4910 requirement of the element type.
4912 When sizeof is applied to an operand that has type char, unsigned char, or
4913 signed char, (or a qualified version thereof) the result is 1. When applied to an
4914 operand that has array type, the result is the total number of bytes in the array.<sup><a href="#note103"><b>103)</b></a></sup> When
4915 applied to an operand that has structure or union type, the result is the total number of
4916 bytes in such an object, including internal and trailing padding.
4918 The value of the result of both operators is implementation-defined, and its type (an
4919 unsigned integer type) is size_t, defined in <stddef.h> (and other headers).
4921 EXAMPLE 1 A principal use of the sizeof operator is in communication with routines such as storage
4922 allocators and I/O systems. A storage-allocation function might accept a size (in bytes) of an object to
4923 allocate and return a pointer to void. For example:
4925 extern void *alloc(size_t);
4926 double *dp = alloc(sizeof *dp);</pre>
4927 The implementation of the alloc function should ensure that its return value is aligned suitably for
4928 conversion to a pointer to double.
4931 EXAMPLE 2 Another use of the sizeof operator is to compute the number of elements in an array:
4933 sizeof array / sizeof array[0]</pre>
4936 EXAMPLE 3 In this example, the size of a variable length array is computed and returned from a
4939 #include <stddef.h></pre>
4943 <!--page 109 indent 4-->
4945 size_t fsize3(int n)
4947 char b[n+3]; // variable length array
4948 return sizeof b; // execution time sizeof
4953 size = fsize3(10); // fsize3 returns 13
4957 Forward references: common definitions <stddef.h> (<a href="#7.19">7.19</a>), declarations (<a href="#6.7">6.7</a>),
4958 structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), type names (<a href="#6.7.7">6.7.7</a>), array declarators (<a href="#6.7.6.2">6.7.6.2</a>).
4961 <p><a name="note103">103)</a> When applied to a parameter declared to have array or function type, the sizeof operator yields the
4962 size of the adjusted (pointer) type (see <a href="#6.9.1">6.9.1</a>).
4965 <a name="6.5.4" href="#6.5.4"><h4>6.5.4 Cast operators</h4></a>
4971 ( type-name ) cast-expression</pre>
4972 <h6>Constraints</h6>
4974 Unless the type name specifies a void type, the type name shall specify atomic, qualified,
4975 or unqualified scalar type, and the operand shall have scalar type.
4977 Conversions that involve pointers, other than where permitted by the constraints of
4978 <a href="#6.5.16.1">6.5.16.1</a>, shall be specified by means of an explicit cast.
4980 A pointer type shall not be converted to any floating type. A floating type shall not be
4981 converted to any pointer type.
4984 Preceding an expression by a parenthesized type name converts the value of the
4985 expression to the named type. This construction is called a cast.<sup><a href="#note104"><b>104)</b></a></sup> A cast that specifies
4986 no conversion has no effect on the type or value of an expression.
4988 If the value of the expression is represented with greater precision or range than required
4989 by the type named by the cast (<a href="#6.3.1.8">6.3.1.8</a>), then the cast specifies a conversion even if the
4990 type of the expression is the same as the named type and removes any extra range and
4992 Forward references: equality operators (<a href="#6.5.9">6.5.9</a>), function declarators (including
4993 prototypes) (<a href="#6.7.6.3">6.7.6.3</a>), simple assignment (<a href="#6.5.16.1">6.5.16.1</a>), type names (<a href="#6.7.7">6.7.7</a>).
4995 <!--page 110 indent 4-->
4998 <p><a name="note104">104)</a> A cast does not yield an lvalue. Thus, a cast to a qualified type has the same effect as a cast to the
4999 unqualified version of the type.
5002 <a name="6.5.5" href="#6.5.5"><h4>6.5.5 Multiplicative operators</h4></a>
5006 multiplicative-expression:
5008 multiplicative-expression * cast-expression
5009 multiplicative-expression / cast-expression
5010 multiplicative-expression % cast-expression</pre>
5011 <h6>Constraints</h6>
5013 Each of the operands shall have arithmetic type. The operands of the % operator shall
5017 The usual arithmetic conversions are performed on the operands.
5019 The result of the binary * operator is the product of the operands.
5021 The result of the / operator is the quotient from the division of the first operand by the
5022 second; the result of the % operator is the remainder. In both operations, if the value of
5023 the second operand is zero, the behavior is undefined.
5025 When integers are divided, the result of the / operator is the algebraic quotient with any
5026 fractional part discarded.<sup><a href="#note105"><b>105)</b></a></sup> If the quotient a/b is representable, the expression
5027 (a/b)*b + a%b shall equal a; otherwise, the behavior of both a/b and a%b is
5031 <p><a name="note105">105)</a> This is often called ''truncation toward zero''.
5034 <a name="6.5.6" href="#6.5.6"><h4>6.5.6 Additive operators</h4></a>
5038 additive-expression:
5039 multiplicative-expression
5040 additive-expression + multiplicative-expression
5041 additive-expression - multiplicative-expression</pre>
5042 <h6>Constraints</h6>
5044 For addition, either both operands shall have arithmetic type, or one operand shall be a
5045 pointer to a complete object type and the other shall have integer type. (Incrementing is
5046 equivalent to adding 1.)
5048 For subtraction, one of the following shall hold:
5053 <!--page 111 indent 4-->
5055 <li> both operands have arithmetic type;
5056 <li> both operands are pointers to qualified or unqualified versions of compatible complete
5058 <li> the left operand is a pointer to a complete object type and the right operand has
5061 (Decrementing is equivalent to subtracting 1.)
5064 If both operands have arithmetic type, the usual arithmetic conversions are performed on
5067 The result of the binary + operator is the sum of the operands.
5069 The result of the binary - operator is the difference resulting from the subtraction of the
5070 second operand from the first.
5072 For the purposes of these operators, a pointer to an object that is not an element of an
5073 array behaves the same as a pointer to the first element of an array of length one with the
5074 type of the object as its element type.
5076 When an expression that has integer type is added to or subtracted from a pointer, the
5077 result has the type of the pointer operand. If the pointer operand points to an element of
5078 an array object, and the array is large enough, the result points to an element offset from
5079 the original element such that the difference of the subscripts of the resulting and original
5080 array elements equals the integer expression. In other words, if the expression P points to
5081 the i-th element of an array object, the expressions (P)+N (equivalently, N+(P)) and
5082 (P)-N (where N has the value n) point to, respectively, the i+n-th and i-n-th elements of
5083 the array object, provided they exist. Moreover, if the expression P points to the last
5084 element of an array object, the expression (P)+1 points one past the last element of the
5085 array object, and if the expression Q points one past the last element of an array object,
5086 the expression (Q)-1 points to the last element of the array object. If both the pointer
5087 operand and the result point to elements of the same array object, or one past the last
5088 element of the array object, the evaluation shall not produce an overflow; otherwise, the
5089 behavior is undefined. If the result points one past the last element of the array object, it
5090 shall not be used as the operand of a unary * operator that is evaluated.
5092 When two pointers are subtracted, both shall point to elements of the same array object,
5093 or one past the last element of the array object; the result is the difference of the
5094 subscripts of the two array elements. The size of the result is implementation-defined,
5095 and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header.
5096 If the result is not representable in an object of that type, the behavior is undefined. In
5097 other words, if the expressions P and Q point to, respectively, the i-th and j-th elements of
5098 an array object, the expression (P)-(Q) has the value i-j provided the value fits in an
5099 <!--page 112 indent 5-->
5100 object of type ptrdiff_t. Moreover, if the expression P points either to an element of
5101 an array object or one past the last element of an array object, and the expression Q points
5102 to the last element of the same array object, the expression ((Q)+1)-(P) has the same
5103 value as ((Q)-(P))+1 and as -((P)-((Q)+1)), and has the value zero if the
5104 expression P points one past the last element of the array object, even though the
5105 expression (Q)+1 does not point to an element of the array object.<sup><a href="#note106"><b>106)</b></a></sup>
5107 EXAMPLE Pointer arithmetic is well defined with pointers to variable length array types.
5113 int (*p)[m] = a; // p == &a[0]
5114 p += 1; // p == &a[1]
5115 (*p)[2] = 99; // a[1][2] == 99
5116 n = p - a; // n == 1
5118 If array a in the above example were declared to be an array of known constant size, and pointer p were
5119 declared to be a pointer to an array of the same known constant size (pointing to a), the results would be
5122 Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), common definitions <stddef.h>
5123 (<a href="#7.19">7.19</a>).
5126 <p><a name="note106">106)</a> Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In
5127 this scheme the integer expression added to or subtracted from the converted pointer is first multiplied
5128 by the size of the object originally pointed to, and the resulting pointer is converted back to the
5129 original type. For pointer subtraction, the result of the difference between the character pointers is
5130 similarly divided by the size of the object originally pointed to.
5131 When viewed in this way, an implementation need only provide one extra byte (which may overlap
5132 another object in the program) just after the end of the object in order to satisfy the ''one past the last
5133 element'' requirements.
5136 <a name="6.5.7" href="#6.5.7"><h4>6.5.7 Bitwise shift operators</h4></a>
5142 shift-expression << additive-expression
5143 shift-expression >> additive-expression</pre>
5144 <h6>Constraints</h6>
5146 Each of the operands shall have integer type.
5149 The integer promotions are performed on each of the operands. The type of the result is
5150 that of the promoted left operand. If the value of the right operand is negative or is
5152 <!--page 113 indent 4-->
5153 greater than or equal to the width of the promoted left operand, the behavior is undefined.
5155 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with
5156 zeros. If E1 has an unsigned type, the value of the result is E1 x 2E2 , reduced modulo
5157 one more than the maximum value representable in the result type. If E1 has a signed
5158 type and nonnegative value, and E1 x 2E2 is representable in the result type, then that is
5159 the resulting value; otherwise, the behavior is undefined.
5161 The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type
5162 or if E1 has a signed type and a nonnegative value, the value of the result is the integral
5163 part of the quotient of E1 / 2E2 . If E1 has a signed type and a negative value, the
5164 resulting value is implementation-defined.
5166 <a name="6.5.8" href="#6.5.8"><h4>6.5.8 Relational operators</h4></a>
5170 relational-expression:
5172 relational-expression < shift-expression
5173 relational-expression > shift-expression
5174 relational-expression <= shift-expression
5175 relational-expression >= shift-expression</pre>
5176 <h6>Constraints</h6>
5178 One of the following shall hold:
5180 <li> both operands have real type; or *
5181 <li> both operands are pointers to qualified or unqualified versions of compatible object
5186 If both of the operands have arithmetic type, the usual arithmetic conversions are
5189 For the purposes of these operators, a pointer to an object that is not an element of an
5190 array behaves the same as a pointer to the first element of an array of length one with the
5191 type of the object as its element type.
5193 When two pointers are compared, the result depends on the relative locations in the
5194 address space of the objects pointed to. If two pointers to object types both point to the
5195 same object, or both point one past the last element of the same array object, they
5196 compare equal. If the objects pointed to are members of the same aggregate object,
5197 pointers to structure members declared later compare greater than pointers to members
5198 declared earlier in the structure, and pointers to array elements with larger subscript
5199 values compare greater than pointers to elements of the same array with lower subscript
5200 <!--page 114 indent 4-->
5201 values. All pointers to members of the same union object compare equal. If the
5202 expression P points to an element of an array object and the expression Q points to the
5203 last element of the same array object, the pointer expression Q+1 compares greater than
5204 P. In all other cases, the behavior is undefined.
5206 Each of the operators < (less than), > (greater than), <= (less than or equal to), and >=
5207 (greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is
5208 false.<sup><a href="#note107"><b>107)</b></a></sup> The result has type int.
5211 <p><a name="note107">107)</a> The expression a<b<c is not interpreted as in ordinary mathematics. As the syntax indicates, it
5212 means (a<b)<c; in other words, ''if a is less than b, compare 1 to c; otherwise, compare 0 to c''.
5215 <a name="6.5.9" href="#6.5.9"><h4>6.5.9 Equality operators</h4></a>
5219 equality-expression:
5220 relational-expression
5221 equality-expression == relational-expression
5222 equality-expression != relational-expression</pre>
5223 <h6>Constraints</h6>
5225 One of the following shall hold:
5227 <li> both operands have arithmetic type;
5228 <li> both operands are pointers to qualified or unqualified versions of compatible types;
5229 <li> one operand is a pointer to an object type and the other is a pointer to a qualified or
5230 unqualified version of void; or
5231 <li> one operand is a pointer and the other is a null pointer constant.
5235 The == (equal to) and != (not equal to) operators are analogous to the relational
5236 operators except for their lower precedence.<sup><a href="#note108"><b>108)</b></a></sup> Each of the operators yields 1 if the
5237 specified relation is true and 0 if it is false. The result has type int. For any pair of
5238 operands, exactly one of the relations is true.
5240 If both of the operands have arithmetic type, the usual arithmetic conversions are
5241 performed. Values of complex types are equal if and only if both their real parts are equal
5242 and also their imaginary parts are equal. Any two values of arithmetic types from
5243 different type domains are equal if and only if the results of their conversions to the
5244 (complex) result type determined by the usual arithmetic conversions are equal.
5248 <!--page 115 indent 4-->
5250 Otherwise, at least one operand is a pointer. If one operand is a pointer and the other is a
5251 null pointer constant, the null pointer constant is converted to the type of the pointer. If
5252 one operand is a pointer to an object type and the other is a pointer to a qualified or
5253 unqualified version of void, the former is converted to the type of the latter.
5255 Two pointers compare equal if and only if both are null pointers, both are pointers to the
5256 same object (including a pointer to an object and a subobject at its beginning) or function,
5257 both are pointers to one past the last element of the same array object, or one is a pointer
5258 to one past the end of one array object and the other is a pointer to the start of a different
5259 array object that happens to immediately follow the first array object in the address
5260 space.<sup><a href="#note109"><b>109)</b></a></sup>
5262 For the purposes of these operators, a pointer to an object that is not an element of an
5263 array behaves the same as a pointer to the first element of an array of length one with the
5264 type of the object as its element type.
5267 <p><a name="note108">108)</a> Because of the precedences, a<b == c<d is 1 whenever a<b and c<d have the same truth-value.
5269 <p><a name="note109">109)</a> Two objects may be adjacent in memory because they are adjacent elements of a larger array or
5270 adjacent members of a structure with no padding between them, or because the implementation chose
5271 to place them so, even though they are unrelated. If prior invalid pointer operations (such as accesses
5272 outside array bounds) produced undefined behavior, subsequent comparisons also produce undefined
5276 <a name="6.5.10" href="#6.5.10"><h4>6.5.10 Bitwise AND operator</h4></a>
5282 AND-expression & equality-expression</pre>
5283 <h6>Constraints</h6>
5285 Each of the operands shall have integer type.
5288 The usual arithmetic conversions are performed on the operands.
5290 The result of the binary & operator is the bitwise AND of the operands (that is, each bit in
5291 the result is set if and only if each of the corresponding bits in the converted operands is
5297 <!--page 116 indent 4-->
5299 <a name="6.5.11" href="#6.5.11"><h4>6.5.11 Bitwise exclusive OR operator</h4></a>
5303 exclusive-OR-expression:
5305 exclusive-OR-expression ^ AND-expression</pre>
5306 <h6>Constraints</h6>
5308 Each of the operands shall have integer type.
5311 The usual arithmetic conversions are performed on the operands.
5313 The result of the ^ operator is the bitwise exclusive OR of the operands (that is, each bit
5314 in the result is set if and only if exactly one of the corresponding bits in the converted
5317 <a name="6.5.12" href="#6.5.12"><h4>6.5.12 Bitwise inclusive OR operator</h4></a>
5321 inclusive-OR-expression:
5322 exclusive-OR-expression
5323 inclusive-OR-expression | exclusive-OR-expression</pre>
5324 <h6>Constraints</h6>
5326 Each of the operands shall have integer type.
5329 The usual arithmetic conversions are performed on the operands.
5331 The result of the | operator is the bitwise inclusive OR of the operands (that is, each bit in
5332 the result is set if and only if at least one of the corresponding bits in the converted
5334 <!--page 117 indent 4-->
5336 <a name="6.5.13" href="#6.5.13"><h4>6.5.13 Logical AND operator</h4></a>
5340 logical-AND-expression:
5341 inclusive-OR-expression
5342 logical-AND-expression && inclusive-OR-expression</pre>
5343 <h6>Constraints</h6>
5345 Each of the operands shall have scalar type.
5348 The && operator shall yield 1 if both of its operands compare unequal to 0; otherwise, it
5349 yields 0. The result has type int.
5351 Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation;
5352 if the second operand is evaluated, there is a sequence point between the evaluations of
5353 the first and second operands. If the first operand compares equal to 0, the second
5354 operand is not evaluated.
5356 <a name="6.5.14" href="#6.5.14"><h4>6.5.14 Logical OR operator</h4></a>
5360 logical-OR-expression:
5361 logical-AND-expression
5362 logical-OR-expression || logical-AND-expression</pre>
5363 <h6>Constraints</h6>
5365 Each of the operands shall have scalar type.
5368 The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it
5369 yields 0. The result has type int.
5371 Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; if the
5372 second operand is evaluated, there is a sequence point between the evaluations of the first
5373 and second operands. If the first operand compares unequal to 0, the second operand is
5375 <!--page 118 indent 4-->
5377 <a name="6.5.15" href="#6.5.15"><h4>6.5.15 Conditional operator</h4></a>
5381 conditional-expression:
5382 logical-OR-expression
5383 logical-OR-expression ? expression : conditional-expression</pre>
5384 <h6>Constraints</h6>
5386 The first operand shall have scalar type.
5388 One of the following shall hold for the second and third operands:
5390 <li> both operands have arithmetic type;
5391 <li> both operands have the same structure or union type;
5392 <li> both operands have void type;
5393 <li> both operands are pointers to qualified or unqualified versions of compatible types;
5394 <li> one operand is a pointer and the other is a null pointer constant; or
5395 <li> one operand is a pointer to an object type and the other is a pointer to a qualified or
5396 unqualified version of void.
5400 The first operand is evaluated; there is a sequence point between its evaluation and the
5401 evaluation of the second or third operand (whichever is evaluated). The second operand
5402 is evaluated only if the first compares unequal to 0; the third operand is evaluated only if
5403 the first compares equal to 0; the result is the value of the second or third operand
5404 (whichever is evaluated), converted to the type described below.<sup><a href="#note110"><b>110)</b></a></sup> *
5406 If both the second and third operands have arithmetic type, the result type that would be
5407 determined by the usual arithmetic conversions, were they applied to those two operands,
5408 is the type of the result. If both the operands have structure or union type, the result has
5409 that type. If both operands have void type, the result has void type.
5411 If both the second and third operands are pointers or one is a null pointer constant and the
5412 other is a pointer, the result type is a pointer to a type qualified with all the type qualifiers
5413 of the types referenced by both operands. Furthermore, if both operands are pointers to
5414 compatible types or to differently qualified versions of compatible types, the result type is
5415 a pointer to an appropriately qualified version of the composite type; if one operand is a
5416 null pointer constant, the result has the type of the other operand; otherwise, one operand
5417 is a pointer to void or a qualified version of void, in which case the result type is a
5418 pointer to an appropriately qualified version of void.
5420 <!--page 119 indent 4-->
5422 EXAMPLE The common type that results when the second and third operands are pointers is determined
5423 in two independent stages. The appropriate qualifiers, for example, do not depend on whether the two
5424 pointers have compatible types.
5426 Given the declarations
5433 const char *c_cp;</pre>
5434 the third column in the following table is the common type that is the result of a conditional expression in
5435 which the first two columns are the second and third operands (in either order):
5437 c_vp c_ip const void *
5438 v_ip 0 volatile int *
5439 c_ip v_ip const volatile int *
5440 vp c_cp const void *
5446 <p><a name="note110">110)</a> A conditional expression does not yield an lvalue.
5449 <a name="6.5.16" href="#6.5.16"><h4>6.5.16 Assignment operators</h4></a>
5453 assignment-expression:
5454 conditional-expression
5455 unary-expression assignment-operator assignment-expression
5456 assignment-operator: one of
5457 = *= /= %= += -= <<= >>= &= ^= |=</pre>
5458 <h6>Constraints</h6>
5460 An assignment operator shall have a modifiable lvalue as its left operand.
5463 An assignment operator stores a value in the object designated by the left operand. An
5464 assignment expression has the value of the left operand after the assignment,<sup><a href="#note111"><b>111)</b></a></sup> but is not
5465 an lvalue. The type of an assignment expression is the type the left operand would have
5466 after lvalue conversion. The side effect of updating the stored value of the left operand is
5467 sequenced after the value computations of the left and right operands. The evaluations of
5468 the operands are unsequenced.
5473 <!--page 120 indent 4-->
5476 <p><a name="note111">111)</a> The implementation is permitted to read the object to determine the value but is not required to, even
5477 when the object has volatile-qualified type.
5480 <a name="6.5.16.1" href="#6.5.16.1"><h5>6.5.16.1 Simple assignment</h5></a>
5481 <h6>Constraints</h6>
5483 One of the following shall hold:<sup><a href="#note112"><b>112)</b></a></sup>
5485 <li> the left operand has atomic, qualified, or unqualified arithmetic type, and the right has
5487 <li> the left operand has an atomic, qualified, or unqualified version of a structure or union
5488 type compatible with the type of the right;
5489 <li> the left operand has atomic, qualified, or unqualified pointer type, and (considering
5490 the type the left operand would have after lvalue conversion) both operands are
5491 pointers to qualified or unqualified versions of compatible types, and the type pointed
5492 to by the left has all the qualifiers of the type pointed to by the right;
5493 <li> the left operand has atomic, qualified, or unqualified pointer type, and (considering
5494 the type the left operand would have after lvalue conversion) one operand is a pointer
5495 to an object type, and the other is a pointer to a qualified or unqualified version of
5496 void, and the type pointed to by the left has all the qualifiers of the type pointed to
5498 <li> the left operand is an atomic, qualified, or unqualified pointer, and the right is a null
5499 pointer constant; or
5500 <li> the left operand has type atomic, qualified, or unqualified _Bool, and the right is a
5505 In simple assignment (=), the value of the right operand is converted to the type of the
5506 assignment expression and replaces the value stored in the object designated by the left
5509 If the value being stored in an object is read from another object that overlaps in any way
5510 the storage of the first object, then the overlap shall be exact and the two objects shall
5511 have qualified or unqualified versions of a compatible type; otherwise, the behavior is
5514 EXAMPLE 1 In the program fragment
5519 <!--page 121 indent 4-->
5524 if ((c = f()) == -1)
5526 the int value returned by the function may be truncated when stored in the char, and then converted back
5527 to int width prior to the comparison. In an implementation in which ''plain'' char has the same range of
5528 values as unsigned char (and char is narrower than int), the result of the conversion cannot be
5529 negative, so the operands of the comparison can never compare equal. Therefore, for full portability, the
5530 variable c should be declared as int.
5533 EXAMPLE 2 In the fragment:
5539 the value of i is converted to the type of the assignment expression c = i, that is, char type. The value
5540 of the expression enclosed in parentheses is then converted to the type of the outer assignment expression,
5541 that is, long int type.
5544 EXAMPLE 3 Consider the fragment:
5549 cpp = &p; // constraint violation
5550 *cpp = &c; // valid
5551 *p = 0; // valid</pre>
5552 The first assignment is unsafe because it would allow the following valid code to attempt to change the
5553 value of the const object c.
5557 <p><a name="note112">112)</a> The asymmetric appearance of these constraints with respect to type qualifiers is due to the conversion
5558 (specified in <a href="#6.3.2.1">6.3.2.1</a>) that changes lvalues to ''the value of the expression'' and thus removes any type
5559 qualifiers that were applied to the type category of the expression (for example, it removes const but
5560 not volatile from the type int volatile * const).
5563 <a name="6.5.16.2" href="#6.5.16.2"><h5>6.5.16.2 Compound assignment</h5></a>
5564 <h6>Constraints</h6>
5566 For the operators += and -= only, either the left operand shall be an atomic, qualified, or
5567 unqualified pointer to a complete object type, and the right shall have integer type; or the
5568 left operand shall have atomic, qualified, or unqualified arithmetic type, and the right
5569 shall have arithmetic type.
5571 For the other operators, the left operand shall have atomic, qualified, or unqualified
5572 arithmetic type, and (considering the type the left operand would have after lvalue
5573 conversion) each operand shall have arithmetic type consistent with those allowed by the
5574 corresponding binary operator.
5577 A compound assignment of the form E1 op = E2 is equivalent to the simple assignment
5578 expression E1 = E1 op (E2), except that the lvalue E1 is evaluated only once, and with
5579 respect to an indeterminately-sequenced function call, the operation of a compound
5580 <!--page 122 indent 4-->
5581 assignment is a single evaluation. If E1 has an atomic type, compound assignment is a
5582 read-modify-write operation with memory_order_seq_cst memory order
5583 semantics.<sup><a href="#note113"><b>113)</b></a></sup>
5586 <p><a name="note113">113)</a> Where a pointer to an atomic object can be formed, this is equivalent to the following code sequence
5587 where T is the type of E1:
5593 result = tmp op (E2);
5594 } while (!atomic_compare_exchange_strong(&E1, &tmp, result));</pre>
5595 with result being the result of the operation.
5598 <a name="6.5.17" href="#6.5.17"><h4>6.5.17 Comma operator</h4></a>
5603 assignment-expression
5604 expression , assignment-expression</pre>
5607 The left operand of a comma operator is evaluated as a void expression; there is a
5608 sequence point between its evaluation and that of the right operand. Then the right
5609 operand is evaluated; the result has its type and value.<sup><a href="#note114"><b>114)</b></a></sup> *
5611 EXAMPLE As indicated by the syntax, the comma operator (as described in this subclause) cannot
5612 appear in contexts where a comma is used to separate items in a list (such as arguments to functions or lists
5613 of initializers). On the other hand, it can be used within a parenthesized expression or within the second
5614 expression of a conditional operator in such contexts. In the function call
5616 f(a, (t=3, t+2), c)</pre>
5617 the function has three arguments, the second of which has the value 5.
5619 Forward references: initialization (<a href="#6.7.9">6.7.9</a>).
5624 <!--page 123 indent 4-->
5627 <p><a name="note114">114)</a> A comma operator does not yield an lvalue.
5630 <a name="6.6" href="#6.6"><h3>6.6 Constant expressions</h3></a>
5634 constant-expression:
5635 conditional-expression</pre>
5636 <h6>Description</h6>
5638 A constant expression can be evaluated during translation rather than runtime, and
5639 accordingly may be used in any place that a constant may be.
5640 <h6>Constraints</h6>
5642 Constant expressions shall not contain assignment, increment, decrement, function-call,
5643 or comma operators, except when they are contained within a subexpression that is not
5644 evaluated.<sup><a href="#note115"><b>115)</b></a></sup>
5646 Each constant expression shall evaluate to a constant that is in the range of representable
5647 values for its type.
5650 An expression that evaluates to a constant is required in several contexts. If a floating
5651 expression is evaluated in the translation environment, the arithmetic precision and range
5652 shall be at least as great as if the expression were being evaluated in the execution
5653 environment.<sup><a href="#note116"><b>116)</b></a></sup>
5655 An integer constant expression<sup><a href="#note117"><b>117)</b></a></sup> shall have integer type and shall only have operands
5656 that are integer constants, enumeration constants, character constants, sizeof
5657 expressions whose results are integer constants, and floating constants that are the
5658 immediate operands of casts. Cast operators in an integer constant expression shall only
5659 convert arithmetic types to integer types, except as part of an operand to the sizeof
5662 More latitude is permitted for constant expressions in initializers. Such a constant
5663 expression shall be, or evaluate to, one of the following:
5665 <li> an arithmetic constant expression,
5669 <!--page 124 indent 5-->
5670 <li> a null pointer constant,
5671 <li> an address constant, or
5672 <li> an address constant for a complete object type plus or minus an integer constant
5676 An arithmetic constant expression shall have arithmetic type and shall only have
5677 operands that are integer constants, floating constants, enumeration constants, character
5678 constants, and sizeof expressions. Cast operators in an arithmetic constant expression
5679 shall only convert arithmetic types to arithmetic types, except as part of an operand to a
5680 sizeof operator whose result is an integer constant.
5682 An address constant is a null pointer, a pointer to an lvalue designating an object of static
5683 storage duration, or a pointer to a function designator; it shall be created explicitly using
5684 the unary & operator or an integer constant cast to pointer type, or implicitly by the use of
5685 an expression of array or function type. The array-subscript [] and member-access .
5686 and -> operators, the address & and indirection * unary operators, and pointer casts may
5687 be used in the creation of an address constant, but the value of an object shall not be
5688 accessed by use of these operators.
5690 An implementation may accept other forms of constant expressions.
5692 The semantic rules for the evaluation of a constant expression are the same as for
5693 nonconstant expressions.<sup><a href="#note118"><b>118)</b></a></sup>
5694 Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), initialization (<a href="#6.7.9">6.7.9</a>).
5699 <!--page 125 indent 4-->
5702 <p><a name="note115">115)</a> The operand of a sizeof operator is usually not evaluated (<a href="#6.5.3.4">6.5.3.4</a>).
5704 <p><a name="note116">116)</a> The use of evaluation formats as characterized by FLT_EVAL_METHOD also applies to evaluation in
5705 the translation environment.
5707 <p><a name="note117">117)</a> An integer constant expression is required in a number of contexts such as the size of a bit-field
5708 member of a structure, the value of an enumeration constant, and the size of a non-variable length
5709 array. Further constraints that apply to the integer constant expressions used in conditional-inclusion
5710 preprocessing directives are discussed in <a href="#6.10.1">6.10.1</a>.
5712 <p><a name="note118">118)</a> Thus, in the following initialization,
5715 static int i = 2 || 1 / 0;</pre>
5716 the expression is a valid integer constant expression with value one.
5719 <a name="6.7" href="#6.7"><h3>6.7 Declarations</h3></a>
5724 declaration-specifiers init-declarator-listopt ;
5725 static_assert-declaration
5726 declaration-specifiers:
5727 storage-class-specifier declaration-specifiersopt
5728 type-specifier declaration-specifiersopt
5729 type-qualifier declaration-specifiersopt
5730 function-specifier declaration-specifiersopt
5731 alignment-specifier declaration-specifiersopt
5732 init-declarator-list:
5734 init-declarator-list , init-declarator
5737 declarator = initializer</pre>
5738 <h6>Constraints</h6>
5740 A declaration other than a static_assert declaration shall declare at least a declarator
5741 (other than the parameters of a function or the members of a structure or union), a tag, or
5742 the members of an enumeration.
5744 If an identifier has no linkage, there shall be no more than one declaration of the identifier
5745 (in a declarator or type specifier) with the same scope and in the same name space, except
5746 that a typedef name can be redefined to denote the same type as it currently does and tags
5747 may be redeclared as specified in <a href="#6.7.2.3">6.7.2.3</a>.
5749 All declarations in the same scope that refer to the same object or function shall specify
5753 A declaration specifies the interpretation and attributes of a set of identifiers. A definition
5754 of an identifier is a declaration for that identifier that:
5756 <li> for an object, causes storage to be reserved for that object;
5757 <li> for a function, includes the function body;<sup><a href="#note119"><b>119)</b></a></sup>
5761 <!--page 126 indent 4-->
5762 <li> for an enumeration constant or typedef name, is the (only) declaration of the
5766 The declaration specifiers consist of a sequence of specifiers that indicate the linkage,
5767 storage duration, and part of the type of the entities that the declarators denote. The init-
5768 declarator-list is a comma-separated sequence of declarators, each of which may have
5769 additional type information, or an initializer, or both. The declarators contain the
5770 identifiers (if any) being declared.
5772 If an identifier for an object is declared with no linkage, the type for the object shall be
5773 complete by the end of its declarator, or by the end of its init-declarator if it has an
5774 initializer; in the case of function parameters (including in prototypes), it is the adjusted
5775 type (see <a href="#6.7.6.3">6.7.6.3</a>) that is required to be complete.
5776 Forward references: declarators (<a href="#6.7.6">6.7.6</a>), enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>), initialization
5777 (<a href="#6.7.9">6.7.9</a>), type names (<a href="#6.7.7">6.7.7</a>), type qualifiers (<a href="#6.7.3">6.7.3</a>).
5780 <p><a name="note119">119)</a> Function definitions have a different syntax, described in <a href="#6.9.1">6.9.1</a>.
5783 <a name="6.7.1" href="#6.7.1"><h4>6.7.1 Storage-class specifiers</h4></a>
5787 storage-class-specifier:
5794 <h6>Constraints</h6>
5796 At most, one storage-class specifier may be given in the declaration specifiers in a
5797 declaration, except that _Thread_local may appear with static or extern.<sup><a href="#note120"><b>120)</b></a></sup>
5799 In the declaration of an object with block scope, if the declaration specifiers include
5800 _Thread_local, they shall also include either static or extern. If
5801 _Thread_local appears in any declaration of an object, it shall be present in every
5802 declaration of that object.
5805 The typedef specifier is called a ''storage-class specifier'' for syntactic convenience
5806 only; it is discussed in <a href="#6.7.8">6.7.8</a>. The meanings of the various linkages and storage durations
5807 were discussed in <a href="#6.2.2">6.2.2</a> and <a href="#6.2.4">6.2.4</a>.
5811 <!--page 127 indent 4-->
5813 A declaration of an identifier for an object with storage-class specifier register
5814 suggests that access to the object be as fast as possible. The extent to which such
5815 suggestions are effective is implementation-defined.<sup><a href="#note121"><b>121)</b></a></sup>
5817 The declaration of an identifier for a function that has block scope shall have no explicit
5818 storage-class specifier other than extern.
5820 If an aggregate or union object is declared with a storage-class specifier other than
5821 typedef, the properties resulting from the storage-class specifier, except with respect to
5822 linkage, also apply to the members of the object, and so on recursively for any aggregate
5823 or union member objects.
5824 Forward references: type definitions (<a href="#6.7.8">6.7.8</a>).
5827 <p><a name="note120">120)</a> See ''future language directions'' (<a href="#6.11.5">6.11.5</a>).
5829 <p><a name="note121">121)</a> The implementation may treat any register declaration simply as an auto declaration. However,
5830 whether or not addressable storage is actually used, the address of any part of an object declared with
5831 storage-class specifier register cannot be computed, either explicitly (by use of the unary &
5832 operator as discussed in <a href="#6.5.3.2">6.5.3.2</a>) or implicitly (by converting an array name to a pointer as discussed in
5833 <a href="#6.3.2.1">6.3.2.1</a>). Thus, the only operator that can be applied to an array declared with storage-class specifier
5837 <a name="6.7.2" href="#6.7.2"><h4>6.7.2 Type specifiers</h4></a>
5853 atomic-type-specifier
5854 struct-or-union-specifier
5857 <h6>Constraints</h6>
5859 At least one type specifier shall be given in the declaration specifiers in each declaration,
5860 and in the specifier-qualifier list in each struct declaration and type name. Each list of
5863 <!--page 128 indent 4-->
5864 type specifiers shall be one of the following multisets (delimited by commas, when there
5865 is more than one multiset per item); the type specifiers may occur in any order, possibly
5866 intermixed with the other declaration specifiers.
5872 <li> short, signed short, short int, or signed short int
5873 <li> unsigned short, or unsigned short int
5874 <li> int, signed, or signed int
5875 <li> unsigned, or unsigned int
5876 <li> long, signed long, long int, or signed long int
5877 <li> unsigned long, or unsigned long int
5878 <li> long long, signed long long, long long int, or
5879 signed long long int
5880 <li> unsigned long long, or unsigned long long int
5886 <li> double _Complex
5887 <li> long double _Complex
5888 <li> atomic type specifier
5889 <li> struct or union specifier
5894 The type specifier _Complex shall not be used if the implementation does not support
5895 complex types (see <a href="#6.10.8.3">6.10.8.3</a>).
5896 <!--page 129 indent 4-->
5899 Specifiers for structures, unions, enumerations, and atomic types are discussed in <a href="#6.7.2.1">6.7.2.1</a>
5900 through <a href="#6.7.2.4">6.7.2.4</a>. Declarations of typedef names are discussed in <a href="#6.7.8">6.7.8</a>. The
5901 characteristics of the other types are discussed in <a href="#6.2.5">6.2.5</a>.
5903 Each of the comma-separated multisets designates the same type, except that for bit-
5904 fields, it is implementation-defined whether the specifier int designates the same type as
5905 signed int or the same type as unsigned int.
5906 Forward references: atomic type specifiers (<a href="#6.7.2.4">6.7.2.4</a>), enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>),
5907 structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), tags (<a href="#6.7.2.3">6.7.2.3</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
5909 <a name="6.7.2.1" href="#6.7.2.1"><h5>6.7.2.1 Structure and union specifiers</h5></a>
5913 struct-or-union-specifier:
5914 struct-or-union identifieropt { struct-declaration-list }
5915 struct-or-union identifier
5919 struct-declaration-list:
5921 struct-declaration-list struct-declaration
5923 specifier-qualifier-list struct-declarator-listopt ;
5924 static_assert-declaration
5925 specifier-qualifier-list:
5926 type-specifier specifier-qualifier-listopt
5927 type-qualifier specifier-qualifier-listopt
5928 struct-declarator-list:
5930 struct-declarator-list , struct-declarator
5933 declaratoropt : constant-expression</pre>
5934 <h6>Constraints</h6>
5936 A struct-declaration that does not declare an anonymous structure or anonymous union
5937 shall contain a struct-declarator-list.
5938 <!--page 130 indent 5-->
5940 A structure or union shall not contain a member with incomplete or function type (hence,
5941 a structure shall not contain an instance of itself, but may contain a pointer to an instance
5942 of itself), except that the last member of a structure with more than one named member
5943 may have incomplete array type; such a structure (and any union containing, possibly
5944 recursively, a member that is such a structure) shall not be a member of a structure or an
5945 element of an array.
5947 The expression that specifies the width of a bit-field shall be an integer constant
5948 expression with a nonnegative value that does not exceed the width of an object of the
5949 type that would be specified were the colon and expression omitted.<sup><a href="#note122"><b>122)</b></a></sup> If the value is
5950 zero, the declaration shall have no declarator.
5952 A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed
5953 int, unsigned int, or some other implementation-defined type. It is
5954 implementation-defined whether atomic types are permitted.
5957 As discussed in <a href="#6.2.5">6.2.5</a>, a structure is a type consisting of a sequence of members, whose
5958 storage is allocated in an ordered sequence, and a union is a type consisting of a sequence
5959 of members whose storage overlap.
5961 Structure and union specifiers have the same form. The keywords struct and union
5962 indicate that the type being specified is, respectively, a structure type or a union type.
5964 The presence of a struct-declaration-list in a struct-or-union-specifier declares a new type,
5965 within a translation unit. The struct-declaration-list is a sequence of declarations for the
5966 members of the structure or union. If the struct-declaration-list contains no named
5967 members, no anonymous structures, and no anonymous unions, the behavior is undefined.
5968 The type is incomplete until immediately after the } that terminates the list, and complete
5971 A member of a structure or union may have any complete object type other than a
5972 variably modified type.<sup><a href="#note123"><b>123)</b></a></sup> In addition, a member may be declared to consist of a
5973 specified number of bits (including a sign bit, if any). Such a member is called a
5974 bit-field;<sup><a href="#note124"><b>124)</b></a></sup> its width is preceded by a colon.
5976 A bit-field is interpreted as having a signed or unsigned integer type consisting of the
5977 specified number of bits.<sup><a href="#note125"><b>125)</b></a></sup> If the value 0 or 1 is stored into a nonzero-width bit-field of
5979 <!--page 131 indent 5-->
5980 type _Bool, the value of the bit-field shall compare equal to the value stored; a _Bool
5981 bit-field has the semantics of a _Bool.
5983 An implementation may allocate any addressable storage unit large enough to hold a bit-
5984 field. If enough space remains, a bit-field that immediately follows another bit-field in a
5985 structure shall be packed into adjacent bits of the same unit. If insufficient space remains,
5986 whether a bit-field that does not fit is put into the next unit or overlaps adjacent units is
5987 implementation-defined. The order of allocation of bit-fields within a unit (high-order to
5988 low-order or low-order to high-order) is implementation-defined. The alignment of the
5989 addressable storage unit is unspecified.
5991 A bit-field declaration with no declarator, but only a colon and a width, indicates an
5992 unnamed bit-field.<sup><a href="#note126"><b>126)</b></a></sup> As a special case, a bit-field structure member with a width of 0
5993 indicates that no further bit-field is to be packed into the unit in which the previous bit-
5994 field, if any, was placed.
5996 An unnamed member of structure type with no tag is called an anonymous structure; an
5997 unnamed member of union type with no tag is called an anonymous union. The members
5998 of an anonymous structure or union are considered to be members of the containing
5999 structure or union. This applies recursively if the containing structure or union is also
6002 Each non-bit-field member of a structure or union object is aligned in an implementation-
6003 defined manner appropriate to its type.
6005 Within a structure object, the non-bit-field members and the units in which bit-fields
6006 reside have addresses that increase in the order in which they are declared. A pointer to a
6007 structure object, suitably converted, points to its initial member (or if that member is a
6008 bit-field, then to the unit in which it resides), and vice versa. There may be unnamed
6009 padding within a structure object, but not at its beginning.
6011 The size of a union is sufficient to contain the largest of its members. The value of at
6012 most one of the members can be stored in a union object at any time. A pointer to a
6013 union object, suitably converted, points to each of its members (or if a member is a bit-
6014 field, then to the unit in which it resides), and vice versa.
6016 There may be unnamed padding at the end of a structure or union.
6018 As a special case, the last element of a structure with more than one named member may
6019 have an incomplete array type; this is called a flexible array member. In most situations,
6022 <!--page 132 indent 5-->
6023 the flexible array member is ignored. In particular, the size of the structure is as if the
6024 flexible array member were omitted except that it may have more trailing padding than
6025 the omission would imply. However, when a . (or ->) operator has a left operand that is
6026 (a pointer to) a structure with a flexible array member and the right operand names that
6027 member, it behaves as if that member were replaced with the longest array (with the same
6028 element type) that would not make the structure larger than the object being accessed; the
6029 offset of the array shall remain that of the flexible array member, even if this would differ
6030 from that of the replacement array. If this array would have no elements, it behaves as if
6031 it had one element but the behavior is undefined if any attempt is made to access that
6032 element or to generate a pointer one past it.
6034 EXAMPLE 1 The following illustrates anonymous structures and unions:
6037 union { // anonymous union
6038 struct { int i, j; }; // anonymous structure
6039 struct { long k, l; } w;
6044 v1.k = 3; // invalid: inner structure is not anonymous
6045 v1.w.k = 5; // valid</pre>
6048 EXAMPLE 2 After the declaration:
6050 struct s { int n; double d[]; };</pre>
6051 the structure struct s has a flexible array member d. A typical way to use this is:
6053 int m = /* some value */;
6054 struct s *p = malloc(sizeof (struct s) + sizeof (double [m]));</pre>
6055 and assuming that the call to malloc succeeds, the object pointed to by p behaves, for most purposes, as if
6056 p had been declared as:
6058 struct { int n; double d[m]; } *p;</pre>
6059 (there are circumstances in which this equivalence is broken; in particular, the offsets of member d might
6062 Following the above declaration:
6064 struct s t1 = { 0 }; // valid
6065 struct s t2 = { 1, { <a href="#4.2">4.2</a> }}; // invalid
6067 t1.d[0] = <a href="#4.2">4.2</a>; // might be undefined behavior</pre>
6068 The initialization of t2 is invalid (and violates a constraint) because struct s is treated as if it did not
6069 contain member d. The assignment to t1.d[0] is probably undefined behavior, but it is possible that
6071 sizeof (struct s) >= offsetof(struct s, d) + sizeof (double)</pre>
6072 in which case the assignment would be legitimate. Nevertheless, it cannot appear in strictly conforming
6074 <!--page 133 indent 5-->
6076 After the further declaration:
6078 struct ss { int n; };</pre>
6081 sizeof (struct s) >= sizeof (struct ss)
6082 sizeof (struct s) >= offsetof(struct s, d)</pre>
6083 are always equal to 1.
6085 If sizeof (double) is 8, then after the following code is executed:
6089 s1 = malloc(sizeof (struct s) + 64);
6090 s2 = malloc(sizeof (struct s) + 46);</pre>
6091 and assuming that the calls to malloc succeed, the objects pointed to by s1 and s2 behave, for most
6092 purposes, as if the identifiers had been declared as:
6095 struct { int n; double d[8]; } *s1;
6096 struct { int n; double d[5]; } *s2;</pre>
6097 Following the further successful assignments:
6099 s1 = malloc(sizeof (struct s) + 10);
6100 s2 = malloc(sizeof (struct s) + 6);</pre>
6101 they then behave as if the declarations were:
6103 struct { int n; double d[1]; } *s1, *s2;</pre>
6108 dp = &(s1->d[0]); // valid
6110 dp = &(s2->d[0]); // valid
6111 *dp = 42; // undefined behavior</pre>
6115 only copies the member n; if any of the array elements are within the first sizeof (struct s) bytes
6116 of the structure, they might be copied or simply overwritten with indeterminate values.
6118 Forward references: declarators (<a href="#6.7.6">6.7.6</a>), tags (<a href="#6.7.2.3">6.7.2.3</a>).
6119 <!--page 134 indent 4-->
6122 <p><a name="note122">122)</a> While the number of bits in a _Bool object is at least CHAR_BIT, the width (number of sign and
6123 value bits) of a _Bool may be just 1 bit.
6125 <p><a name="note123">123)</a> A structure or union cannot contain a member with a variably modified type because member names
6126 are not ordinary identifiers as defined in <a href="#6.2.3">6.2.3</a>.
6128 <p><a name="note124">124)</a> The unary & (address-of) operator cannot be applied to a bit-field object; thus, there are no pointers to
6129 or arrays of bit-field objects.
6131 <p><a name="note125">125)</a> As specified in <a href="#6.7.2">6.7.2</a> above, if the actual type specifier used is int or a typedef-name defined as int,
6132 then it is implementation-defined whether the bit-field is signed or unsigned.
6134 <p><a name="note126">126)</a> An unnamed bit-field structure member is useful for padding to conform to externally imposed
6138 <a name="6.7.2.2" href="#6.7.2.2"><h5>6.7.2.2 Enumeration specifiers</h5></a>
6143 enum identifieropt { enumerator-list }
6144 enum identifieropt { enumerator-list , }
6148 enumerator-list , enumerator
6150 enumeration-constant
6151 enumeration-constant = constant-expression</pre>
6152 <h6>Constraints</h6>
6154 The expression that defines the value of an enumeration constant shall be an integer
6155 constant expression that has a value representable as an int.
6158 The identifiers in an enumerator list are declared as constants that have type int and
6159 may appear wherever such are permitted.<sup><a href="#note127"><b>127)</b></a></sup> An enumerator with = defines its
6160 enumeration constant as the value of the constant expression. If the first enumerator has
6161 no =, the value of its enumeration constant is 0. Each subsequent enumerator with no =
6162 defines its enumeration constant as the value of the constant expression obtained by
6163 adding 1 to the value of the previous enumeration constant. (The use of enumerators with
6164 = may produce enumeration constants with values that duplicate other values in the same
6165 enumeration.) The enumerators of an enumeration are also known as its members.
6167 Each enumerated type shall be compatible with char, a signed integer type, or an
6168 unsigned integer type. The choice of type is implementation-defined,<sup><a href="#note128"><b>128)</b></a></sup> but shall be
6169 capable of representing the values of all the members of the enumeration. The
6170 enumerated type is incomplete until immediately after the } that terminates the list of
6171 enumerator declarations, and complete thereafter.
6176 <!--page 135 indent 4-->
6178 EXAMPLE The following fragment:
6180 enum hue { chartreuse, burgundy, claret=20, winedark };
6184 if (*cp != burgundy)
6186 makes hue the tag of an enumeration, and then declares col as an object that has that type and cp as a
6187 pointer to an object that has that type. The enumerated values are in the set { 0, 1, 20, 21 }.
6189 Forward references: tags (<a href="#6.7.2.3">6.7.2.3</a>).
6192 <p><a name="note127">127)</a> Thus, the identifiers of enumeration constants declared in the same scope shall all be distinct from
6193 each other and from other identifiers declared in ordinary declarators.
6195 <p><a name="note128">128)</a> An implementation may delay the choice of which integer type until all enumeration constants have
6199 <a name="6.7.2.3" href="#6.7.2.3"><h5>6.7.2.3 Tags</h5></a>
6200 <h6>Constraints</h6>
6202 A specific type shall have its content defined at most once.
6204 Where two declarations that use the same tag declare the same type, they shall both use
6205 the same choice of struct, union, or enum.
6207 A type specifier of the form
6209 enum identifier</pre>
6210 without an enumerator list shall only appear after the type it specifies is complete.
6213 All declarations of structure, union, or enumerated types that have the same scope and
6214 use the same tag declare the same type. Irrespective of whether there is a tag or what
6215 other declarations of the type are in the same translation unit, the type is incomplete<sup><a href="#note129"><b>129)</b></a></sup>
6216 until immediately after the closing brace of the list defining the content, and complete
6219 Two declarations of structure, union, or enumerated types which are in different scopes or
6220 use different tags declare distinct types. Each declaration of a structure, union, or
6221 enumerated type which does not include a tag declares a distinct type.
6223 A type specifier of the form
6228 <!--page 136 indent 5-->
6230 struct-or-union identifieropt { struct-declaration-list }</pre>
6233 enum identifieropt { enumerator-list }</pre>
6236 enum identifieropt { enumerator-list , }</pre>
6237 declares a structure, union, or enumerated type. The list defines the structure content,
6238 union content, or enumeration content. If an identifier is provided,<sup><a href="#note130"><b>130)</b></a></sup> the type specifier
6239 also declares the identifier to be the tag of that type.
6241 A declaration of the form
6243 struct-or-union identifier ;</pre>
6244 specifies a structure or union type and declares the identifier as a tag of that type.<sup><a href="#note131"><b>131)</b></a></sup>
6246 If a type specifier of the form
6248 struct-or-union identifier</pre>
6249 occurs other than as part of one of the above forms, and no other declaration of the
6250 identifier as a tag is visible, then it declares an incomplete structure or union type, and
6251 declares the identifier as the tag of that type.131)
6253 If a type specifier of the form
6255 struct-or-union identifier</pre>
6258 enum identifier</pre>
6259 occurs other than as part of one of the above forms, and a declaration of the identifier as a
6260 tag is visible, then it specifies the same type as that other declaration, and does not
6263 EXAMPLE 1 This mechanism allows declaration of a self-referential structure.
6267 struct tnode *left, *right;
6269 specifies a structure that contains an integer and two pointers to objects of the same type. Once this
6270 declaration has been given, the declaration
6275 <!--page 137 indent 5-->
6277 struct tnode s, *sp;</pre>
6278 declares s to be an object of the given type and sp to be a pointer to an object of the given type. With
6279 these declarations, the expression sp->left refers to the left struct tnode pointer of the object to
6280 which sp points; the expression s.right->count designates the count member of the right struct
6281 tnode pointed to from s.
6283 The following alternative formulation uses the typedef mechanism:
6285 typedef struct tnode TNODE;
6288 TNODE *left, *right;
6293 EXAMPLE 2 To illustrate the use of prior declaration of a tag to specify a pair of mutually referential
6294 structures, the declarations
6296 struct s1 { struct s2 *s2p; /* ... */ }; // D1
6297 struct s2 { struct s1 *s1p; /* ... */ }; // D2</pre>
6298 specify a pair of structures that contain pointers to each other. Note, however, that if s2 were already
6299 declared as a tag in an enclosing scope, the declaration D1 would refer to it, not to the tag s2 declared in
6300 D2. To eliminate this context sensitivity, the declaration
6303 may be inserted ahead of D1. This declares a new tag s2 in the inner scope; the declaration D2 then
6304 completes the specification of the new type.
6306 Forward references: declarators (<a href="#6.7.6">6.7.6</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
6309 <p><a name="note129">129)</a> An incomplete type may only by used when the size of an object of that type is not needed. It is not
6310 needed, for example, when a typedef name is declared to be a specifier for a structure or union, or
6311 when a pointer to or a function returning a structure or union is being declared. (See incomplete types
6312 in <a href="#6.2.5">6.2.5</a>.) The specification has to be complete before such a function is called or defined.
6314 <p><a name="note130">130)</a> If there is no identifier, the type can, within the translation unit, only be referred to by the declaration
6315 of which it is a part. Of course, when the declaration is of a typedef name, subsequent declarations
6316 can make use of that typedef name to declare objects having the specified structure, union, or
6319 <p><a name="note131">131)</a> A similar construction with enum does not exist.
6322 <a name="6.7.2.4" href="#6.7.2.4"><h5>6.7.2.4 Atomic type specifiers</h5></a>
6326 atomic-type-specifier:
6327 _Atomic ( type-name )</pre>
6328 <h6>Constraints</h6>
6330 Atomic type specifiers shall not be used if the implementation does not support atomic
6331 types (see <a href="#6.10.8.3">6.10.8.3</a>).
6333 The type name in an atomic type specifier shall not refer to an array type, a function type,
6334 an atomic type, or a qualified type.
6337 The properties associated with atomic types are meaningful only for expressions that are
6338 lvalues. If the _Atomic keyword is immediately followed by a left parenthesis, it is
6339 interpreted as a type specifier (with a type name), not as a type qualifier.
6340 <!--page 138 indent 4-->
6342 <a name="6.7.3" href="#6.7.3"><h4>6.7.3 Type qualifiers</h4></a>
6351 <h6>Constraints</h6>
6353 Types other than pointer types whose referenced type is an object type shall not be
6356 The type modified by the _Atomic qualifier shall not be an array type or a function
6360 The properties associated with qualified types are meaningful only for expressions that
6361 are lvalues.<sup><a href="#note132"><b>132)</b></a></sup>
6363 If the same qualifier appears more than once in the same specifier-qualifier-list, either
6364 directly or via one or more typedefs, the behavior is the same as if it appeared only
6365 once. If other qualifiers appear along with the _Atomic qualifier in a specifier-qualifier-
6366 list, the resulting type is the so-qualified atomic type.
6368 If an attempt is made to modify an object defined with a const-qualified type through use
6369 of an lvalue with non-const-qualified type, the behavior is undefined. If an attempt is
6370 made to refer to an object defined with a volatile-qualified type through use of an lvalue
6371 with non-volatile-qualified type, the behavior is undefined.<sup><a href="#note133"><b>133)</b></a></sup>
6373 An object that has volatile-qualified type may be modified in ways unknown to the
6374 implementation or have other unknown side effects. Therefore any expression referring
6375 to such an object shall be evaluated strictly according to the rules of the abstract machine,
6376 as described in <a href="#5.1.2.3">5.1.2.3</a>. Furthermore, at every sequence point the value last stored in the
6377 object shall agree with that prescribed by the abstract machine, except as modified by the
6382 <!--page 139 indent 5-->
6383 unknown factors mentioned previously.<sup><a href="#note134"><b>134)</b></a></sup> What constitutes an access to an object that
6384 has volatile-qualified type is implementation-defined.
6386 An object that is accessed through a restrict-qualified pointer has a special association
6387 with that pointer. This association, defined in <a href="#6.7.3.1">6.7.3.1</a> below, requires that all accesses to
6388 that object use, directly or indirectly, the value of that particular pointer.<sup><a href="#note135"><b>135)</b></a></sup> The intended
6389 use of the restrict qualifier (like the register storage class) is to promote
6390 optimization, and deleting all instances of the qualifier from all preprocessing translation
6391 units composing a conforming program does not change its meaning (i.e., observable
6394 If the specification of an array type includes any type qualifiers, the element type is so-
6395 qualified, not the array type. If the specification of a function type includes any type
6396 qualifiers, the behavior is undefined.<sup><a href="#note136"><b>136)</b></a></sup>
6398 For two qualified types to be compatible, both shall have the identically qualified version
6399 of a compatible type; the order of type qualifiers within a list of specifiers or qualifiers
6400 does not affect the specified type.
6402 EXAMPLE 1 An object declared
6404 extern const volatile int real_time_clock;</pre>
6405 may be modifiable by hardware, but cannot be assigned to, incremented, or decremented.
6408 EXAMPLE 2 The following declarations and expressions illustrate the behavior when type qualifiers
6409 modify an aggregate type:
6411 const struct s { int mem; } cs = { 1 };
6412 struct s ncs; // the object ncs is modifiable
6413 typedef int A[2][3];
6414 const A a = {{4, 5, 6}, {7, 8, 9}}; // array of array of const int
6418 cs = ncs; // violates modifiable lvalue constraint for =
6419 pi = &ncs.mem; // valid
6420 pi = &cs.mem; // violates type constraints for =
6421 pci = &cs.mem; // valid
6422 pi = a[0]; // invalid: a[0] has type ''const int *''</pre>
6426 <!--page 140 indent 5-->
6428 EXAMPLE 3 The declaration
6430 _Atomic volatile int *p;</pre>
6431 specifies that p has the type ''pointer to volatile atomic int'', a pointer to a volatile-qualified atomic type.
6435 <p><a name="note132">132)</a> The implementation may place a const object that is not volatile in a read-only region of
6436 storage. Moreover, the implementation need not allocate storage for such an object if its address is
6439 <p><a name="note133">133)</a> This applies to those objects that behave as if they were defined with qualified types, even if they are
6440 never actually defined as objects in the program (such as an object at a memory-mapped input/output
6443 <p><a name="note134">134)</a> A volatile declaration may be used to describe an object corresponding to a memory-mapped
6444 input/output port or an object accessed by an asynchronously interrupting function. Actions on
6445 objects so declared shall not be ''optimized out'' by an implementation or reordered except as
6446 permitted by the rules for evaluating expressions.
6448 <p><a name="note135">135)</a> For example, a statement that assigns a value returned by malloc to a single pointer establishes this
6449 association between the allocated object and the pointer.
6451 <p><a name="note136">136)</a> Both of these can occur through the use of typedefs.
6454 <a name="6.7.3.1" href="#6.7.3.1"><h5>6.7.3.1 Formal definition of restrict</h5></a>
6456 Let D be a declaration of an ordinary identifier that provides a means of designating an
6457 object P as a restrict-qualified pointer to type T.
6459 If D appears inside a block and does not have storage class extern, let B denote the
6460 block. If D appears in the list of parameter declarations of a function definition, let B
6461 denote the associated block. Otherwise, let B denote the block of main (or the block of
6462 whatever function is called at program startup in a freestanding environment).
6464 In what follows, a pointer expression E is said to be based on object P if (at some
6465 sequence point in the execution of B prior to the evaluation of E) modifying P to point to
6466 a copy of the array object into which it formerly pointed would change the value of E.<sup><a href="#note137"><b>137)</b></a></sup>
6467 Note that ''based'' is defined only for expressions with pointer types.
6469 During each execution of B, let L be any lvalue that has &L based on P. If L is used to
6470 access the value of the object X that it designates, and X is also modified (by any means),
6471 then the following requirements apply: T shall not be const-qualified. Every other lvalue
6472 used to access the value of X shall also have its address based on P. Every access that
6473 modifies X shall be considered also to modify P, for the purposes of this subclause. If P
6474 is assigned the value of a pointer expression E that is based on another restricted pointer
6475 object P2, associated with block B2, then either the execution of B2 shall begin before
6476 the execution of B, or the execution of B2 shall end prior to the assignment. If these
6477 requirements are not met, then the behavior is undefined.
6479 Here an execution of B means that portion of the execution of the program that would
6480 correspond to the lifetime of an object with scalar type and automatic storage duration
6483 A translator is free to ignore any or all aliasing implications of uses of restrict.
6485 EXAMPLE 1 The file scope declarations
6489 extern int c[];</pre>
6490 assert that if an object is accessed using one of a, b, or c, and that object is modified anywhere in the
6491 program, then it is never accessed using either of the other two.
6494 <!--page 141 indent 5-->
6496 EXAMPLE 2 The function parameter declarations in the following example
6498 void f(int n, int * restrict p, int * restrict q)
6503 assert that, during each execution of the function, if an object is accessed through one of the pointer
6504 parameters, then it is not also accessed through the other.
6506 The benefit of the restrict qualifiers is that they enable a translator to make an effective dependence
6507 analysis of function f without examining any of the calls of f in the program. The cost is that the
6508 programmer has to examine all of those calls to ensure that none give undefined behavior. For example, the
6509 second call of f in g has undefined behavior because each of d[1] through d[49] is accessed through
6515 f(50, d + 50, d); // valid
6516 f(50, d + 1, d); // undefined behavior
6520 EXAMPLE 3 The function parameter declarations
6522 void h(int n, int * restrict p, int * restrict q, int * restrict r)
6525 for (i = 0; i < n; i++)
6528 illustrate how an unmodified object can be aliased through two restricted pointers. In particular, if a and b
6529 are disjoint arrays, a call of the form h(100, a, b, b) has defined behavior, because array b is not
6530 modified within function h.
6533 EXAMPLE 4 The rule limiting assignments between restricted pointers does not distinguish between a
6534 function call and an equivalent nested block. With one exception, only ''outer-to-inner'' assignments
6535 between restricted pointers declared in nested blocks have defined behavior.
6536 <!--page 142 indent 5-->
6542 p1 = q1; // undefined behavior
6544 int * restrict p2 = p1; // valid
6545 int * restrict q2 = q1; // valid
6546 p1 = q2; // undefined behavior
6547 p2 = q2; // undefined behavior
6550 The one exception allows the value of a restricted pointer to be carried out of the block in which it (or, more
6551 precisely, the ordinary identifier used to designate it) is declared when that block finishes execution. For
6552 example, this permits new_vector to return a vector.
6554 typedef struct { int n; float * restrict v; } vector;
6555 vector new_vector(int n)
6559 t.v = malloc(n * sizeof (float));
6565 <p><a name="note137">137)</a> In other words, E depends on the value of P itself rather than on the value of an object referenced
6566 indirectly through P. For example, if identifier p has type (int **restrict), then the pointer
6567 expressions p and p+1 are based on the restricted pointer object designated by p, but the pointer
6568 expressions *p and p[1] are not.
6571 <a name="6.7.4" href="#6.7.4"><h4>6.7.4 Function specifiers</h4></a>
6578 <h6>Constraints</h6>
6580 Function specifiers shall be used only in the declaration of an identifier for a function.
6582 An inline definition of a function with external linkage shall not contain a definition of a
6583 modifiable object with static or thread storage duration, and shall not contain a reference
6584 to an identifier with internal linkage.
6586 In a hosted environment, no function specifier(s) shall appear in a declaration of main.
6589 A function specifier may appear more than once; the behavior is the same as if it
6592 A function declared with an inline function specifier is an inline function. Making a *
6593 function an inline function suggests that calls to the function be as fast as possible.<sup><a href="#note138"><b>138)</b></a></sup>
6594 The extent to which such suggestions are effective is implementation-defined.<sup><a href="#note139"><b>139)</b></a></sup>
6599 <!--page 143 indent 5-->
6601 Any function with internal linkage can be an inline function. For a function with external
6602 linkage, the following restrictions apply: If a function is declared with an inline
6603 function specifier, then it shall also be defined in the same translation unit. If all of the
6604 file scope declarations for a function in a translation unit include the inline function
6605 specifier without extern, then the definition in that translation unit is an inline
6606 definition. An inline definition does not provide an external definition for the function,
6607 and does not forbid an external definition in another translation unit. An inline definition
6608 provides an alternative to an external definition, which a translator may use to implement
6609 any call to the function in the same translation unit. It is unspecified whether a call to the
6610 function uses the inline definition or the external definition.<sup><a href="#note140"><b>140)</b></a></sup>
6612 A function declared with a _Noreturn function specifier shall not return to its caller.
6613 Recommended practice
6615 The implementation should produce a diagnostic message for a function declared with a
6616 _Noreturn function specifier that appears to be capable of returning to its caller.
6618 EXAMPLE 1 The declaration of an inline function with external linkage can result in either an external
6619 definition, or a definition available for use only within the translation unit. A file scope declaration with
6620 extern creates an external definition. The following example shows an entire translation unit.
6623 inline double fahr(double t)
6625 return (9.0 * t) / 5.0 + 32.0;
6627 inline double cels(double t)
6629 return (5.0 * (t - 32.0)) / 9.0;
6631 extern double fahr(double); // creates an external definition
6632 double convert(int is_fahr, double temp)
6634 /* A translator may perform inline substitutions */
6635 return is_fahr ? cels(temp) : fahr(temp);
6637 Note that the definition of fahr is an external definition because fahr is also declared with extern, but
6638 the definition of cels is an inline definition. Because cels has external linkage and is referenced, an
6639 external definition has to appear in another translation unit (see <a href="#6.9">6.9</a>); the inline definition and the external
6640 definition are distinct and either may be used for the call.
6648 <!--page 144 indent 4-->
6650 _Noreturn void f () {
6653 _Noreturn void g (int i) { // causes undefined behavior if i <= 0
6654 if (i > 0) abort();
6657 Forward references: function definitions (<a href="#6.9.1">6.9.1</a>).
6660 <p><a name="note138">138)</a> By using, for example, an alternative to the usual function call mechanism, such as ''inline
6661 substitution''. Inline substitution is not textual substitution, nor does it create a new function.
6662 Therefore, for example, the expansion of a macro used within the body of the function uses the
6663 definition it had at the point the function body appears, and not where the function is called; and
6664 identifiers refer to the declarations in scope where the body occurs. Likewise, the function has a
6665 single address, regardless of the number of inline definitions that occur in addition to the external
6668 <p><a name="note139">139)</a> For example, an implementation might never perform inline substitution, or might only perform inline
6669 substitutions to calls in the scope of an inline declaration.
6671 <p><a name="note140">140)</a> Since an inline definition is distinct from the corresponding external definition and from any other
6672 corresponding inline definitions in other translation units, all corresponding objects with static storage
6673 duration are also distinct in each of the definitions.
6676 <a name="6.7.5" href="#6.7.5"><h4>6.7.5 Alignment specifier</h4></a>
6680 alignment-specifier:
6681 _Alignas ( type-name )
6682 _Alignas ( constant-expression )</pre>
6683 <h6>Constraints</h6>
6685 An alignment attribute shall not be specified in a declaration of a typedef, or a bit-field, or
6686 a function, or a parameter, or an object declared with the register storage-class
6689 The constant expression shall be an integer constant expression. It shall evaluate to a
6690 valid fundamental alignment, or to a valid extended alignment supported by the
6691 implementation in the context in which it appears, or to zero.
6693 The combined effect of all alignment attributes in a declaration shall not specify an
6694 alignment that is less strict than the alignment that would otherwise be required for the
6695 type of the object or member being declared.
6698 The first form is equivalent to _Alignas(alignof(type-name)).
6700 The alignment requirement of the declared object or member is taken to be the specified
6701 alignment. An alignment specification of zero has no effect.<sup><a href="#note141"><b>141)</b></a></sup> When multiple
6702 alignment specifiers occur in a declaration, the effective alignment requirement is the
6703 strictest specified alignment.
6705 If the definition of an object has an alignment specifier, any other declaration of that
6706 object shall either specify equivalent alignment or have no alignment specifier. If the
6707 definition of an object does not have an alignment specifier, any other declaration of that
6708 object shall also have no alignment specifier. If declarations of an object in different
6709 translation units have different alignment specifiers, the behavior is undefined.
6713 <!--page 145 indent 4-->
6716 <p><a name="note141">141)</a> An alignment specification of zero also does not affect other alignment specifications in the same
6720 <a name="6.7.6" href="#6.7.6"><h4>6.7.6 Declarators</h4></a>
6725 pointeropt direct-declarator
6729 direct-declarator [ type-qualifier-listopt assignment-expressionopt ]
6730 direct-declarator [ static type-qualifier-listopt assignment-expression ]
6731 direct-declarator [ type-qualifier-list static assignment-expression ]
6732 direct-declarator [ type-qualifier-listopt * ]
6733 direct-declarator ( parameter-type-list )
6734 direct-declarator ( identifier-listopt )
6736 * type-qualifier-listopt
6737 * type-qualifier-listopt pointer
6738 type-qualifier-list:
6740 type-qualifier-list type-qualifier
6741 parameter-type-list:
6743 parameter-list , ...
6745 parameter-declaration
6746 parameter-list , parameter-declaration
6747 parameter-declaration:
6748 declaration-specifiers declarator
6749 declaration-specifiers abstract-declaratoropt
6752 identifier-list , identifier</pre>
6755 Each declarator declares one identifier, and asserts that when an operand of the same
6756 form as the declarator appears in an expression, it designates a function or object with the
6757 scope, storage duration, and type indicated by the declaration specifiers.
6759 A full declarator is a declarator that is not part of another declarator. The end of a full
6760 declarator is a sequence point. If, in the nested sequence of declarators in a full
6761 <!--page 146 indent 4-->
6762 declarator, there is a declarator specifying a variable length array type, the type specified
6763 by the full declarator is said to be variably modified. Furthermore, any type derived by
6764 declarator type derivation from a variably modified type is itself variably modified.
6766 In the following subclauses, consider a declaration
6769 where T contains the declaration specifiers that specify a type T (such as int) and D1 is
6770 a declarator that contains an identifier ident. The type specified for the identifier ident in
6771 the various forms of declarator is described inductively using this notation.
6773 If, in the declaration ''T D1'', D1 has the form
6776 then the type specified for ident is T .
6778 If, in the declaration ''T D1'', D1 has the form
6781 then ident has the type specified by the declaration ''T D''. Thus, a declarator in
6782 parentheses is identical to the unparenthesized declarator, but the binding of complicated
6783 declarators may be altered by parentheses.
6784 Implementation limits
6786 As discussed in <a href="#5.2.4.1">5.2.4.1</a>, an implementation may limit the number of pointer, array, and
6787 function declarators that modify an arithmetic, structure, union, or void type, either
6788 directly or via one or more typedefs.
6789 Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
6791 <a name="6.7.6.1" href="#6.7.6.1"><h5>6.7.6.1 Pointer declarators</h5></a>
6794 If, in the declaration ''T D1'', D1 has the form
6796 * type-qualifier-listopt D</pre>
6797 and the type specified for ident in the declaration ''T D'' is ''derived-declarator-type-list
6798 T '', then the type specified for ident is ''derived-declarator-type-list type-qualifier-list
6799 pointer to T ''. For each type qualifier in the list, ident is a so-qualified pointer.
6801 For two pointer types to be compatible, both shall be identically qualified and both shall
6802 be pointers to compatible types.
6804 EXAMPLE The following pair of declarations demonstrates the difference between a ''variable pointer
6805 to a constant value'' and a ''constant pointer to a variable value''.
6806 <!--page 147 indent 4-->
6808 const int *ptr_to_constant;
6809 int *const constant_ptr;</pre>
6810 The contents of any object pointed to by ptr_to_constant shall not be modified through that pointer,
6811 but ptr_to_constant itself may be changed to point to another object. Similarly, the contents of the
6812 int pointed to by constant_ptr may be modified, but constant_ptr itself shall always point to the
6815 The declaration of the constant pointer constant_ptr may be clarified by including a definition for the
6816 type ''pointer to int''.
6818 typedef int *int_ptr;
6819 const int_ptr constant_ptr;</pre>
6820 declares constant_ptr as an object that has type ''const-qualified pointer to int''.
6823 <a name="6.7.6.2" href="#6.7.6.2"><h5>6.7.6.2 Array declarators</h5></a>
6824 <h6>Constraints</h6>
6826 In addition to optional type qualifiers and the keyword static, the [ and ] may delimit
6827 an expression or *. If they delimit an expression (which specifies the size of an array), the
6828 expression shall have an integer type. If the expression is a constant expression, it shall
6829 have a value greater than zero. The element type shall not be an incomplete or function
6830 type. The optional type qualifiers and the keyword static shall appear only in a
6831 declaration of a function parameter with an array type, and then only in the outermost
6832 array type derivation.
6834 If an identifier is declared as having a variably modified type, it shall be an ordinary
6835 identifier (as defined in <a href="#6.2.3">6.2.3</a>), have no linkage, and have either block scope or function
6836 prototype scope. If an identifier is declared to be an object with static or thread storage
6837 duration, it shall not have a variable length array type.
6840 If, in the declaration ''T D1'', D1 has one of the forms:
6842 D[ type-qualifier-listopt assignment-expressionopt ]
6843 D[ static type-qualifier-listopt assignment-expression ]
6844 D[ type-qualifier-list static assignment-expression ]
6845 D[ type-qualifier-listopt * ]</pre>
6846 and the type specified for ident in the declaration ''T D'' is ''derived-declarator-type-list
6847 T '', then the type specified for ident is ''derived-declarator-type-list array of T ''.<sup><a href="#note142"><b>142)</b></a></sup>
6848 (See <a href="#6.7.6.3">6.7.6.3</a> for the meaning of the optional type qualifiers and the keyword static.)
6850 If the size is not present, the array type is an incomplete type. If the size is * instead of
6851 being an expression, the array type is a variable length array type of unspecified size,
6852 which can only be used in declarations or type names with function prototype scope;<sup><a href="#note143"><b>143)</b></a></sup>
6854 <!--page 148 indent 4-->
6855 such arrays are nonetheless complete types. If the size is an integer constant expression
6856 and the element type has a known constant size, the array type is not a variable length
6857 array type; otherwise, the array type is a variable length array type. (Variable length
6858 arrays are a conditional feature that implementations need not support; see <a href="#6.10.8.3">6.10.8.3</a>.)
6860 If the size is an expression that is not an integer constant expression: if it occurs in a
6861 declaration at function prototype scope, it is treated as if it were replaced by *; otherwise,
6862 each time it is evaluated it shall have a value greater than zero. The size of each instance
6863 of a variable length array type does not change during its lifetime. Where a size
6864 expression is part of the operand of a sizeof operator and changing the value of the
6865 size expression would not affect the result of the operator, it is unspecified whether or not
6866 the size expression is evaluated.
6868 For two array types to be compatible, both shall have compatible element types, and if
6869 both size specifiers are present, and are integer constant expressions, then both size
6870 specifiers shall have the same constant value. If the two array types are used in a context
6871 which requires them to be compatible, it is undefined behavior if the two size specifiers
6872 evaluate to unequal values.
6876 float fa[11], *afp[17];</pre>
6877 declares an array of float numbers and an array of pointers to float numbers.
6880 EXAMPLE 2 Note the distinction between the declarations
6883 extern int y[];</pre>
6884 The first declares x to be a pointer to int; the second declares y to be an array of int of unspecified size
6885 (an incomplete type), the storage for which is defined elsewhere.
6888 EXAMPLE 3 The following declarations demonstrate the compatibility rules for variably modified types.
6897 int (*r)[n][n][n+1];
6898 p = a; // invalid: not compatible because 4 != 6
6899 r = c; // compatible, but defined behavior only if
6900 // n == 6 and m == n+1
6906 <!--page 149 indent 5-->
6908 EXAMPLE 4 All declarations of variably modified (VM) types have to be at either block scope or
6909 function prototype scope. Array objects declared with the _Thread_local, static, or extern
6910 storage-class specifier cannot have a variable length array (VLA) type. However, an object declared with
6911 the static storage-class specifier can have a VM type (that is, a pointer to a VLA type). Finally, all
6912 identifiers declared with a VM type have to be ordinary identifiers and cannot, therefore, be members of
6913 structures or unions.
6916 int A[n]; // invalid: file scope VLA
6917 extern int (*p2)[n]; // invalid: file scope VM
6918 int B[100]; // valid: file scope but not VM
6919 void fvla(int m, int C[m][m]); // valid: VLA with prototype scope
6920 void fvla(int m, int C[m][m]) // valid: adjusted to auto pointer to VLA
6922 typedef int VLA[m][m]; // valid: block scope typedef VLA
6924 int (*y)[n]; // invalid: y not ordinary identifier
6925 int z[n]; // invalid: z not ordinary identifier
6927 int D[m]; // valid: auto VLA
6928 static int E[m]; // invalid: static block scope VLA
6929 extern int F[m]; // invalid: F has linkage and is VLA
6930 int (*s)[m]; // valid: auto pointer to VLA
6931 extern int (*r)[m]; // invalid: r has linkage and points to VLA
6932 static int (*q)[m] = &B; // valid: q is a static block pointer to VLA
6935 Forward references: function declarators (<a href="#6.7.6.3">6.7.6.3</a>), function definitions (<a href="#6.9.1">6.9.1</a>),
6936 initialization (<a href="#6.7.9">6.7.9</a>).
6939 <p><a name="note142">142)</a> When several ''array of'' specifications are adjacent, a multidimensional array is declared.
6941 <p><a name="note143">143)</a> Thus, * can be used only in function declarations that are not definitions (see <a href="#6.7.6.3">6.7.6.3</a>).
6944 <a name="6.7.6.3" href="#6.7.6.3"><h5>6.7.6.3 Function declarators (including prototypes)</h5></a>
6945 <h6>Constraints</h6>
6947 A function declarator shall not specify a return type that is a function type or an array
6950 The only storage-class specifier that shall occur in a parameter declaration is register.
6952 An identifier list in a function declarator that is not part of a definition of that function
6955 After adjustment, the parameters in a parameter type list in a function declarator that is
6956 part of a definition of that function shall not have incomplete type.
6959 If, in the declaration ''T D1'', D1 has the form
6960 <!--page 150 indent 5-->
6962 D( parameter-type-list )</pre>
6965 D( identifier-listopt )</pre>
6966 and the type specified for ident in the declaration ''T D'' is ''derived-declarator-type-list
6967 T '', then the type specified for ident is ''derived-declarator-type-list function returning
6970 A parameter type list specifies the types of, and may declare identifiers for, the
6971 parameters of the function.
6973 A declaration of a parameter as ''array of type'' shall be adjusted to ''qualified pointer to
6974 type'', where the type qualifiers (if any) are those specified within the [ and ] of the
6975 array type derivation. If the keyword static also appears within the [ and ] of the
6976 array type derivation, then for each call to the function, the value of the corresponding
6977 actual argument shall provide access to the first element of an array with at least as many
6978 elements as specified by the size expression.
6980 A declaration of a parameter as ''function returning type'' shall be adjusted to ''pointer to
6981 function returning type'', as in <a href="#6.3.2.1">6.3.2.1</a>.
6983 If the list terminates with an ellipsis (, ...), no information about the number or types
6984 of the parameters after the comma is supplied.<sup><a href="#note144"><b>144)</b></a></sup>
6986 The special case of an unnamed parameter of type void as the only item in the list
6987 specifies that the function has no parameters.
6989 If, in a parameter declaration, an identifier can be treated either as a typedef name or as a
6990 parameter name, it shall be taken as a typedef name.
6992 If the function declarator is not part of a definition of that function, parameters may have
6993 incomplete type and may use the [*] notation in their sequences of declarator specifiers
6994 to specify variable length array types.
6996 The storage-class specifier in the declaration specifiers for a parameter declaration, if
6997 present, is ignored unless the declared parameter is one of the members of the parameter
6998 type list for a function definition.
7000 An identifier list declares only the identifiers of the parameters of the function. An empty
7001 list in a function declarator that is part of a definition of that function specifies that the
7002 function has no parameters. The empty list in a function declarator that is not part of a
7003 definition of that function specifies that no information about the number or types of the
7004 parameters is supplied.<sup><a href="#note145"><b>145)</b></a></sup>
7008 <!--page 151 indent 5-->
7010 For two function types to be compatible, both shall specify compatible return types.<sup><a href="#note146"><b>146)</b></a></sup>
7011 Moreover, the parameter type lists, if both are present, shall agree in the number of
7012 parameters and in use of the ellipsis terminator; corresponding parameters shall have
7013 compatible types. If one type has a parameter type list and the other type is specified by a
7014 function declarator that is not part of a function definition and that contains an empty
7015 identifier list, the parameter list shall not have an ellipsis terminator and the type of each
7016 parameter shall be compatible with the type that results from the application of the
7017 default argument promotions. If one type has a parameter type list and the other type is
7018 specified by a function definition that contains a (possibly empty) identifier list, both shall
7019 agree in the number of parameters, and the type of each prototype parameter shall be
7020 compatible with the type that results from the application of the default argument
7021 promotions to the type of the corresponding identifier. (In the determination of type
7022 compatibility and of a composite type, each parameter declared with function or array
7023 type is taken as having the adjusted type and each parameter declared with qualified type
7024 is taken as having the unqualified version of its declared type.)
7026 EXAMPLE 1 The declaration
7028 int f(void), *fip(), (*pfi)();</pre>
7029 declares a function f with no parameters returning an int, a function fip with no parameter specification
7030 returning a pointer to an int, and a pointer pfi to a function with no parameter specification returning an
7031 int. It is especially useful to compare the last two. The binding of *fip() is *(fip()), so that the
7032 declaration suggests, and the same construction in an expression requires, the calling of a function fip,
7033 and then using indirection through the pointer result to yield an int. In the declarator (*pfi)(), the
7034 extra parentheses are necessary to indicate that indirection through a pointer to a function yields a function
7035 designator, which is then used to call the function; it returns an int.
7037 If the declaration occurs outside of any function, the identifiers have file scope and external linkage. If the
7038 declaration occurs inside a function, the identifiers of the functions f and fip have block scope and either
7039 internal or external linkage (depending on what file scope declarations for these identifiers are visible), and
7040 the identifier of the pointer pfi has block scope and no linkage.
7043 EXAMPLE 2 The declaration
7045 int (*apfi[3])(int *x, int *y);</pre>
7046 declares an array apfi of three pointers to functions returning int. Each of these functions has two
7047 parameters that are pointers to int. The identifiers x and y are declared for descriptive purposes only and
7048 go out of scope at the end of the declaration of apfi.
7051 EXAMPLE 3 The declaration
7053 int (*fpfi(int (*)(long), int))(int, ...);</pre>
7054 declares a function fpfi that returns a pointer to a function returning an int. The function fpfi has two
7055 parameters: a pointer to a function returning an int (with one parameter of type long int), and an int.
7056 The pointer returned by fpfi points to a function that has one int parameter and accepts zero or more
7059 <!--page 152 indent 5-->
7060 additional arguments of any type.
7063 EXAMPLE 4 The following prototype has a variably modified parameter.
7065 void addscalar(int n, int m,
7066 double a[n][n*m+300], double x);
7070 addscalar(4, 2, b, <a href="#2.17">2.17</a>);
7073 void addscalar(int n, int m,
7074 double a[n][n*m+300], double x)
7076 for (int i = 0; i < n; i++)
7077 for (int j = 0, k = n*m+300; j < k; j++)
7078 // a is a pointer to a VLA with n*m+300 elements
7083 EXAMPLE 5 The following are all compatible function prototype declarators.
7085 double maximum(int n, int m, double a[n][m]);
7086 double maximum(int n, int m, double a[*][*]);
7087 double maximum(int n, int m, double a[ ][*]);
7088 double maximum(int n, int m, double a[ ][m]);</pre>
7091 void f(double (* restrict a)[5]);
7092 void f(double a[restrict][5]);
7093 void f(double a[restrict 3][5]);
7094 void f(double a[restrict static 3][5]);</pre>
7095 (Note that the last declaration also specifies that the argument corresponding to a in any call to f must be a
7096 non-null pointer to the first of at least three arrays of 5 doubles, which the others do not.)
7098 Forward references: function definitions (<a href="#6.9.1">6.9.1</a>), type names (<a href="#6.7.7">6.7.7</a>).
7099 <!--page 153 indent 4-->
7102 <p><a name="note144">144)</a> The macros defined in the <stdarg.h> header (<a href="#7.16">7.16</a>) may be used to access arguments that
7103 correspond to the ellipsis.
7105 <p><a name="note145">145)</a> See ''future language directions'' (<a href="#6.11.6">6.11.6</a>).
7107 <p><a name="note146">146)</a> If both function types are ''old style'', parameter types are not compared.
7110 <a name="6.7.7" href="#6.7.7"><h4>6.7.7 Type names</h4></a>
7115 specifier-qualifier-list abstract-declaratoropt
7116 abstract-declarator:
7118 pointeropt direct-abstract-declarator
7119 direct-abstract-declarator:
7120 ( abstract-declarator )
7121 direct-abstract-declaratoropt [ type-qualifier-listopt
7122 assignment-expressionopt ]
7123 direct-abstract-declaratoropt [ static type-qualifier-listopt
7124 assignment-expression ]
7125 direct-abstract-declaratoropt [ type-qualifier-list static
7126 assignment-expression ]
7127 direct-abstract-declaratoropt [ * ]
7128 direct-abstract-declaratoropt ( parameter-type-listopt )</pre>
7131 In several contexts, it is necessary to specify a type. This is accomplished using a type
7132 name, which is syntactically a declaration for a function or an object of that type that
7133 omits the identifier.<sup><a href="#note147"><b>147)</b></a></sup>
7135 EXAMPLE The constructions
7144 (h) int (*const [])(unsigned int, ...)</pre>
7145 name respectively the types (a) int, (b) pointer to int, (c) array of three pointers to int, (d) pointer to an
7146 array of three ints, (e) pointer to a variable length array of an unspecified number of ints, (f) function
7147 with no parameter specification returning a pointer to int, (g) pointer to function with no parameters
7148 returning an int, and (h) array of an unspecified number of constant pointers to functions, each with one
7149 parameter that has type unsigned int and an unspecified number of other parameters, returning an
7155 <!--page 154 indent 4-->
7158 <p><a name="note147">147)</a> As indicated by the syntax, empty parentheses in a type name are interpreted as ''function with no
7159 parameter specification'', rather than redundant parentheses around the omitted identifier.
7162 <a name="6.7.8" href="#6.7.8"><h4>6.7.8 Type definitions</h4></a>
7168 <h6>Constraints</h6>
7170 If a typedef name specifies a variably modified type then it shall have block scope.
7173 In a declaration whose storage-class specifier is typedef, each declarator defines an
7174 identifier to be a typedef name that denotes the type specified for the identifier in the way
7175 described in <a href="#6.7.6">6.7.6</a>. Any array size expressions associated with variable length array
7176 declarators are evaluated each time the declaration of the typedef name is reached in the
7177 order of execution. A typedef declaration does not introduce a new type, only a
7178 synonym for the type so specified. That is, in the following declarations:
7180 typedef T type_ident;
7182 type_ident is defined as a typedef name with the type specified by the declaration
7183 specifiers in T (known as T ), and the identifier in D has the type ''derived-declarator-
7184 type-list T '' where the derived-declarator-type-list is specified by the declarators of D. A
7185 typedef name shares the same name space as other identifiers declared in ordinary
7190 typedef int MILES, KLICKSP();
7191 typedef struct { double hi, lo; } range;</pre>
7195 extern KLICKSP *metricp;
7198 are all valid declarations. The type of distance is int, that of metricp is ''pointer to function with no
7199 parameter specification returning int'', and that of x and z is the specified structure; zp is a pointer to
7200 such a structure. The object distance has a type compatible with any other int object.
7203 EXAMPLE 2 After the declarations
7205 typedef struct s1 { int x; } t1, *tp1;
7206 typedef struct s2 { int x; } t2, *tp2;</pre>
7207 type t1 and the type pointed to by tp1 are compatible. Type t1 is also compatible with type struct
7208 s1, but not compatible with the types struct s2, t2, the type pointed to by tp2, or int.
7209 <!--page 155 indent 4-->
7211 EXAMPLE 3 The following obscure constructions
7213 typedef signed int t;
7220 declare a typedef name t with type signed int, a typedef name plain with type int, and a structure
7221 with three bit-field members, one named t that contains values in the range [0, 15], an unnamed const-
7222 qualified bit-field which (if it could be accessed) would contain values in either the range [-15, +15] or
7223 [-16, +15], and one named r that contains values in one of the ranges [0, 31], [-15, +15], or [-16, +15].
7224 (The choice of range is implementation-defined.) The first two bit-field declarations differ in that
7225 unsigned is a type specifier (which forces t to be the name of a structure member), while const is a
7226 type qualifier (which modifies t which is still visible as a typedef name). If these declarations are followed
7227 in an inner scope by
7231 then a function f is declared with type ''function returning signed int with one unnamed parameter
7232 with type pointer to function returning signed int with one unnamed parameter with type signed
7233 int'', and an identifier t with type long int.
7236 EXAMPLE 4 On the other hand, typedef names can be used to improve code readability. All three of the
7237 following declarations of the signal function specify exactly the same type, the first without making use
7238 of any typedef names.
7240 typedef void fv(int), (*pfv)(int);
7241 void (*signal(int, void (*)(int)))(int);
7242 fv *signal(int, fv *);
7243 pfv signal(int, pfv);</pre>
7246 EXAMPLE 5 If a typedef name denotes a variable length array type, the length of the array is fixed at the
7247 time the typedef name is defined, not each time it is used:
7248 <!--page 156 indent 4-->
7252 typedef int B[n]; // B is n ints, n evaluated now
7254 B a; // a is n ints, n without += 1
7255 int b[n]; // a and b are different sizes
7256 for (int i = 1; i < n; i++)
7260 <a name="6.7.9" href="#6.7.9"><h4>6.7.9 Initialization</h4></a>
7265 assignment-expression
7266 { initializer-list }
7267 { initializer-list , }
7269 designationopt initializer
7270 initializer-list , designationopt initializer
7275 designator-list designator
7277 [ constant-expression ]
7279 <h6>Constraints</h6>
7281 No initializer shall attempt to provide a value for an object not contained within the entity
7284 The type of the entity to be initialized shall be an array of unknown size or a complete
7285 object type that is not a variable length array type.
7287 All the expressions in an initializer for an object that has static or thread storage duration
7288 shall be constant expressions or string literals.
7290 If the declaration of an identifier has block scope, and the identifier has external or
7291 internal linkage, the declaration shall have no initializer for the identifier.
7293 If a designator has the form
7295 [ constant-expression ]</pre>
7296 then the current object (defined below) shall have array type and the expression shall be
7297 an integer constant expression. If the array is of unknown size, any nonnegative value is
7300 If a designator has the form
7303 then the current object (defined below) shall have structure or union type and the
7304 identifier shall be the name of a member of that type.
7305 <!--page 157 indent 5-->
7308 An initializer specifies the initial value stored in an object.
7310 Except where explicitly stated otherwise, for the purposes of this subclause unnamed
7311 members of objects of structure and union type do not participate in initialization.
7312 Unnamed members of structure objects have indeterminate value even after initialization.
7314 If an object that has automatic storage duration is not initialized explicitly, its value is
7315 indeterminate. If an object that has static or thread storage duration is not initialized
7318 <li> if it has pointer type, it is initialized to a null pointer;
7319 <li> if it has arithmetic type, it is initialized to (positive or unsigned) zero;
7320 <li> if it is an aggregate, every member is initialized (recursively) according to these rules,
7321 and any padding is initialized to zero bits;
7322 <li> if it is a union, the first named member is initialized (recursively) according to these
7323 rules, and any padding is initialized to zero bits;
7326 The initializer for a scalar shall be a single expression, optionally enclosed in braces. The
7327 initial value of the object is that of the expression (after conversion); the same type
7328 constraints and conversions as for simple assignment apply, taking the type of the scalar
7329 to be the unqualified version of its declared type.
7331 The rest of this subclause deals with initializers for objects that have aggregate or union
7334 The initializer for a structure or union object that has automatic storage duration shall be
7335 either an initializer list as described below, or a single expression that has compatible
7336 structure or union type. In the latter case, the initial value of the object, including
7337 unnamed members, is that of the expression.
7339 An array of character type may be initialized by a character string literal or UTF-8 string
7340 literal, optionally enclosed in braces. Successive bytes of the string literal (including the
7341 terminating null character if there is room or if the array is of unknown size) initialize the
7342 elements of the array.
7344 An array with element type compatible with a qualified or unqualified version of
7345 wchar_t may be initialized by a wide string literal, optionally enclosed in braces.
7346 Successive wide characters of the wide string literal (including the terminating null wide
7347 character if there is room or if the array is of unknown size) initialize the elements of the
7350 Otherwise, the initializer for an object that has aggregate or union type shall be a brace-
7351 enclosed list of initializers for the elements or named members.
7352 <!--page 158 indent 5-->
7354 Each brace-enclosed initializer list has an associated current object. When no
7355 designations are present, subobjects of the current object are initialized in order according
7356 to the type of the current object: array elements in increasing subscript order, structure
7357 members in declaration order, and the first named member of a union.<sup><a href="#note148"><b>148)</b></a></sup> In contrast, a
7358 designation causes the following initializer to begin initialization of the subobject
7359 described by the designator. Initialization then continues forward in order, beginning
7360 with the next subobject after that described by the designator.<sup><a href="#note149"><b>149)</b></a></sup>
7362 Each designator list begins its description with the current object associated with the
7363 closest surrounding brace pair. Each item in the designator list (in order) specifies a
7364 particular member of its current object and changes the current object for the next
7365 designator (if any) to be that member.<sup><a href="#note150"><b>150)</b></a></sup> The current object that results at the end of the
7366 designator list is the subobject to be initialized by the following initializer.
7368 The initialization shall occur in initializer list order, each initializer provided for a
7369 particular subobject overriding any previously listed initializer for the same subobject;<sup><a href="#note151"><b>151)</b></a></sup>
7370 all subobjects that are not initialized explicitly shall be initialized implicitly the same as
7371 objects that have static storage duration.
7373 If the aggregate or union contains elements or members that are aggregates or unions,
7374 these rules apply recursively to the subaggregates or contained unions. If the initializer of
7375 a subaggregate or contained union begins with a left brace, the initializers enclosed by
7376 that brace and its matching right brace initialize the elements or members of the
7377 subaggregate or the contained union. Otherwise, only enough initializers from the list are
7378 taken to account for the elements or members of the subaggregate or the first member of
7379 the contained union; any remaining initializers are left to initialize the next element or
7380 member of the aggregate of which the current subaggregate or contained union is a part.
7382 If there are fewer initializers in a brace-enclosed list than there are elements or members
7383 of an aggregate, or fewer characters in a string literal used to initialize an array of known
7384 size than there are elements in the array, the remainder of the aggregate shall be
7385 initialized implicitly the same as objects that have static storage duration.
7389 <!--page 159 indent 5-->
7391 If an array of unknown size is initialized, its size is determined by the largest indexed
7392 element with an explicit initializer. The array type is completed at the end of its
7395 The evaluations of the initialization list expressions are indeterminately sequenced with
7396 respect to one another and thus the order in which any side effects occur is
7397 unspecified.<sup><a href="#note152"><b>152)</b></a></sup>
7399 EXAMPLE 1 Provided that <complex.h> has been #included, the declarations
7401 int i = <a href="#3.5">3.5</a>;
7402 double complex c = 5 + 3 * I;</pre>
7403 define and initialize i with the value 3 and c with the value 5.0 + i3.0.
7406 EXAMPLE 2 The declaration
7408 int x[] = { 1, 3, 5 };</pre>
7409 defines and initializes x as a one-dimensional array object that has three elements, as no size was specified
7410 and there are three initializers.
7413 EXAMPLE 3 The declaration
7420 is a definition with a fully bracketed initialization: 1, 3, and 5 initialize the first row of y (the array object
7421 y[0]), namely y[0][0], y[0][1], and y[0][2]. Likewise the next two lines initialize y[1] and
7422 y[2]. The initializer ends early, so y[3] is initialized with zeros. Precisely the same effect could have
7426 1, 3, 5, 2, 4, 6, 3, 5, 7
7428 The initializer for y[0] does not begin with a left brace, so three items from the list are used. Likewise the
7429 next three are taken successively for y[1] and y[2].
7432 EXAMPLE 4 The declaration
7435 { 1 }, { 2 }, { 3 }, { 4 }
7437 initializes the first column of z as specified and initializes the rest with zeros.
7440 EXAMPLE 5 The declaration
7442 struct { int a[3], b; } w[] = { { 1 }, 2 };</pre>
7443 is a definition with an inconsistently bracketed initialization. It defines an array with two element
7447 <!--page 160 indent 5-->
7448 structures: w[0].a[0] is 1 and w[1].a[0] is 2; all the other elements are zero.
7451 EXAMPLE 6 The declaration
7453 short q[4][3][2] = {
7458 contains an incompletely but consistently bracketed initialization. It defines a three-dimensional array
7459 object: q[0][0][0] is 1, q[1][0][0] is 2, q[1][0][1] is 3, and 4, 5, and 6 initialize
7460 q[2][0][0], q[2][0][1], and q[2][1][0], respectively; all the rest are zero. The initializer for
7461 q[0][0] does not begin with a left brace, so up to six items from the current list may be used. There is
7462 only one, so the values for the remaining five elements are initialized with zero. Likewise, the initializers
7463 for q[1][0] and q[2][0] do not begin with a left brace, so each uses up to six items, initializing their
7464 respective two-dimensional subaggregates. If there had been more than six items in any of the lists, a
7465 diagnostic message would have been issued. The same initialization result could have been achieved by:
7467 short q[4][3][2] = {
7474 short q[4][3][2] = {
7486 in a fully bracketed form.
7488 Note that the fully bracketed and minimally bracketed forms of initialization are, in general, less likely to
7492 EXAMPLE 7 One form of initialization that completes array types involves typedef names. Given the
7495 typedef int A[]; // OK - declared with block scope</pre>
7498 A a = { 1, 2 }, b = { 3, 4, 5 };</pre>
7501 int a[] = { 1, 2 }, b[] = { 3, 4, 5 };</pre>
7502 due to the rules for incomplete types.
7503 <!--page 161 indent 5-->
7505 EXAMPLE 8 The declaration
7507 char s[] = "abc", t[3] = "abc";</pre>
7508 defines ''plain'' char array objects s and t whose elements are initialized with character string literals.
7509 This declaration is identical to
7511 char s[] = { 'a', 'b', 'c', '\0' },
7512 t[] = { 'a', 'b', 'c' };</pre>
7513 The contents of the arrays are modifiable. On the other hand, the declaration
7515 char *p = "abc";</pre>
7516 defines p with type ''pointer to char'' and initializes it to point to an object with type ''array of char''
7517 with length 4 whose elements are initialized with a character string literal. If an attempt is made to use p to
7518 modify the contents of the array, the behavior is undefined.
7521 EXAMPLE 9 Arrays can be initialized to correspond to the elements of an enumeration by using
7524 enum { member_one, member_two };
7525 const char *nm[] = {
7526 [member_two] = "member two",
7527 [member_one] = "member one",
7531 EXAMPLE 10 Structure members can be initialized to nonzero values without depending on their order:
7533 div_t answer = { .quot = 2, .rem = -1 };</pre>
7536 EXAMPLE 11 Designators can be used to provide explicit initialization when unadorned initializer lists
7537 might be misunderstood:
7539 struct { int a[3], b; } w[] =
7540 { [0].a = {1}, [1].a[0] = 2 };</pre>
7543 EXAMPLE 12 Space can be ''allocated'' from both ends of an array by using a single designator:
7547 1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0
7549 In the above, if MAX is greater than ten, there will be some zero-valued elements in the middle; if it is less
7550 than ten, some of the values provided by the first five initializers will be overridden by the second five.
7553 EXAMPLE 13 Any member of a union can be initialized:
7555 union { /* ... */ } u = { .any_member = 42 };</pre>
7557 Forward references: common definitions <stddef.h> (<a href="#7.19">7.19</a>).
7558 <!--page 162 indent 4-->
7561 <p><a name="note148">148)</a> If the initializer list for a subaggregate or contained union does not begin with a left brace, its
7562 subobjects are initialized as usual, but the subaggregate or contained union does not become the
7563 current object: current objects are associated only with brace-enclosed initializer lists.
7565 <p><a name="note149">149)</a> After a union member is initialized, the next object is not the next member of the union; instead, it is
7566 the next subobject of an object containing the union.
7568 <p><a name="note150">150)</a> Thus, a designator can only specify a strict subobject of the aggregate or union that is associated with
7569 the surrounding brace pair. Note, too, that each separate designator list is independent.
7571 <p><a name="note151">151)</a> Any initializer for the subobject which is overridden and so not used to initialize that subobject might
7572 not be evaluated at all.
7574 <p><a name="note152">152)</a> In particular, the evaluation order need not be the same as the order of subobject initialization.
7577 <a name="6.7.10" href="#6.7.10"><h4>6.7.10 Static assertions</h4></a>
7581 static_assert-declaration:
7582 _Static_assert ( constant-expression , string-literal ) ;</pre>
7583 <h6>Constraints</h6>
7585 The constant expression shall compare unequal to 0.
7588 The constant expression shall be an integer constant expression. If the value of the
7589 constant expression compares unequal to 0, the declaration has no effect. Otherwise, the
7590 constraint is violated and the implementation shall produce a diagnostic message that
7591 includes the text of the string literal, except that characters not in the basic source
7592 character set are not required to appear in the message.
7593 Forward references: diagnostics (<a href="#7.2">7.2</a>).
7594 <!--page 163 indent 4-->
7596 <a name="6.8" href="#6.8"><h3>6.8 Statements and blocks</h3></a>
7603 expression-statement
7606 jump-statement</pre>
7609 A statement specifies an action to be performed. Except as indicated, statements are
7610 executed in sequence.
7612 A block allows a set of declarations and statements to be grouped into one syntactic unit.
7613 The initializers of objects that have automatic storage duration, and the variable length
7614 array declarators of ordinary identifiers with block scope, are evaluated and the values are
7615 stored in the objects (including storing an indeterminate value in objects without an
7616 initializer) each time the declaration is reached in the order of execution, as if it were a
7617 statement, and within each declaration in the order that declarators appear.
7619 A full expression is an expression that is not part of another expression or of a declarator.
7620 Each of the following is a full expression: an initializer that is not part of a compound
7621 literal; the expression in an expression statement; the controlling expression of a selection
7622 statement (if or switch); the controlling expression of a while or do statement; each
7623 of the (optional) expressions of a for statement; the (optional) expression in a return
7624 statement. There is a sequence point between the evaluation of a full expression and the
7625 evaluation of the next full expression to be evaluated.
7626 Forward references: expression and null statements (<a href="#6.8.3">6.8.3</a>), selection statements
7627 (<a href="#6.8.4">6.8.4</a>), iteration statements (<a href="#6.8.5">6.8.5</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>).
7629 <a name="6.8.1" href="#6.8.1"><h4>6.8.1 Labeled statements</h4></a>
7634 identifier : statement
7635 case constant-expression : statement
7636 default : statement</pre>
7637 <h6>Constraints</h6>
7639 A case or default label shall appear only in a switch statement. Further
7640 constraints on such labels are discussed under the switch statement.
7641 <!--page 164 indent 4-->
7643 Label names shall be unique within a function.
7646 Any statement may be preceded by a prefix that declares an identifier as a label name.
7647 Labels in themselves do not alter the flow of control, which continues unimpeded across
7649 Forward references: the goto statement (<a href="#6.8.6.1">6.8.6.1</a>), the switch statement (<a href="#6.8.4.2">6.8.4.2</a>).
7651 <a name="6.8.2" href="#6.8.2"><h4>6.8.2 Compound statement</h4></a>
7656 { block-item-listopt }
7659 block-item-list block-item
7665 A compound statement is a block.
7667 <a name="6.8.3" href="#6.8.3"><h4>6.8.3 Expression and null statements</h4></a>
7671 expression-statement:
7672 expressionopt ;</pre>
7675 The expression in an expression statement is evaluated as a void expression for its side
7676 effects.<sup><a href="#note153"><b>153)</b></a></sup>
7678 A null statement (consisting of just a semicolon) performs no operations.
7680 EXAMPLE 1 If a function call is evaluated as an expression statement for its side effects only, the
7681 discarding of its value may be made explicit by converting the expression to a void expression by means of
7690 <!--page 165 indent 4-->
7692 EXAMPLE 2 In the program fragment
7696 while (*s++ != '\0')
7698 a null statement is used to supply an empty loop body to the iteration statement.
7701 EXAMPLE 3 A null statement may also be used to carry a label just before the closing } of a compound
7716 Forward references: iteration statements (<a href="#6.8.5">6.8.5</a>).
7719 <p><a name="note153">153)</a> Such as assignments, and function calls which have side effects.
7722 <a name="6.8.4" href="#6.8.4"><h4>6.8.4 Selection statements</h4></a>
7726 selection-statement:
7727 if ( expression ) statement
7728 if ( expression ) statement else statement
7729 switch ( expression ) statement</pre>
7732 A selection statement selects among a set of statements depending on the value of a
7733 controlling expression.
7735 A selection statement is a block whose scope is a strict subset of the scope of its
7736 enclosing block. Each associated substatement is also a block whose scope is a strict
7737 subset of the scope of the selection statement.
7739 <a name="6.8.4.1" href="#6.8.4.1"><h5>6.8.4.1 The if statement</h5></a>
7740 <h6>Constraints</h6>
7742 The controlling expression of an if statement shall have scalar type.
7745 In both forms, the first substatement is executed if the expression compares unequal to 0.
7746 In the else form, the second substatement is executed if the expression compares equal
7747 <!--page 166 indent 4-->
7748 to 0. If the first substatement is reached via a label, the second substatement is not
7751 An else is associated with the lexically nearest preceding if that is allowed by the
7754 <a name="6.8.4.2" href="#6.8.4.2"><h5>6.8.4.2 The switch statement</h5></a>
7755 <h6>Constraints</h6>
7757 The controlling expression of a switch statement shall have integer type.
7759 If a switch statement has an associated case or default label within the scope of an
7760 identifier with a variably modified type, the entire switch statement shall be within the
7761 scope of that identifier.<sup><a href="#note154"><b>154)</b></a></sup>
7763 The expression of each case label shall be an integer constant expression and no two of
7764 the case constant expressions in the same switch statement shall have the same value
7765 after conversion. There may be at most one default label in a switch statement.
7766 (Any enclosed switch statement may have a default label or case constant
7767 expressions with values that duplicate case constant expressions in the enclosing
7771 A switch statement causes control to jump to, into, or past the statement that is the
7772 switch body, depending on the value of a controlling expression, and on the presence of a
7773 default label and the values of any case labels on or in the switch body. A case or
7774 default label is accessible only within the closest enclosing switch statement.
7776 The integer promotions are performed on the controlling expression. The constant
7777 expression in each case label is converted to the promoted type of the controlling
7778 expression. If a converted value matches that of the promoted controlling expression,
7779 control jumps to the statement following the matched case label. Otherwise, if there is
7780 a default label, control jumps to the labeled statement. If no converted case constant
7781 expression matches and there is no default label, no part of the switch body is
7783 Implementation limits
7785 As discussed in <a href="#5.2.4.1">5.2.4.1</a>, the implementation may limit the number of case values in a
7791 <!--page 167 indent 4-->
7793 EXAMPLE In the artificial program fragment
7801 /* falls through into default code */
7805 the object whose identifier is i exists with automatic storage duration (within the block) but is never
7806 initialized, and thus if the controlling expression has a nonzero value, the call to the printf function will
7807 access an indeterminate value. Similarly, the call to the function f cannot be reached.
7811 <p><a name="note154">154)</a> That is, the declaration either precedes the switch statement, or it follows the last case or
7812 default label associated with the switch that is in the block containing the declaration.
7815 <a name="6.8.5" href="#6.8.5"><h4>6.8.5 Iteration statements</h4></a>
7819 iteration-statement:
7820 while ( expression ) statement
7821 do statement while ( expression ) ;
7822 for ( expressionopt ; expressionopt ; expressionopt ) statement
7823 for ( declaration expressionopt ; expressionopt ) statement</pre>
7824 <h6>Constraints</h6>
7826 The controlling expression of an iteration statement shall have scalar type.
7828 The declaration part of a for statement shall only declare identifiers for objects having
7829 storage class auto or register.
7832 An iteration statement causes a statement called the loop body to be executed repeatedly
7833 until the controlling expression compares equal to 0. The repetition occurs regardless of
7834 whether the loop body is entered from the iteration statement or by a jump.<sup><a href="#note155"><b>155)</b></a></sup>
7836 An iteration statement is a block whose scope is a strict subset of the scope of its
7837 enclosing block. The loop body is also a block whose scope is a strict subset of the scope
7838 of the iteration statement.
7840 An iteration statement whose controlling expression is not a constant expression,<sup><a href="#note156"><b>156)</b></a></sup> that
7841 performs no input/output operations, does not access volatile objects, and performs no
7842 synchronization or atomic operations in its body, controlling expression, or (in the case of
7844 <!--page 168 indent 4-->
7845 a for statement) its expression-3, may be assumed by the implementation to
7846 terminate.<sup><a href="#note157"><b>157)</b></a></sup>
7849 <p><a name="note155">155)</a> Code jumped over is not executed. In particular, the controlling expression of a for or while
7850 statement is not evaluated before entering the loop body, nor is clause-1 of a for statement.
7852 <p><a name="note156">156)</a> An omitted controlling expression is replaced by a nonzero constant, which is a constant expression.
7854 <p><a name="note157">157)</a> This is intended to allow compiler transformations such as removal of empty loops even when
7855 termination cannot be proven.
7858 <a name="6.8.5.1" href="#6.8.5.1"><h5>6.8.5.1 The while statement</h5></a>
7860 The evaluation of the controlling expression takes place before each execution of the loop
7863 <a name="6.8.5.2" href="#6.8.5.2"><h5>6.8.5.2 The do statement</h5></a>
7865 The evaluation of the controlling expression takes place after each execution of the loop
7868 <a name="6.8.5.3" href="#6.8.5.3"><h5>6.8.5.3 The for statement</h5></a>
7872 for ( clause-1 ; expression-2 ; expression-3 ) statement</pre>
7873 behaves as follows: The expression expression-2 is the controlling expression that is
7874 evaluated before each execution of the loop body. The expression expression-3 is
7875 evaluated as a void expression after each execution of the loop body. If clause-1 is a
7876 declaration, the scope of any identifiers it declares is the remainder of the declaration and
7877 the entire loop, including the other two expressions; it is reached in the order of execution
7878 before the first evaluation of the controlling expression. If clause-1 is an expression, it is
7879 evaluated as a void expression before the first evaluation of the controlling expression.<sup><a href="#note158"><b>158)</b></a></sup>
7881 Both clause-1 and expression-3 can be omitted. An omitted expression-2 is replaced by a
7885 <p><a name="note158">158)</a> Thus, clause-1 specifies initialization for the loop, possibly declaring one or more variables for use in
7886 the loop; the controlling expression, expression-2, specifies an evaluation made before each iteration,
7887 such that execution of the loop continues until the expression compares equal to 0; and expression-3
7888 specifies an operation (such as incrementing) that is performed after each iteration.
7891 <a name="6.8.6" href="#6.8.6"><h4>6.8.6 Jump statements</h4></a>
7899 return expressionopt ;</pre>
7904 <!--page 169 indent 4-->
7907 A jump statement causes an unconditional jump to another place.
7909 <a name="6.8.6.1" href="#6.8.6.1"><h5>6.8.6.1 The goto statement</h5></a>
7910 <h6>Constraints</h6>
7912 The identifier in a goto statement shall name a label located somewhere in the enclosing
7913 function. A goto statement shall not jump from outside the scope of an identifier having
7914 a variably modified type to inside the scope of that identifier.
7917 A goto statement causes an unconditional jump to the statement prefixed by the named
7918 label in the enclosing function.
7920 EXAMPLE 1 It is sometimes convenient to jump into the middle of a complicated set of statements. The
7921 following outline presents one possible approach to a problem based on these three assumptions:
7923 <li> The general initialization code accesses objects only visible to the current function.
7924 <li> The general initialization code is too large to warrant duplication.
7925 <li> The code to determine the next operation is at the head of the loop. (To allow it to be reached by
7926 continue statements, for example.)
7927 <!--page 170 indent 4-->
7934 // determine next operation
7936 if (need to reinitialize) {
7937 // reinitialize-only code
7940 // general initialization code
7944 // handle other operations
7947 EXAMPLE 2 A goto statement is not allowed to jump past any declarations of objects with variably
7948 modified types. A jump within the scope, however, is permitted.
7950 goto lab3; // invalid: going INTO scope of VLA.
7953 a[j] = <a href="#4.4">4.4</a>;
7955 a[j] = <a href="#3.3">3.3</a>;
7956 goto lab4; // valid: going WITHIN scope of VLA.
7957 a[j] = <a href="#5.5">5.5</a>;
7959 a[j] = <a href="#6.6">6.6</a>;
7961 goto lab4; // invalid: going INTO scope of VLA.</pre>
7964 <a name="6.8.6.2" href="#6.8.6.2"><h5>6.8.6.2 The continue statement</h5></a>
7965 <h6>Constraints</h6>
7967 A continue statement shall appear only in or as a loop body.
7970 A continue statement causes a jump to the loop-continuation portion of the smallest
7971 enclosing iteration statement; that is, to the end of the loop body. More precisely, in each
7973 while (/* ... */) { do { for (/* ... */) {
7975 /* ... */ /* ... */ /* ... */
7976 continue; continue; continue;
7977 /* ... */ /* ... */ /* ... */</pre>
7978 contin: ; contin: ; contin: ;
7979 } } while (/* ... */); }
7980 unless the continue statement shown is in an enclosed iteration statement (in which
7981 case it is interpreted within that statement), it is equivalent to goto contin;.<sup><a href="#note159"><b>159)</b></a></sup>
7984 <p><a name="note159">159)</a> Following the contin: label is a null statement.
7987 <a name="6.8.6.3" href="#6.8.6.3"><h5>6.8.6.3 The break statement</h5></a>
7988 <h6>Constraints</h6>
7990 A break statement shall appear only in or as a switch body or loop body.
7993 A break statement terminates execution of the smallest enclosing switch or iteration
7998 <!--page 171 indent 4-->
8000 <a name="6.8.6.4" href="#6.8.6.4"><h5>6.8.6.4 The return statement</h5></a>
8001 <h6>Constraints</h6>
8003 A return statement with an expression shall not appear in a function whose return type
8004 is void. A return statement without an expression shall only appear in a function
8005 whose return type is void.
8008 A return statement terminates execution of the current function and returns control to
8009 its caller. A function may have any number of return statements.
8011 If a return statement with an expression is executed, the value of the expression is
8012 returned to the caller as the value of the function call expression. If the expression has a
8013 type different from the return type of the function in which it appears, the value is
8014 converted as if by assignment to an object having the return type of the function.<sup><a href="#note160"><b>160)</b></a></sup>
8018 struct s { double i; } f(void);
8034 g.u2.f3 = f();</pre>
8035 there is no undefined behavior, although there would be if the assignment were done directly (without using
8036 a function call to fetch the value).
8041 <!--page 172 indent 4-->
8044 <p><a name="note160">160)</a> The return statement is not an assignment. The overlap restriction of subclause <a href="#6.5.16.1">6.5.16.1</a> does not
8045 apply to the case of function return. The representation of floating-point values may have wider range
8046 or precision than implied by the type; a cast may be used to remove this extra range and precision.
8049 <a name="6.9" href="#6.9"><h3>6.9 External definitions</h3></a>
8054 external-declaration
8055 translation-unit external-declaration
8056 external-declaration:
8059 <h6>Constraints</h6>
8061 The storage-class specifiers auto and register shall not appear in the declaration
8062 specifiers in an external declaration.
8064 There shall be no more than one external definition for each identifier declared with
8065 internal linkage in a translation unit. Moreover, if an identifier declared with internal
8066 linkage is used in an expression (other than as a part of the operand of a sizeof
8067 operator whose result is an integer constant), there shall be exactly one external definition
8068 for the identifier in the translation unit.
8071 As discussed in <a href="#5.1.1.1">5.1.1.1</a>, the unit of program text after preprocessing is a translation unit,
8072 which consists of a sequence of external declarations. These are described as ''external''
8073 because they appear outside any function (and hence have file scope). As discussed in
8074 <a href="#6.7">6.7</a>, a declaration that also causes storage to be reserved for an object or a function named
8075 by the identifier is a definition.
8077 An external definition is an external declaration that is also a definition of a function
8078 (other than an inline definition) or an object. If an identifier declared with external
8079 linkage is used in an expression (other than as part of the operand of a sizeof operator
8080 whose result is an integer constant), somewhere in the entire program there shall be
8081 exactly one external definition for the identifier; otherwise, there shall be no more than
8082 one.<sup><a href="#note161"><b>161)</b></a></sup>
8087 <!--page 173 indent 4-->
8090 <p><a name="note161">161)</a> Thus, if an identifier declared with external linkage is not used in an expression, there need be no
8091 external definition for it.
8094 <a name="6.9.1" href="#6.9.1"><h4>6.9.1 Function definitions</h4></a>
8098 function-definition:
8099 declaration-specifiers declarator declaration-listopt compound-statement
8102 declaration-list declaration</pre>
8103 <h6>Constraints</h6>
8105 The identifier declared in a function definition (which is the name of the function) shall
8106 have a function type, as specified by the declarator portion of the function definition.<sup><a href="#note162"><b>162)</b></a></sup>
8108 The return type of a function shall be void or a complete object type other than array
8111 The storage-class specifier, if any, in the declaration specifiers shall be either extern or
8114 If the declarator includes a parameter type list, the declaration of each parameter shall
8115 include an identifier, except for the special case of a parameter list consisting of a single
8116 parameter of type void, in which case there shall not be an identifier. No declaration list
8119 If the declarator includes an identifier list, each declaration in the declaration list shall
8120 have at least one declarator, those declarators shall declare only identifiers from the
8121 identifier list, and every identifier in the identifier list shall be declared. An identifier
8122 declared as a typedef name shall not be redeclared as a parameter. The declarations in the
8123 declaration list shall contain no storage-class specifier other than register and no
8128 <!--page 174 indent 5-->
8131 The declarator in a function definition specifies the name of the function being defined
8132 and the identifiers of its parameters. If the declarator includes a parameter type list, the
8133 list also specifies the types of all the parameters; such a declarator also serves as a
8134 function prototype for later calls to the same function in the same translation unit. If the
8135 declarator includes an identifier list,<sup><a href="#note163"><b>163)</b></a></sup> the types of the parameters shall be declared in a
8136 following declaration list. In either case, the type of each parameter is adjusted as
8137 described in <a href="#6.7.6.3">6.7.6.3</a> for a parameter type list; the resulting type shall be a complete object
8140 If a function that accepts a variable number of arguments is defined without a parameter
8141 type list that ends with the ellipsis notation, the behavior is undefined.
8143 Each parameter has automatic storage duration; its identifier is an lvalue.<sup><a href="#note164"><b>164)</b></a></sup> The layout
8144 of the storage for parameters is unspecified.
8146 On entry to the function, the size expressions of each variably modified parameter are
8147 evaluated and the value of each argument expression is converted to the type of the
8148 corresponding parameter as if by assignment. (Array expressions and function
8149 designators as arguments were converted to pointers before the call.)
8151 After all parameters have been assigned, the compound statement that constitutes the
8152 body of the function definition is executed.
8154 If the } that terminates a function is reached, and the value of the function call is used by
8155 the caller, the behavior is undefined.
8157 EXAMPLE 1 In the following:
8159 extern int max(int a, int b)
8161 return a > b ? a : b;
8163 extern is the storage-class specifier and int is the type specifier; max(int a, int b) is the
8164 function declarator; and
8166 { return a > b ? a : b; }</pre>
8167 is the function body. The following similar definition uses the identifier-list form for the parameter
8173 <!--page 175 indent 5-->
8175 extern int max(a, b)
8178 return a > b ? a : b;
8180 Here int a, b; is the declaration list for the parameters. The difference between these two definitions is
8181 that the first form acts as a prototype declaration that forces conversion of the arguments of subsequent calls
8182 to the function, whereas the second form does not.
8185 EXAMPLE 2 To pass one function to another, one might say
8190 Then the definition of g might read
8192 void g(int (*funcp)(void))
8195 (*funcp)(); /* or funcp(); ... */
8199 void g(int func(void))
8202 func(); /* or (*func)(); ... */
8207 <p><a name="note162">162)</a> The intent is that the type category in a function definition cannot be inherited from a typedef:
8210 typedef int F(void); // type F is ''function with no parameters
8212 F f, g; // f and g both have type compatible with F
8213 F f { /* ... */ } // WRONG: syntax/constraint error
8214 F g() { /* ... */ } // WRONG: declares that g returns a function
8215 int f(void) { /* ... */ } // RIGHT: f has type compatible with F
8216 int g() { /* ... */ } // RIGHT: g has type compatible with F
8217 F *e(void) { /* ... */ } // e returns a pointer to a function
8218 F *((e))(void) { /* ... */ } // same: parentheses irrelevant
8219 int (*fp)(void); // fp points to a function that has type F
8220 F *Fp; // Fp points to a function that has type F</pre>
8222 <p><a name="note163">163)</a> See ''future language directions'' (<a href="#6.11.7">6.11.7</a>).
8224 <p><a name="note164">164)</a> A parameter identifier cannot be redeclared in the function body except in an enclosed block.
8227 <a name="6.9.2" href="#6.9.2"><h4>6.9.2 External object definitions</h4></a>
8230 If the declaration of an identifier for an object has file scope and an initializer, the
8231 declaration is an external definition for the identifier.
8233 A declaration of an identifier for an object that has file scope without an initializer, and
8234 without a storage-class specifier or with the storage-class specifier static, constitutes a
8235 tentative definition. If a translation unit contains one or more tentative definitions for an
8236 identifier, and the translation unit contains no external definition for that identifier, then
8237 the behavior is exactly as if the translation unit contains a file scope declaration of that
8238 identifier, with the composite type as of the end of the translation unit, with an initializer
8241 If the declaration of an identifier for an object is a tentative definition and has internal
8242 linkage, the declared type shall not be an incomplete type.
8243 <!--page 176 indent 4-->
8247 int i1 = 1; // definition, external linkage
8248 static int i2 = 2; // definition, internal linkage
8249 extern int i3 = 3; // definition, external linkage
8250 int i4; // tentative definition, external linkage
8251 static int i5; // tentative definition, internal linkage
8252 int i1; // valid tentative definition, refers to previous
8253 int i2; // <a href="#6.2.2">6.2.2</a> renders undefined, linkage disagreement
8254 int i3; // valid tentative definition, refers to previous
8255 int i4; // valid tentative definition, refers to previous
8256 int i5; // <a href="#6.2.2">6.2.2</a> renders undefined, linkage disagreement
8257 extern int i1; // refers to previous, whose linkage is external
8258 extern int i2; // refers to previous, whose linkage is internal
8259 extern int i3; // refers to previous, whose linkage is external
8260 extern int i4; // refers to previous, whose linkage is external
8261 extern int i5; // refers to previous, whose linkage is internal</pre>
8264 EXAMPLE 2 If at the end of the translation unit containing
8267 the array i still has incomplete type, the implicit initializer causes it to have one element, which is set to
8268 zero on program startup.
8269 <!--page 177 indent 4-->
8271 <a name="6.10" href="#6.10"><h3>6.10 Preprocessing directives</h3></a>
8274 <!--page 178 indent 4-->
8287 if-group elif-groupsopt else-groupopt endif-line
8289 # if constant-expression new-line groupopt
8290 # ifdef identifier new-line groupopt
8291 # ifndef identifier new-line groupopt
8294 elif-groups elif-group
8296 # elif constant-expression new-line groupopt
8298 # else new-line groupopt
8302 # include pp-tokens new-line
8303 # define identifier replacement-list new-line
8304 # define identifier lparen identifier-listopt )
8305 replacement-list new-line
8306 # define identifier lparen ... ) replacement-list new-line
8307 # define identifier lparen identifier-list , ... )
8308 replacement-list new-line
8309 # undef identifier new-line
8310 # line pp-tokens new-line
8311 # error pp-tokensopt new-line
8312 # pragma pp-tokensopt new-line
8315 pp-tokensopt new-line
8319 a ( character not immediately preceded by white-space
8324 pp-tokens preprocessing-token
8326 the new-line character</pre>
8327 <h6>Description</h6>
8329 A preprocessing directive consists of a sequence of preprocessing tokens that satisfies the
8330 following constraints: The first token in the sequence is a # preprocessing token that (at
8331 the start of translation phase 4) is either the first character in the source file (optionally
8332 after white space containing no new-line characters) or that follows white space
8333 containing at least one new-line character. The last token in the sequence is the first new-
8334 line character that follows the first token in the sequence.<sup><a href="#note165"><b>165)</b></a></sup> A new-line character ends
8335 the preprocessing directive even if it occurs within what would otherwise be an
8337 <!--page 179 indent 4-->
8338 invocation of a function-like macro.
8340 A text line shall not begin with a # preprocessing token. A non-directive shall not begin
8341 with any of the directive names appearing in the syntax.
8343 When in a group that is skipped (<a href="#6.10.1">6.10.1</a>), the directive syntax is relaxed to allow any
8344 sequence of preprocessing tokens to occur between the directive name and the following
8346 <h6>Constraints</h6>
8348 The only white-space characters that shall appear between preprocessing tokens within a
8349 preprocessing directive (from just after the introducing # preprocessing token through
8350 just before the terminating new-line character) are space and horizontal-tab (including
8351 spaces that have replaced comments or possibly other white-space characters in
8352 translation phase 3).
8355 The implementation can process and skip sections of source files conditionally, include
8356 other source files, and replace macros. These capabilities are called preprocessing,
8357 because conceptually they occur before translation of the resulting translation unit.
8359 The preprocessing tokens within a preprocessing directive are not subject to macro
8360 expansion unless otherwise stated.
8365 EMPTY # include <file.h></pre>
8366 the sequence of preprocessing tokens on the second line is not a preprocessing directive, because it does not
8367 begin with a # at the start of translation phase 4, even though it will do so after the macro EMPTY has been
8372 <p><a name="note165">165)</a> Thus, preprocessing directives are commonly called ''lines''. These ''lines'' have no other syntactic
8373 significance, as all white space is equivalent except in certain situations during preprocessing (see the
8374 # character string literal creation operator in <a href="#6.10.3.2">6.10.3.2</a>, for example).
8377 <a name="6.10.1" href="#6.10.1"><h4>6.10.1 Conditional inclusion</h4></a>
8378 <h6>Constraints</h6>
8380 The expression that controls conditional inclusion shall be an integer constant expression
8381 except that: identifiers (including those lexically identical to keywords) are interpreted as *
8382 described below;<sup><a href="#note166"><b>166)</b></a></sup> and it may contain unary operator expressions of the form
8384 defined identifier</pre>
8387 defined ( identifier )</pre>
8388 which evaluate to 1 if the identifier is currently defined as a macro name (that is, if it is
8391 <!--page 180 indent 4-->
8392 predefined or if it has been the subject of a #define preprocessing directive without an
8393 intervening #undef directive with the same subject identifier), 0 if it is not.
8395 Each preprocessing token that remains (in the list of preprocessing tokens that will
8396 become the controlling expression) after all macro replacements have occurred shall be in
8397 the lexical form of a token (<a href="#6.4">6.4</a>).
8400 Preprocessing directives of the forms
8402 # if constant-expression new-line groupopt
8403 # elif constant-expression new-line groupopt</pre>
8404 check whether the controlling constant expression evaluates to nonzero.
8406 Prior to evaluation, macro invocations in the list of preprocessing tokens that will become
8407 the controlling constant expression are replaced (except for those macro names modified
8408 by the defined unary operator), just as in normal text. If the token defined is
8409 generated as a result of this replacement process or use of the defined unary operator
8410 does not match one of the two specified forms prior to macro replacement, the behavior is
8411 undefined. After all replacements due to macro expansion and the defined unary
8412 operator have been performed, all remaining identifiers (including those lexically
8413 identical to keywords) are replaced with the pp-number 0, and then each preprocessing
8414 token is converted into a token. The resulting tokens compose the controlling constant
8415 expression which is evaluated according to the rules of <a href="#6.6">6.6</a>. For the purposes of this
8416 token conversion and evaluation, all signed integer types and all unsigned integer types
8417 act as if they have the same representation as, respectively, the types intmax_t and
8418 uintmax_t defined in the header <stdint.h>.<sup><a href="#note167"><b>167)</b></a></sup> This includes interpreting
8419 character constants, which may involve converting escape sequences into execution
8420 character set members. Whether the numeric value for these character constants matches
8421 the value obtained when an identical character constant occurs in an expression (other
8422 than within a #if or #elif directive) is implementation-defined.<sup><a href="#note168"><b>168)</b></a></sup> Also, whether a
8423 single-character character constant may have a negative value is implementation-defined.
8428 <!--page 181 indent 4-->
8430 Preprocessing directives of the forms
8432 # ifdef identifier new-line groupopt
8433 # ifndef identifier new-line groupopt</pre>
8434 check whether the identifier is or is not currently defined as a macro name. Their
8435 conditions are equivalent to #if defined identifier and #if !defined identifier
8438 Each directive's condition is checked in order. If it evaluates to false (zero), the group
8439 that it controls is skipped: directives are processed only through the name that determines
8440 the directive in order to keep track of the level of nested conditionals; the rest of the
8441 directives' preprocessing tokens are ignored, as are the other preprocessing tokens in the
8442 group. Only the first group whose control condition evaluates to true (nonzero) is
8443 processed. If none of the conditions evaluates to true, and there is a #else directive, the
8444 group controlled by the #else is processed; lacking a #else directive, all the groups
8445 until the #endif are skipped.<sup><a href="#note169"><b>169)</b></a></sup>
8446 Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>), source file inclusion (<a href="#6.10.2">6.10.2</a>), largest
8447 integer types (<a href="#7.20.1.5">7.20.1.5</a>).
8450 <p><a name="note166">166)</a> Because the controlling constant expression is evaluated during translation phase 4, all identifiers
8451 either are or are not macro names -- there simply are no keywords, enumeration constants, etc.
8453 <p><a name="note167">167)</a> Thus, on an implementation where INT_MAX is 0x7FFF and UINT_MAX is 0xFFFF, the constant
8454 0x8000 is signed and positive within a #if expression even though it would be unsigned in
8455 translation phase 7.
8457 <p><a name="note168">168)</a> Thus, the constant expression in the following #if directive and if statement is not guaranteed to
8458 evaluate to the same value in these two contexts.
8460 if ('z' - 'a' == 25)
8462 <p><a name="note169">169)</a> As indicated by the syntax, a preprocessing token shall not follow a #else or #endif directive
8463 before the terminating new-line character. However, comments may appear anywhere in a source file,
8464 including within a preprocessing directive.
8467 <a name="6.10.2" href="#6.10.2"><h4>6.10.2 Source file inclusion</h4></a>
8468 <h6>Constraints</h6>
8470 A #include directive shall identify a header or source file that can be processed by the
8474 A preprocessing directive of the form
8476 # include <h-char-sequence> new-line</pre>
8477 searches a sequence of implementation-defined places for a header identified uniquely by
8478 the specified sequence between the < and > delimiters, and causes the replacement of that
8479 directive by the entire contents of the header. How the places are specified or the header
8480 identified is implementation-defined.
8482 A preprocessing directive of the form
8484 # include "q-char-sequence" new-line</pre>
8485 causes the replacement of that directive by the entire contents of the source file identified
8486 by the specified sequence between the " delimiters. The named source file is searched
8489 <!--page 182 indent 4-->
8490 for in an implementation-defined manner. If this search is not supported, or if the search
8491 fails, the directive is reprocessed as if it read
8493 # include <h-char-sequence> new-line</pre>
8494 with the identical contained sequence (including > characters, if any) from the original
8497 A preprocessing directive of the form
8499 # include pp-tokens new-line</pre>
8500 (that does not match one of the two previous forms) is permitted. The preprocessing
8501 tokens after include in the directive are processed just as in normal text. (Each
8502 identifier currently defined as a macro name is replaced by its replacement list of
8503 preprocessing tokens.) The directive resulting after all replacements shall match one of
8504 the two previous forms.<sup><a href="#note170"><b>170)</b></a></sup> The method by which a sequence of preprocessing tokens
8505 between a < and a > preprocessing token pair or a pair of " characters is combined into a
8506 single header name preprocessing token is implementation-defined.
8508 The implementation shall provide unique mappings for sequences consisting of one or
8509 more nondigits or digits (<a href="#6.4.2.1">6.4.2.1</a>) followed by a period (.) and a single nondigit. The
8510 first character shall not be a digit. The implementation may ignore distinctions of
8511 alphabetical case and restrict the mapping to eight significant characters before the
8514 A #include preprocessing directive may appear in a source file that has been read
8515 because of a #include directive in another file, up to an implementation-defined
8516 nesting limit (see <a href="#5.2.4.1">5.2.4.1</a>).
8518 EXAMPLE 1 The most common uses of #include preprocessing directives are as in the following:
8520 #include <stdio.h>
8521 #include "myprog.h"</pre>
8526 <!--page 183 indent 4-->
8528 EXAMPLE 2 This illustrates macro-replaced #include directives:
8531 #define INCFILE "vers1.h"
8533 #define INCFILE "vers2.h" // and so on
8535 #define INCFILE "versN.h"
8537 #include INCFILE</pre>
8539 Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>).
8542 <p><a name="note170">170)</a> Note that adjacent string literals are not concatenated into a single string literal (see the translation
8543 phases in <a href="#5.1.1.2">5.1.1.2</a>); thus, an expansion that results in two string literals is an invalid directive.
8546 <a name="6.10.3" href="#6.10.3"><h4>6.10.3 Macro replacement</h4></a>
8547 <h6>Constraints</h6>
8549 Two replacement lists are identical if and only if the preprocessing tokens in both have
8550 the same number, ordering, spelling, and white-space separation, where all white-space
8551 separations are considered identical.
8553 An identifier currently defined as an object-like macro shall not be redefined by another
8554 #define preprocessing directive unless the second definition is an object-like macro
8555 definition and the two replacement lists are identical. Likewise, an identifier currently
8556 defined as a function-like macro shall not be redefined by another #define
8557 preprocessing directive unless the second definition is a function-like macro definition
8558 that has the same number and spelling of parameters, and the two replacement lists are
8561 There shall be white-space between the identifier and the replacement list in the definition
8562 of an object-like macro.
8564 If the identifier-list in the macro definition does not end with an ellipsis, the number of
8565 arguments (including those arguments consisting of no preprocessing tokens) in an
8566 invocation of a function-like macro shall equal the number of parameters in the macro
8567 definition. Otherwise, there shall be more arguments in the invocation than there are
8568 parameters in the macro definition (excluding the ...). There shall exist a )
8569 preprocessing token that terminates the invocation.
8571 The identifier __VA_ARGS__ shall occur only in the replacement-list of a function-like
8572 macro that uses the ellipsis notation in the parameters.
8574 A parameter identifier in a function-like macro shall be uniquely declared within its
8578 The identifier immediately following the define is called the macro name. There is one
8579 name space for macro names. Any white-space characters preceding or following the
8580 replacement list of preprocessing tokens are not considered part of the replacement list
8581 <!--page 184 indent 5-->
8582 for either form of macro.
8584 If a # preprocessing token, followed by an identifier, occurs lexically at the point at which
8585 a preprocessing directive could begin, the identifier is not subject to macro replacement.
8587 A preprocessing directive of the form
8589 # define identifier replacement-list new-line</pre>
8590 defines an object-like macro that causes each subsequent instance of the macro name<sup><a href="#note171"><b>171)</b></a></sup>
8591 to be replaced by the replacement list of preprocessing tokens that constitute the
8592 remainder of the directive. The replacement list is then rescanned for more macro names
8595 A preprocessing directive of the form
8597 # define identifier lparen identifier-listopt ) replacement-list new-line
8598 # define identifier lparen ... ) replacement-list new-line
8599 # define identifier lparen identifier-list , ... ) replacement-list new-line</pre>
8600 defines a function-like macro with parameters, whose use is similar syntactically to a
8601 function call. The parameters are specified by the optional list of identifiers, whose scope
8602 extends from their declaration in the identifier list until the new-line character that
8603 terminates the #define preprocessing directive. Each subsequent instance of the
8604 function-like macro name followed by a ( as the next preprocessing token introduces the
8605 sequence of preprocessing tokens that is replaced by the replacement list in the definition
8606 (an invocation of the macro). The replaced sequence of preprocessing tokens is
8607 terminated by the matching ) preprocessing token, skipping intervening matched pairs of
8608 left and right parenthesis preprocessing tokens. Within the sequence of preprocessing
8609 tokens making up an invocation of a function-like macro, new-line is considered a normal
8610 white-space character.
8612 The sequence of preprocessing tokens bounded by the outside-most matching parentheses
8613 forms the list of arguments for the function-like macro. The individual arguments within
8614 the list are separated by comma preprocessing tokens, but comma preprocessing tokens
8615 between matching inner parentheses do not separate arguments. If there are sequences of
8616 preprocessing tokens within the list of arguments that would otherwise act as
8617 preprocessing directives,<sup><a href="#note172"><b>172)</b></a></sup> the behavior is undefined.
8619 If there is a ... in the identifier-list in the macro definition, then the trailing arguments,
8620 including any separating comma preprocessing tokens, are merged to form a single item:
8623 <!--page 185 indent 4-->
8624 the variable arguments. The number of arguments so combined is such that, following
8625 merger, the number of arguments is one more than the number of parameters in the macro
8626 definition (excluding the ...).
8629 <p><a name="note171">171)</a> Since, by macro-replacement time, all character constants and string literals are preprocessing tokens,
8630 not sequences possibly containing identifier-like subsequences (see <a href="#5.1.1.2">5.1.1.2</a>, translation phases), they
8631 are never scanned for macro names or parameters.
8633 <p><a name="note172">172)</a> Despite the name, a non-directive is a preprocessing directive.
8636 <a name="6.10.3.1" href="#6.10.3.1"><h5>6.10.3.1 Argument substitution</h5></a>
8638 After the arguments for the invocation of a function-like macro have been identified,
8639 argument substitution takes place. A parameter in the replacement list, unless preceded
8640 by a # or ## preprocessing token or followed by a ## preprocessing token (see below), is
8641 replaced by the corresponding argument after all macros contained therein have been
8642 expanded. Before being substituted, each argument's preprocessing tokens are
8643 completely macro replaced as if they formed the rest of the preprocessing file; no other
8644 preprocessing tokens are available.
8646 An identifier __VA_ARGS__ that occurs in the replacement list shall be treated as if it
8647 were a parameter, and the variable arguments shall form the preprocessing tokens used to
8650 <a name="6.10.3.2" href="#6.10.3.2"><h5>6.10.3.2 The # operator</h5></a>
8651 <h6>Constraints</h6>
8653 Each # preprocessing token in the replacement list for a function-like macro shall be
8654 followed by a parameter as the next preprocessing token in the replacement list.
8657 If, in the replacement list, a parameter is immediately preceded by a # preprocessing
8658 token, both are replaced by a single character string literal preprocessing token that
8659 contains the spelling of the preprocessing token sequence for the corresponding
8660 argument. Each occurrence of white space between the argument's preprocessing tokens
8661 becomes a single space character in the character string literal. White space before the
8662 first preprocessing token and after the last preprocessing token composing the argument
8663 is deleted. Otherwise, the original spelling of each preprocessing token in the argument
8664 is retained in the character string literal, except for special handling for producing the
8665 spelling of string literals and character constants: a \ character is inserted before each "
8666 and \ character of a character constant or string literal (including the delimiting "
8667 characters), except that it is implementation-defined whether a \ character is inserted
8668 before the \ character beginning a universal character name. If the replacement that
8669 results is not a valid character string literal, the behavior is undefined. The character
8670 string literal corresponding to an empty argument is "". The order of evaluation of # and
8671 ## operators is unspecified.
8672 <!--page 186 indent 4-->
8674 <a name="6.10.3.3" href="#6.10.3.3"><h5>6.10.3.3 The ## operator</h5></a>
8675 <h6>Constraints</h6>
8677 A ## preprocessing token shall not occur at the beginning or at the end of a replacement
8678 list for either form of macro definition.
8681 If, in the replacement list of a function-like macro, a parameter is immediately preceded
8682 or followed by a ## preprocessing token, the parameter is replaced by the corresponding
8683 argument's preprocessing token sequence; however, if an argument consists of no
8684 preprocessing tokens, the parameter is replaced by a placemarker preprocessing token
8685 instead.<sup><a href="#note173"><b>173)</b></a></sup>
8687 For both object-like and function-like macro invocations, before the replacement list is
8688 reexamined for more macro names to replace, each instance of a ## preprocessing token
8689 in the replacement list (not from an argument) is deleted and the preceding preprocessing
8690 token is concatenated with the following preprocessing token. Placemarker
8691 preprocessing tokens are handled specially: concatenation of two placemarkers results in
8692 a single placemarker preprocessing token, and concatenation of a placemarker with a
8693 non-placemarker preprocessing token results in the non-placemarker preprocessing token.
8694 If the result is not a valid preprocessing token, the behavior is undefined. The resulting
8695 token is available for further macro replacement. The order of evaluation of ## operators
8698 EXAMPLE In the following fragment:
8700 #define hash_hash # ## #
8701 #define mkstr(a) # a
8702 #define in_between(a) mkstr(a)
8703 #define join(c, d) in_between(c hash_hash d)
8704 char p[] = join(x, y); // equivalent to
8705 // char p[] = "x ## y";</pre>
8706 The expansion produces, at various stages:
8709 in_between(x hash_hash y)
8713 In other words, expanding hash_hash produces a new token, consisting of two adjacent sharp signs, but
8714 this new token is not the ## operator.
8717 <!--page 187 indent 4-->
8720 <p><a name="note173">173)</a> Placemarker preprocessing tokens do not appear in the syntax because they are temporary entities that
8721 exist only within translation phase 4.
8724 <a name="6.10.3.4" href="#6.10.3.4"><h5>6.10.3.4 Rescanning and further replacement</h5></a>
8726 After all parameters in the replacement list have been substituted and # and ##
8727 processing has taken place, all placemarker preprocessing tokens are removed. The
8728 resulting preprocessing token sequence is then rescanned, along with all subsequent
8729 preprocessing tokens of the source file, for more macro names to replace.
8731 If the name of the macro being replaced is found during this scan of the replacement list
8732 (not including the rest of the source file's preprocessing tokens), it is not replaced.
8733 Furthermore, if any nested replacements encounter the name of the macro being replaced,
8734 it is not replaced. These nonreplaced macro name preprocessing tokens are no longer
8735 available for further replacement even if they are later (re)examined in contexts in which
8736 that macro name preprocessing token would otherwise have been replaced.
8738 The resulting completely macro-replaced preprocessing token sequence is not processed
8739 as a preprocessing directive even if it resembles one, but all pragma unary operator
8740 expressions within it are then processed as specified in <a href="#6.10.9">6.10.9</a> below.
8742 <a name="6.10.3.5" href="#6.10.3.5"><h5>6.10.3.5 Scope of macro definitions</h5></a>
8744 A macro definition lasts (independent of block structure) until a corresponding #undef
8745 directive is encountered or (if none is encountered) until the end of the preprocessing
8746 translation unit. Macro definitions have no significance after translation phase 4.
8748 A preprocessing directive of the form
8750 # undef identifier new-line</pre>
8751 causes the specified identifier no longer to be defined as a macro name. It is ignored if
8752 the specified identifier is not currently defined as a macro name.
8754 EXAMPLE 1 The simplest use of this facility is to define a ''manifest constant'', as in
8757 int table[TABSIZE];</pre>
8760 EXAMPLE 2 The following defines a function-like macro whose value is the maximum of its arguments.
8761 It has the advantages of working for any compatible types of the arguments and of generating in-line code
8762 without the overhead of function calling. It has the disadvantages of evaluating one or the other of its
8763 arguments a second time (including side effects) and generating more code than a function if invoked
8764 several times. It also cannot have its address taken, as it has none.
8766 #define max(a, b) ((a) > (b) ? (a) : (b))</pre>
8767 The parentheses ensure that the arguments and the resulting expression are bound properly.
8768 <!--page 188 indent 4-->
8770 EXAMPLE 3 To illustrate the rules for redefinition and reexamination, the sequence
8773 #define f(a) f(x * (a))
8784 #define r(x,y) x ## y
8786 f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
8787 g(x+(3,4)-w) | h 5) & m
8789 p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
8790 char c[2][6] = { str(hello), str() };</pre>
8793 f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
8794 f(2 * (2+(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
8795 int i[] = { 1, 23, 4, 5, };
8796 char c[2][6] = { "hello", "" };</pre>
8799 EXAMPLE 4 To illustrate the rules for creating character string literals and concatenating tokens, the
8803 #define xstr(s) str(s)
8804 #define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \
8806 #define INCFILE(n) vers ## n
8807 #define glue(a, b) a ## b
8808 #define xglue(a, b) glue(a, b)
8809 #define HIGHLOW "hello"
8810 #define LOW LOW ", world"
8812 fputs(str(strncmp("abc\0d", "abc", '\4') // this goes away
8813 == 0) str(: @\n), s);
8814 #include xstr(INCFILE(2).h)
8816 xglue(HIGH, LOW)</pre>
8818 <!--page 189 indent 4-->
8820 printf("x" "1" "= %d, x" "2" "= %s", x1, x2);
8822 "strncmp(\"abc\\0d\", \"abc\", '\\4') == 0" ": @\n",
8824 #include "vers2.h" (after macro replacement, before file access)
8826 "hello" ", world"</pre>
8827 or, after concatenation of the character string literals,
8829 printf("x1= %d, x2= %s", x1, x2);
8831 "strncmp(\"abc\\0d\", \"abc\", '\\4') == 0: @\n",
8833 #include "vers2.h" (after macro replacement, before file access)
8835 "hello, world"</pre>
8836 Space around the # and ## tokens in the macro definition is optional.
8839 EXAMPLE 5 To illustrate the rules for placemarker preprocessing tokens, the sequence
8841 #define t(x,y,z) x ## y ## z
8842 int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
8843 t(10,,), t(,11,), t(,,12), t(,,) };</pre>
8846 int j[] = { 123, 45, 67, 89,
8847 10, 11, 12, };</pre>
8850 EXAMPLE 6 To demonstrate the redefinition rules, the following sequence is valid.
8852 #define OBJ_LIKE (1-1)
8853 #define OBJ_LIKE /* white space */ (1-1) /* other */
8854 #define FUNC_LIKE(a) ( a )
8855 #define FUNC_LIKE( a )( /* note the white space */ \
8856 a /* other stuff on this line
8858 But the following redefinitions are invalid:
8860 #define OBJ_LIKE (0) // different token sequence
8861 #define OBJ_LIKE (1 - 1) // different white space
8862 #define FUNC_LIKE(b) ( a ) // different parameter usage
8863 #define FUNC_LIKE(b) ( b ) // different parameter spelling</pre>
8866 EXAMPLE 7 Finally, to show the variable argument list macro facilities:
8867 <!--page 190 indent 4-->
8869 #define debug(...) fprintf(stderr, __VA_ARGS__)
8870 #define showlist(...) puts(#__VA_ARGS__)
8871 #define report(test, ...) ((test)?puts(#test):\
8872 printf(__VA_ARGS__))
8874 debug("X = %d\n", x);
8875 showlist(The first, second, and third items.);
8876 report(x>y, "x is %d but y is %d", x, y);</pre>
8879 fprintf(stderr, "Flag" );
8880 fprintf(stderr, "X = %d\n", x );
8881 puts( "The first, second, and third items." );
8882 ((x>y)?puts("x>y"):
8883 printf("x is %d but y is %d", x, y));</pre>
8886 <a name="6.10.4" href="#6.10.4"><h4>6.10.4 Line control</h4></a>
8887 <h6>Constraints</h6>
8889 The string literal of a #line directive, if present, shall be a character string literal.
8892 The line number of the current source line is one greater than the number of new-line
8893 characters read or introduced in translation phase 1 (<a href="#5.1.1.2">5.1.1.2</a>) while processing the source
8894 file to the current token.
8896 A preprocessing directive of the form
8898 # line digit-sequence new-line</pre>
8899 causes the implementation to behave as if the following sequence of source lines begins
8900 with a source line that has a line number as specified by the digit sequence (interpreted as
8901 a decimal integer). The digit sequence shall not specify zero, nor a number greater than
8904 A preprocessing directive of the form
8906 # line digit-sequence "s-char-sequenceopt" new-line</pre>
8907 sets the presumed line number similarly and changes the presumed name of the source
8908 file to be the contents of the character string literal.
8910 A preprocessing directive of the form
8912 # line pp-tokens new-line</pre>
8913 (that does not match one of the two previous forms) is permitted. The preprocessing
8914 tokens after line on the directive are processed just as in normal text (each identifier
8915 currently defined as a macro name is replaced by its replacement list of preprocessing
8916 tokens). The directive resulting after all replacements shall match one of the two
8917 previous forms and is then processed as appropriate.
8918 <!--page 191 indent 4-->
8920 <a name="6.10.5" href="#6.10.5"><h4>6.10.5 Error directive</h4></a>
8923 A preprocessing directive of the form
8925 # error pp-tokensopt new-line</pre>
8926 causes the implementation to produce a diagnostic message that includes the specified
8927 sequence of preprocessing tokens.
8929 <a name="6.10.6" href="#6.10.6"><h4>6.10.6 Pragma directive</h4></a>
8932 A preprocessing directive of the form
8934 # pragma pp-tokensopt new-line</pre>
8935 where the preprocessing token STDC does not immediately follow pragma in the
8936 directive (prior to any macro replacement)<sup><a href="#note174"><b>174)</b></a></sup> causes the implementation to behave in an
8937 implementation-defined manner. The behavior might cause translation to fail or cause the
8938 translator or the resulting program to behave in a non-conforming manner. Any such
8939 pragma that is not recognized by the implementation is ignored.
8941 If the preprocessing token STDC does immediately follow pragma in the directive (prior
8942 to any macro replacement), then no macro replacement is performed on the directive, and
8943 the directive shall have one of the following forms<sup><a href="#note175"><b>175)</b></a></sup> whose meanings are described
8946 #pragma STDC FP_CONTRACT on-off-switch
8947 #pragma STDC FENV_ACCESS on-off-switch
8948 #pragma STDC CX_LIMITED_RANGE on-off-switch
8949 on-off-switch: one of
8950 ON OFF DEFAULT</pre>
8951 Forward references: the FP_CONTRACT pragma (<a href="#7.12.2">7.12.2</a>), the FENV_ACCESS pragma
8952 (<a href="#7.6.1">7.6.1</a>), the CX_LIMITED_RANGE pragma (<a href="#7.3.4">7.3.4</a>).
8957 <!--page 192 indent 4-->
8960 <p><a name="note174">174)</a> An implementation is not required to perform macro replacement in pragmas, but it is permitted
8961 except for in standard pragmas (where STDC immediately follows pragma). If the result of macro
8962 replacement in a non-standard pragma has the same form as a standard pragma, the behavior is still
8963 implementation-defined; an implementation is permitted to behave as if it were the standard pragma,
8964 but is not required to.
8966 <p><a name="note175">175)</a> See ''future language directions'' (<a href="#6.11.8">6.11.8</a>).
8969 <a name="6.10.7" href="#6.10.7"><h4>6.10.7 Null directive</h4></a>
8972 A preprocessing directive of the form
8977 <a name="6.10.8" href="#6.10.8"><h4>6.10.8 Predefined macro names</h4></a>
8979 The values of the predefined macros listed in the following subclauses<sup><a href="#note176"><b>176)</b></a></sup> (except for
8980 __FILE__ and __LINE__) remain constant throughout the translation unit.
8982 None of these macro names, nor the identifier defined, shall be the subject of a
8983 #define or a #undef preprocessing directive. Any other predefined macro names
8984 shall begin with a leading underscore followed by an uppercase letter or a second
8987 The implementation shall not predefine the macro __cplusplus, nor shall it define it
8988 in any standard header.
8989 Forward references: standard headers (<a href="#7.1.2">7.1.2</a>).
8992 <p><a name="note176">176)</a> See ''future language directions'' (<a href="#6.11.9">6.11.9</a>).
8995 <a name="6.10.8.1" href="#6.10.8.1"><h5>6.10.8.1 Mandatory macros</h5></a>
8997 The following macro names shall be defined by the implementation:
8998 __DATE__ The date of translation of the preprocessing translation unit: a character
9000 string literal of the form "Mmm dd yyyy", where the names of the
9001 months are the same as those generated by the asctime function, and the
9002 first character of dd is a space character if the value is less than 10. If the
9003 date of translation is not available, an implementation-defined valid date
9004 shall be supplied.</pre>
9005 __FILE__ The presumed name of the current source file (a character string literal).<sup><a href="#note177"><b>177)</b></a></sup>
9006 __LINE__ The presumed line number (within the current source file) of the current
9008 source line (an integer constant).177)</pre>
9009 __STDC__ The integer constant 1, intended to indicate a conforming implementation.
9010 __STDC_HOSTED__ The integer constant 1 if the implementation is a hosted
9012 implementation or the integer constant 0 if it is not.</pre>
9017 <!--page 193 indent 4-->
9018 __STDC_VERSION__ The integer constant 201ymmL.<sup><a href="#note178"><b>178)</b></a></sup>
9019 __TIME__ The time of translation of the preprocessing translation unit: a character
9021 string literal of the form "hh:mm:ss" as in the time generated by the
9022 asctime function. If the time of translation is not available, an
9023 implementation-defined valid time shall be supplied.</pre>
9024 Forward references: the asctime function (<a href="#7.26.3.1">7.26.3.1</a>).
9027 <p><a name="note177">177)</a> The presumed source file name and line number can be changed by the #line directive.
9029 <p><a name="note178">178)</a> This macro was not specified in ISO/IEC 9899:1990 and was specified as 199409L in
9030 ISO/IEC 9899/AMD1:1995 and as 199901L in ISO/IEC 9899:1999. The intention is that this will
9031 remain an integer constant of type long int that is increased with each revision of this International
9035 <a name="6.10.8.2" href="#6.10.8.2"><h5>6.10.8.2 Environment macros</h5></a>
9037 The following macro names are conditionally defined by the implementation:
9038 __STDC_ISO_10646__ An integer constant of the form yyyymmL (for example,
9040 199712L). If this symbol is defined, then every character in the Unicode
9041 required set, when stored in an object of type wchar_t, has the same
9042 value as the short identifier of that character. The Unicode required set
9043 consists of all the characters that are defined by ISO/IEC 10646, along with
9044 all amendments and technical corrigenda, as of the specified year and
9045 month. If some other encoding is used, the macro shall not be defined and
9046 the actual encoding used is implementation-defined.</pre>
9047 __STDC_MB_MIGHT_NEQ_WC__ The integer constant 1, intended to indicate that, in
9049 the encoding for wchar_t, a member of the basic character set need not
9050 have a code value equal to its value when used as the lone character in an
9051 integer character constant.</pre>
9052 __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type
9054 char16_t are UTF-16 encoded. If some other encoding is used, the
9055 macro shall not be defined and the actual encoding used is implementation-
9057 __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type
9059 char32_t are UTF-32 encoded. If some other encoding is used, the
9060 macro shall not be defined and the actual encoding used is implementation-
9062 Forward references: common definitions (<a href="#7.19">7.19</a>), unicode utilities (<a href="#7.27">7.27</a>).
9067 <!--page 194 indent 4-->
9069 <a name="6.10.8.3" href="#6.10.8.3"><h5>6.10.8.3 Conditional feature macros</h5></a>
9071 The following macro names are conditionally defined by the implementation:
9072 __STDC_ANALYZABLE__ The integer constant 1, intended to indicate conformance to
9074 the specifications in <a href="#L">annex L</a> (Analyzability).</pre>
9075 __STDC_IEC_559__ The integer constant 1, intended to indicate conformance to the
9077 specifications in <a href="#F">annex F</a> (IEC 60559 floating-point arithmetic).</pre>
9078 __STDC_IEC_559_COMPLEX__ The integer constant 1, intended to indicate
9080 adherence to the specifications in <a href="#G">annex G</a> (IEC 60559 compatible complex
9082 __STDC_LIB_EXT1__ The integer constant 201ymmL, intended to indicate support
9084 for the extensions defined in <a href="#K">annex K</a> (Bounds-checking interfaces).<sup><a href="#note179"><b>179)</b></a></sup></pre>
9085 __STDC_NO_COMPLEX__ The integer constant 1, intended to indicate that the
9087 implementation does not support complex types or the <complex.h>
9089 __STDC_NO_THREADS__ The integer constant 1, intended to indicate that the
9091 implementation does not support atomic types (including the _Atomic
9092 type qualifier and the <stdatomic.h> header) or the <threads.h>
9094 __STDC_NO_VLA__ The integer constant 1, intended to indicate that the
9097 implementation does not support variable length arrays or variably
9098 modified types.</pre>
9099 An implementation that defines __STDC_NO_COMPLEX__ shall not define
9100 __STDC_IEC_559_COMPLEX__.
9103 <p><a name="note179">179)</a> The intention is that this will remain an integer constant of type long int that is increased with
9104 each revision of this International Standard.
9107 <a name="6.10.9" href="#6.10.9"><h4>6.10.9 Pragma operator</h4></a>
9110 A unary operator expression of the form:
9112 _Pragma ( string-literal )</pre>
9113 is processed as follows: The string literal is destringized by deleting the L prefix, if
9114 present, deleting the leading and trailing double-quotes, replacing each escape sequence
9115 \" by a double-quote, and replacing each escape sequence \\ by a single backslash. The
9116 resulting sequence of characters is processed through translation phase 3 to produce
9117 preprocessing tokens that are executed as if they were the pp-tokens in a pragma
9120 <!--page 195 indent 4-->
9121 directive. The original four preprocessing tokens in the unary operator expression are
9124 EXAMPLE A directive of the form:
9126 #pragma listing on "..\listing.dir"</pre>
9127 can also be expressed as:
9129 _Pragma ( "listing on \"..\\listing.dir\"" )</pre>
9130 The latter form is processed in the same way whether it appears literally as shown, or results from macro
9132 <!--page 196 indent 4-->
9134 #define LISTING(x) PRAGMA(listing on #x)
9135 #define PRAGMA(x) _Pragma(#x)
9136 LISTING ( ..\listing.dir )</pre>
9138 <a name="6.11" href="#6.11"><h3>6.11 Future language directions</h3></a>
9140 <a name="6.11.1" href="#6.11.1"><h4>6.11.1 Floating types</h4></a>
9142 Future standardization may include additional floating-point types, including those with
9143 greater range, precision, or both than long double.
9145 <a name="6.11.2" href="#6.11.2"><h4>6.11.2 Linkages of identifiers</h4></a>
9147 Declaring an identifier with internal linkage at file scope without the static storage-
9148 class specifier is an obsolescent feature.
9150 <a name="6.11.3" href="#6.11.3"><h4>6.11.3 External names</h4></a>
9152 Restriction of the significance of an external name to fewer than 255 characters
9153 (considering each universal character name or extended source character as a single
9154 character) is an obsolescent feature that is a concession to existing implementations.
9156 <a name="6.11.4" href="#6.11.4"><h4>6.11.4 Character escape sequences</h4></a>
9158 Lowercase letters as escape sequences are reserved for future standardization. Other
9159 characters may be used in extensions.
9161 <a name="6.11.5" href="#6.11.5"><h4>6.11.5 Storage-class specifiers</h4></a>
9163 The placement of a storage-class specifier other than at the beginning of the declaration
9164 specifiers in a declaration is an obsolescent feature.
9166 <a name="6.11.6" href="#6.11.6"><h4>6.11.6 Function declarators</h4></a>
9168 The use of function declarators with empty parentheses (not prototype-format parameter
9169 type declarators) is an obsolescent feature.
9171 <a name="6.11.7" href="#6.11.7"><h4>6.11.7 Function definitions</h4></a>
9173 The use of function definitions with separate parameter identifier and declaration lists
9174 (not prototype-format parameter type and identifier declarators) is an obsolescent feature.
9176 <a name="6.11.8" href="#6.11.8"><h4>6.11.8 Pragma directives</h4></a>
9178 Pragmas whose first preprocessing token is STDC are reserved for future standardization.
9180 <a name="6.11.9" href="#6.11.9"><h4>6.11.9 Predefined macro names</h4></a>
9182 Macro names beginning with __STDC_ are reserved for future standardization.
9183 <!--page 197 indent 4-->
9185 <a name="7" href="#7"><h2>7. Library</h2></a>
9187 <a name="7.1" href="#7.1"><h3>7.1 Introduction</h3></a>
9189 <a name="7.1.1" href="#7.1.1"><h4>7.1.1 Definitions of terms</h4></a>
9191 A string is a contiguous sequence of characters terminated by and including the first null
9192 character. The term multibyte string is sometimes used instead to emphasize special
9193 processing given to multibyte characters contained in the string or to avoid confusion
9194 with a wide string. A pointer to a string is a pointer to its initial (lowest addressed)
9195 character. The length of a string is the number of bytes preceding the null character and
9196 the value of a string is the sequence of the values of the contained characters, in order.
9198 The decimal-point character is the character used by functions that convert floating-point
9199 numbers to or from character sequences to denote the beginning of the fractional part of
9200 such character sequences.<sup><a href="#note180"><b>180)</b></a></sup> It is represented in the text and examples by a period, but
9201 may be changed by the setlocale function.
9203 A null wide character is a wide character with code value zero.
9205 A wide string is a contiguous sequence of wide characters terminated by and including
9206 the first null wide character. A pointer to a wide string is a pointer to its initial (lowest
9207 addressed) wide character. The length of a wide string is the number of wide characters
9208 preceding the null wide character and the value of a wide string is the sequence of code
9209 values of the contained wide characters, in order.
9211 A shift sequence is a contiguous sequence of bytes within a multibyte string that
9212 (potentially) causes a change in shift state (see <a href="#5.2.1.2">5.2.1.2</a>). A shift sequence shall not have a
9213 corresponding wide character; it is instead taken to be an adjunct to an adjacent multibyte
9214 character.<sup><a href="#note181"><b>181)</b></a></sup>
9215 Forward references: character handling (<a href="#7.4">7.4</a>), the setlocale function (<a href="#7.11.1.1">7.11.1.1</a>).
9220 <!--page 198 indent 4-->
9223 <p><a name="note180">180)</a> The functions that make use of the decimal-point character are the numeric conversion functions
9224 (<a href="#7.22.1">7.22.1</a>, <a href="#7.28.4.1">7.28.4.1</a>) and the formatted input/output functions (<a href="#7.21.6">7.21.6</a>, <a href="#7.28.2">7.28.2</a>).
9226 <p><a name="note181">181)</a> For state-dependent encodings, the values for MB_CUR_MAX and MB_LEN_MAX shall thus be large
9227 enough to count all the bytes in any complete multibyte character plus at least one adjacent shift
9228 sequence of maximum length. Whether these counts provide for more than one shift sequence is the
9229 implementation's choice.
9232 <a name="7.1.2" href="#7.1.2"><h4>7.1.2 Standard headers</h4></a>
9234 Each library function is declared, with a type that includes a prototype, in a header,<sup><a href="#note182"><b>182)</b></a></sup>
9235 whose contents are made available by the #include preprocessing directive. The
9236 header declares a set of related functions, plus any necessary types and additional macros
9237 needed to facilitate their use. Declarations of types described in this clause shall not
9238 include type qualifiers, unless explicitly stated otherwise.
9240 The standard headers are<sup><a href="#note183"><b>183)</b></a></sup>
9243 <assert.h> <iso646.h> <stdarg.h> <string.h>
9244 <complex.h> <limits.h> <stdatomic.h> <tgmath.h>
9245 <ctype.h> <locale.h> <stdbool.h> <threads.h>
9246 <errno.h> <math.h> <stddef.h> <time.h>
9247 <fenv.h> <setjmp.h> <stdint.h> <uchar.h>
9248 <float.h> <signal.h> <stdio.h> <wchar.h>
9249 <inttypes.h> <stdalign.h> <stdlib.h> <wctype.h></pre>
9250 If a file with the same name as one of the above < and > delimited sequences, not
9251 provided as part of the implementation, is placed in any of the standard places that are
9252 searched for included source files, the behavior is undefined.
9254 Standard headers may be included in any order; each may be included more than once in
9255 a given scope, with no effect different from being included only once, except that the
9256 effect of including <assert.h> depends on the definition of NDEBUG (see <a href="#7.2">7.2</a>). If
9257 used, a header shall be included outside of any external declaration or definition, and it
9258 shall first be included before the first reference to any of the functions or objects it
9259 declares, or to any of the types or macros it defines. However, if an identifier is declared
9260 or defined in more than one header, the second and subsequent associated headers may be
9261 included after the initial reference to the identifier. The program shall not have any
9262 macros with names lexically identical to keywords currently defined prior to the
9265 Any definition of an object-like macro described in this clause shall expand to code that is
9266 fully protected by parentheses where necessary, so that it groups in an arbitrary
9267 expression as if it were a single identifier.
9269 Any declaration of a library function shall have external linkage.
9274 <!--page 199 indent 4-->
9276 A summary of the contents of the standard headers is given in <a href="#B">annex B</a>.
9277 Forward references: diagnostics (<a href="#7.2">7.2</a>).
9280 <p><a name="note182">182)</a> A header is not necessarily a source file, nor are the < and > delimited sequences in header names
9281 necessarily valid source file names.
9283 <p><a name="note183">183)</a> The headers <complex.h>, <stdatomic.h>, and <threads.h> are conditional features that
9284 implementations need not support; see <a href="#6.10.8.3">6.10.8.3</a>.
9287 <a name="7.1.3" href="#7.1.3"><h4>7.1.3 Reserved identifiers</h4></a>
9289 Each header declares or defines all identifiers listed in its associated subclause, and
9290 optionally declares or defines identifiers listed in its associated future library directions
9291 subclause and identifiers which are always reserved either for any use or for use as file
9294 <li> All identifiers that begin with an underscore and either an uppercase letter or another
9295 underscore are always reserved for any use.
9296 <li> All identifiers that begin with an underscore are always reserved for use as identifiers
9297 with file scope in both the ordinary and tag name spaces.
9298 <li> Each macro name in any of the following subclauses (including the future library
9299 directions) is reserved for use as specified if any of its associated headers is included;
9300 unless explicitly stated otherwise (see <a href="#7.1.4">7.1.4</a>).
9301 <li> All identifiers with external linkage in any of the following subclauses (including the
9302 future library directions) and errno are always reserved for use as identifiers with
9303 external linkage.<sup><a href="#note184"><b>184)</b></a></sup>
9304 <li> Each identifier with file scope listed in any of the following subclauses (including the
9305 future library directions) is reserved for use as a macro name and as an identifier with
9306 file scope in the same name space if any of its associated headers is included.
9309 No other identifiers are reserved. If the program declares or defines an identifier in a
9310 context in which it is reserved (other than as allowed by <a href="#7.1.4">7.1.4</a>), or defines a reserved
9311 identifier as a macro name, the behavior is undefined.
9313 If the program removes (with #undef) any macro definition of an identifier in the first
9314 group listed above, the behavior is undefined.
9319 <!--page 200 indent 4-->
9322 <p><a name="note184">184)</a> The list of reserved identifiers with external linkage includes math_errhandling, setjmp,
9323 va_copy, and va_end.
9326 <a name="7.1.4" href="#7.1.4"><h4>7.1.4 Use of library functions</h4></a>
9328 Each of the following statements applies unless explicitly stated otherwise in the detailed
9329 descriptions that follow: If an argument to a function has an invalid value (such as a value
9330 outside the domain of the function, or a pointer outside the address space of the program,
9331 or a null pointer, or a pointer to non-modifiable storage when the corresponding
9332 parameter is not const-qualified) or a type (after promotion) not expected by a function
9333 with variable number of arguments, the behavior is undefined. If a function argument is
9334 described as being an array, the pointer actually passed to the function shall have a value
9335 such that all address computations and accesses to objects (that would be valid if the
9336 pointer did point to the first element of such an array) are in fact valid. Any function
9337 declared in a header may be additionally implemented as a function-like macro defined in
9338 the header, so if a library function is declared explicitly when its header is included, one
9339 of the techniques shown below can be used to ensure the declaration is not affected by
9340 such a macro. Any macro definition of a function can be suppressed locally by enclosing
9341 the name of the function in parentheses, because the name is then not followed by the left
9342 parenthesis that indicates expansion of a macro function name. For the same syntactic
9343 reason, it is permitted to take the address of a library function even if it is also defined as
9344 a macro.<sup><a href="#note185"><b>185)</b></a></sup> The use of #undef to remove any macro definition will also ensure that an
9345 actual function is referred to. Any invocation of a library function that is implemented as
9346 a macro shall expand to code that evaluates each of its arguments exactly once, fully
9347 protected by parentheses where necessary, so it is generally safe to use arbitrary
9348 expressions as arguments.<sup><a href="#note186"><b>186)</b></a></sup> Likewise, those function-like macros described in the
9349 following subclauses may be invoked in an expression anywhere a function with a
9350 compatible return type could be called.<sup><a href="#note187"><b>187)</b></a></sup> All object-like macros listed as expanding to
9353 <!--page 201 indent 4-->
9354 integer constant expressions shall additionally be suitable for use in #if preprocessing
9357 Provided that a library function can be declared without reference to any type defined in a
9358 header, it is also permissible to declare the function and use it without including its
9361 There is a sequence point immediately before a library function returns.
9363 The functions in the standard library are not guaranteed to be reentrant and may modify
9364 objects with static or thread storage duration.<sup><a href="#note188"><b>188)</b></a></sup>
9366 Unless explicitly stated otherwise in the detailed descriptions that follow, library
9367 functions shall prevent data races as follows: A library function shall not directly or
9368 indirectly access objects accessible by threads other than the current thread unless the
9369 objects are accessed directly or indirectly via the function's arguments. A library
9370 function shall not directly or indirectly modify objects accessible by threads other than
9371 the current thread unless the objects are accessed directly or indirectly via the function's
9372 non-const arguments.<sup><a href="#note189"><b>189)</b></a></sup> Implementations may share their own internal objects between
9373 threads if the objects are not visible to users and are protected against data races.
9375 Unless otherwise specified, library functions shall perform all operations solely within the
9376 current thread if those operations have effects that are visible to users.<sup><a href="#note190"><b>190)</b></a></sup>
9378 EXAMPLE The function atoi may be used in any of several ways:
9380 <li> by use of its associated header (possibly generating a macro expansion)
9382 #include <stdlib.h>
9385 i = atoi(str);</pre>
9386 <li> by use of its associated header (assuredly generating a true function reference)
9391 <!--page 202 indent 0-->
9393 #include <stdlib.h>
9397 i = atoi(str);</pre>
9400 #include <stdlib.h>
9403 i = (atoi)(str);</pre>
9404 <li> by explicit declaration
9405 <!--page 203 indent 4-->
9407 extern int atoi(const char *);
9410 i = atoi(str);</pre>
9414 <p><a name="note185">185)</a> This means that an implementation shall provide an actual function for each library function, even if it
9415 also provides a macro for that function.
9417 <p><a name="note186">186)</a> Such macros might not contain the sequence points that the corresponding function calls do.
9419 <p><a name="note187">187)</a> Because external identifiers and some macro names beginning with an underscore are reserved,
9420 implementations may provide special semantics for such names. For example, the identifier
9421 _BUILTIN_abs could be used to indicate generation of in-line code for the abs function. Thus, the
9422 appropriate header could specify
9425 #define abs(x) _BUILTIN_abs(x)</pre>
9426 for a compiler whose code generator will accept it.
9427 In this manner, a user desiring to guarantee that a given library function such as abs will be a genuine
9432 whether the implementation's header provides a macro implementation of abs or a built-in
9433 implementation. The prototype for the function, which precedes and is hidden by any macro
9434 definition, is thereby revealed also.
9436 <p><a name="note188">188)</a> Thus, a signal handler cannot, in general, call standard library functions.
9438 <p><a name="note189">189)</a> This means, for example, that an implementation is not permitted to use a static object for internal
9439 purposes without synchronization because it could cause a data race even in programs that do not
9440 explicitly share objects between threads.
9442 <p><a name="note190">190)</a> This allows implementations to parallelize operations if there are no visible side effects.
9445 <a name="7.2" href="#7.2"><h3>7.2 Diagnostics <assert.h></h3></a>
9447 The header <assert.h> defines the assert and static_assert macros and
9448 refers to another macro,
9451 which is not defined by <assert.h>. If NDEBUG is defined as a macro name at the
9452 point in the source file where <assert.h> is included, the assert macro is defined
9455 #define assert(ignore) ((void)0)</pre>
9456 The assert macro is redefined according to the current state of NDEBUG each time that
9457 <assert.h> is included.
9459 The assert macro shall be implemented as a macro, not as an actual function. If the
9460 macro definition is suppressed in order to access an actual function, the behavior is
9466 expands to _Static_assert.
9468 <a name="7.2.1" href="#7.2.1"><h4>7.2.1 Program diagnostics</h4></a>
9470 <a name="7.2.1.1" href="#7.2.1.1"><h5>7.2.1.1 The assert macro</h5></a>
9474 #include <assert.h>
9475 void assert(scalar expression);</pre>
9476 <h6>Description</h6>
9478 The assert macro puts diagnostic tests into programs; it expands to a void expression.
9479 When it is executed, if expression (which shall have a scalar type) is false (that is,
9480 compares equal to 0), the assert macro writes information about the particular call that
9481 failed (including the text of the argument, the name of the source file, the source line
9482 number, and the name of the enclosing function -- the latter are respectively the values of
9483 the preprocessing macros __FILE__ and __LINE__ and of the identifier
9484 __func__) on the standard error stream in an implementation-defined format.<sup><a href="#note191"><b>191)</b></a></sup> It
9485 then calls the abort function.
9489 <!--page 204 indent 4-->
9492 The assert macro returns no value.
9493 Forward references: the abort function (<a href="#7.22.4.1">7.22.4.1</a>).
9494 <!--page 205 indent 4-->
9497 <p><a name="note191">191)</a> The message written might be of the form:
9498 Assertion failed: expression, function abc, file xyz, line nnn.
9501 <a name="7.3" href="#7.3"><h3>7.3 Complex arithmetic <complex.h></h3></a>
9503 <a name="7.3.1" href="#7.3.1"><h4>7.3.1 Introduction</h4></a>
9505 The header <complex.h> defines macros and declares functions that support complex
9506 arithmetic.<sup><a href="#note192"><b>192)</b></a></sup>
9508 Implementations that define the macro __STDC_NO_COMPLEX__ need not provide
9509 this header nor support any of its facilities.
9511 Each synopsis specifies a family of functions consisting of a principal function with one
9512 or more double complex parameters and a double complex or double return
9513 value; and other functions with the same name but with f and l suffixes which are
9514 corresponding functions with float and long double parameters and return values.
9519 expands to _Complex; the macro
9522 expands to a constant expression of type const float _Complex, with the value of
9523 the imaginary unit.<sup><a href="#note193"><b>193)</b></a></sup>
9531 are defined if and only if the implementation supports imaginary types;<sup><a href="#note194"><b>194)</b></a></sup> if defined,
9532 they expand to _Imaginary and a constant expression of type const float
9533 _Imaginary with the value of the imaginary unit.
9538 expands to either _Imaginary_I or _Complex_I. If _Imaginary_I is not
9539 defined, I shall expand to _Complex_I.
9541 Notwithstanding the provisions of <a href="#7.1.3">7.1.3</a>, a program may undefine and perhaps then
9542 redefine the macros complex, imaginary, and I.
9544 <!--page 206 indent 4-->
9545 Forward references: IEC 60559-compatible complex arithmetic (<a href="#G">annex G</a>).
9548 <p><a name="note192">192)</a> See ''future library directions'' (<a href="#7.30.1">7.30.1</a>).
9550 <p><a name="note193">193)</a> The imaginary unit is a number i such that i 2 = -1.
9552 <p><a name="note194">194)</a> A specification for imaginary types is in informative <a href="#G">annex G</a>.
9555 <a name="7.3.2" href="#7.3.2"><h4>7.3.2 Conventions</h4></a>
9557 Values are interpreted as radians, not degrees. An implementation may set errno but is
9560 <a name="7.3.3" href="#7.3.3"><h4>7.3.3 Branch cuts</h4></a>
9562 Some of the functions below have branch cuts, across which the function is
9563 discontinuous. For implementations with a signed zero (including all IEC 60559
9564 implementations) that follow the specifications of <a href="#G">annex G</a>, the sign of zero distinguishes
9565 one side of a cut from another so the function is continuous (except for format
9566 limitations) as the cut is approached from either side. For example, for the square root
9567 function, which has a branch cut along the negative real axis, the top of the cut, with
9568 imaginary part +0, maps to the positive imaginary axis, and the bottom of the cut, with
9569 imaginary part -0, maps to the negative imaginary axis.
9571 Implementations that do not support a signed zero (see <a href="#F">annex F</a>) cannot distinguish the
9572 sides of branch cuts. These implementations shall map a cut so the function is continuous
9573 as the cut is approached coming around the finite endpoint of the cut in a counter
9574 clockwise direction. (Branch cuts for the functions specified here have just one finite
9575 endpoint.) For example, for the square root function, coming counter clockwise around
9576 the finite endpoint of the cut along the negative real axis approaches the cut from above,
9577 so the cut maps to the positive imaginary axis.
9579 <a name="7.3.4" href="#7.3.4"><h4>7.3.4 The CX_LIMITED_RANGE pragma</h4></a>
9583 #include <complex.h>
9584 #pragma STDC CX_LIMITED_RANGE on-off-switch</pre>
9585 <h6>Description</h6>
9587 The usual mathematical formulas for complex multiply, divide, and absolute value are
9588 problematic because of their treatment of infinities and because of undue overflow and
9589 underflow. The CX_LIMITED_RANGE pragma can be used to inform the
9590 implementation that (where the state is ''on'') the usual mathematical formulas are
9591 acceptable.<sup><a href="#note195"><b>195)</b></a></sup> The pragma can occur either outside external declarations or preceding all
9592 explicit declarations and statements inside a compound statement. When outside external
9593 declarations, the pragma takes effect from its occurrence until another
9594 CX_LIMITED_RANGE pragma is encountered, or until the end of the translation unit.
9595 When inside a compound statement, the pragma takes effect from its occurrence until
9596 another CX_LIMITED_RANGE pragma is encountered (including within a nested
9597 compound statement), or until the end of the compound statement; at the end of a
9598 compound statement the state for the pragma is restored to its condition just before the
9599 <!--page 207 indent 4-->
9600 compound statement. If this pragma is used in any other context, the behavior is
9601 undefined. The default state for the pragma is ''off''.
9604 <p><a name="note195">195)</a> The purpose of the pragma is to allow the implementation to use the formulas:
9607 (x + iy) x (u + iv) = (xu - yv) + i(yu + xv)
9608 (x + iy) / (u + iv) = [(xu + yv) + i(yu - xv)]/(u2 + v 2 )
9609 | x + iy | = (sqrt) x 2 + y 2
9611 where the programmer can determine they are safe.
9614 <a name="7.3.5" href="#7.3.5"><h4>7.3.5 Trigonometric functions</h4></a>
9616 <a name="7.3.5.1" href="#7.3.5.1"><h5>7.3.5.1 The cacos functions</h5></a>
9620 #include <complex.h>
9621 double complex cacos(double complex z);
9622 float complex cacosf(float complex z);
9623 long double complex cacosl(long double complex z);</pre>
9624 <h6>Description</h6>
9626 The cacos functions compute the complex arc cosine of z, with branch cuts outside the
9627 interval [-1, +1] along the real axis.
9630 The cacos functions return the complex arc cosine value, in the range of a strip
9631 mathematically unbounded along the imaginary axis and in the interval [0, pi ] along the
9634 <a name="7.3.5.2" href="#7.3.5.2"><h5>7.3.5.2 The casin functions</h5></a>
9638 #include <complex.h>
9639 double complex casin(double complex z);
9640 float complex casinf(float complex z);
9641 long double complex casinl(long double complex z);</pre>
9642 <h6>Description</h6>
9644 The casin functions compute the complex arc sine of z, with branch cuts outside the
9645 interval [-1, +1] along the real axis.
9648 The casin functions return the complex arc sine value, in the range of a strip
9649 mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
9651 <!--page 208 indent 4-->
9652 along the real axis.
9654 <a name="7.3.5.3" href="#7.3.5.3"><h5>7.3.5.3 The catan functions</h5></a>
9658 #include <complex.h>
9659 double complex catan(double complex z);
9660 float complex catanf(float complex z);
9661 long double complex catanl(long double complex z);</pre>
9662 <h6>Description</h6>
9664 The catan functions compute the complex arc tangent of z, with branch cuts outside the
9665 interval [-i, +i] along the imaginary axis.
9668 The catan functions return the complex arc tangent value, in the range of a strip
9669 mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
9670 along the real axis.
9672 <a name="7.3.5.4" href="#7.3.5.4"><h5>7.3.5.4 The ccos functions</h5></a>
9676 #include <complex.h>
9677 double complex ccos(double complex z);
9678 float complex ccosf(float complex z);
9679 long double complex ccosl(long double complex z);</pre>
9680 <h6>Description</h6>
9682 The ccos functions compute the complex cosine of z.
9685 The ccos functions return the complex cosine value.
9687 <a name="7.3.5.5" href="#7.3.5.5"><h5>7.3.5.5 The csin functions</h5></a>
9691 #include <complex.h>
9692 double complex csin(double complex z);
9693 float complex csinf(float complex z);
9694 long double complex csinl(long double complex z);</pre>
9695 <h6>Description</h6>
9697 The csin functions compute the complex sine of z.
9698 <!--page 209 indent 4-->
9701 The csin functions return the complex sine value.
9703 <a name="7.3.5.6" href="#7.3.5.6"><h5>7.3.5.6 The ctan functions</h5></a>
9707 #include <complex.h>
9708 double complex ctan(double complex z);
9709 float complex ctanf(float complex z);
9710 long double complex ctanl(long double complex z);</pre>
9711 <h6>Description</h6>
9713 The ctan functions compute the complex tangent of z.
9716 The ctan functions return the complex tangent value.
9718 <a name="7.3.6" href="#7.3.6"><h4>7.3.6 Hyperbolic functions</h4></a>
9720 <a name="7.3.6.1" href="#7.3.6.1"><h5>7.3.6.1 The cacosh functions</h5></a>
9724 #include <complex.h>
9725 double complex cacosh(double complex z);
9726 float complex cacoshf(float complex z);
9727 long double complex cacoshl(long double complex z);</pre>
9728 <h6>Description</h6>
9730 The cacosh functions compute the complex arc hyperbolic cosine of z, with a branch
9731 cut at values less than 1 along the real axis.
9734 The cacosh functions return the complex arc hyperbolic cosine value, in the range of a
9735 half-strip of nonnegative values along the real axis and in the interval [-ipi , +ipi ] along the
9738 <a name="7.3.6.2" href="#7.3.6.2"><h5>7.3.6.2 The casinh functions</h5></a>
9741 <!--page 210 indent 4-->
9743 #include <complex.h>
9744 double complex casinh(double complex z);
9745 float complex casinhf(float complex z);
9746 long double complex casinhl(long double complex z);</pre>
9747 <h6>Description</h6>
9749 The casinh functions compute the complex arc hyperbolic sine of z, with branch cuts
9750 outside the interval [-i, +i] along the imaginary axis.
9753 The casinh functions return the complex arc hyperbolic sine value, in the range of a
9754 strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
9755 along the imaginary axis.
9757 <a name="7.3.6.3" href="#7.3.6.3"><h5>7.3.6.3 The catanh functions</h5></a>
9761 #include <complex.h>
9762 double complex catanh(double complex z);
9763 float complex catanhf(float complex z);
9764 long double complex catanhl(long double complex z);</pre>
9765 <h6>Description</h6>
9767 The catanh functions compute the complex arc hyperbolic tangent of z, with branch
9768 cuts outside the interval [-1, +1] along the real axis.
9771 The catanh functions return the complex arc hyperbolic tangent value, in the range of a
9772 strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
9773 along the imaginary axis.
9775 <a name="7.3.6.4" href="#7.3.6.4"><h5>7.3.6.4 The ccosh functions</h5></a>
9779 #include <complex.h>
9780 double complex ccosh(double complex z);
9781 float complex ccoshf(float complex z);
9782 long double complex ccoshl(long double complex z);</pre>
9783 <h6>Description</h6>
9785 The ccosh functions compute the complex hyperbolic cosine of z.
9788 The ccosh functions return the complex hyperbolic cosine value.
9789 <!--page 211 indent 4-->
9791 <a name="7.3.6.5" href="#7.3.6.5"><h5>7.3.6.5 The csinh functions</h5></a>
9795 #include <complex.h>
9796 double complex csinh(double complex z);
9797 float complex csinhf(float complex z);
9798 long double complex csinhl(long double complex z);</pre>
9799 <h6>Description</h6>
9801 The csinh functions compute the complex hyperbolic sine of z.
9804 The csinh functions return the complex hyperbolic sine value.
9806 <a name="7.3.6.6" href="#7.3.6.6"><h5>7.3.6.6 The ctanh functions</h5></a>
9810 #include <complex.h>
9811 double complex ctanh(double complex z);
9812 float complex ctanhf(float complex z);
9813 long double complex ctanhl(long double complex z);</pre>
9814 <h6>Description</h6>
9816 The ctanh functions compute the complex hyperbolic tangent of z.
9819 The ctanh functions return the complex hyperbolic tangent value.
9821 <a name="7.3.7" href="#7.3.7"><h4>7.3.7 Exponential and logarithmic functions</h4></a>
9823 <a name="7.3.7.1" href="#7.3.7.1"><h5>7.3.7.1 The cexp functions</h5></a>
9827 #include <complex.h>
9828 double complex cexp(double complex z);
9829 float complex cexpf(float complex z);
9830 long double complex cexpl(long double complex z);</pre>
9831 <h6>Description</h6>
9833 The cexp functions compute the complex base-e exponential of z.
9836 The cexp functions return the complex base-e exponential value.
9837 <!--page 212 indent 4-->
9839 <a name="7.3.7.2" href="#7.3.7.2"><h5>7.3.7.2 The clog functions</h5></a>
9843 #include <complex.h>
9844 double complex clog(double complex z);
9845 float complex clogf(float complex z);
9846 long double complex clogl(long double complex z);</pre>
9847 <h6>Description</h6>
9849 The clog functions compute the complex natural (base-e) logarithm of z, with a branch
9850 cut along the negative real axis.
9853 The clog functions return the complex natural logarithm value, in the range of a strip
9854 mathematically unbounded along the real axis and in the interval [-ipi , +ipi ] along the
9857 <a name="7.3.8" href="#7.3.8"><h4>7.3.8 Power and absolute-value functions</h4></a>
9859 <a name="7.3.8.1" href="#7.3.8.1"><h5>7.3.8.1 The cabs functions</h5></a>
9863 #include <complex.h>
9864 double cabs(double complex z);
9865 float cabsf(float complex z);
9866 long double cabsl(long double complex z);</pre>
9867 <h6>Description</h6>
9869 The cabs functions compute the complex absolute value (also called norm, modulus, or
9873 The cabs functions return the complex absolute value.
9875 <a name="7.3.8.2" href="#7.3.8.2"><h5>7.3.8.2 The cpow functions</h5></a>
9878 <!--page 213 indent 4-->
9880 #include <complex.h>
9881 double complex cpow(double complex x, double complex y);
9882 float complex cpowf(float complex x, float complex y);
9883 long double complex cpowl(long double complex x,
9884 long double complex y);</pre>
9885 <h6>Description</h6>
9887 The cpow functions compute the complex power function xy , with a branch cut for the
9888 first parameter along the negative real axis.
9891 The cpow functions return the complex power function value.
9893 <a name="7.3.8.3" href="#7.3.8.3"><h5>7.3.8.3 The csqrt functions</h5></a>
9897 #include <complex.h>
9898 double complex csqrt(double complex z);
9899 float complex csqrtf(float complex z);
9900 long double complex csqrtl(long double complex z);</pre>
9901 <h6>Description</h6>
9903 The csqrt functions compute the complex square root of z, with a branch cut along the
9907 The csqrt functions return the complex square root value, in the range of the right half-
9908 plane (including the imaginary axis).
9910 <a name="7.3.9" href="#7.3.9"><h4>7.3.9 Manipulation functions</h4></a>
9912 <a name="7.3.9.1" href="#7.3.9.1"><h5>7.3.9.1 The carg functions</h5></a>
9916 #include <complex.h>
9917 double carg(double complex z);
9918 float cargf(float complex z);
9919 long double cargl(long double complex z);</pre>
9920 <h6>Description</h6>
9922 The carg functions compute the argument (also called phase angle) of z, with a branch
9923 cut along the negative real axis.
9926 The carg functions return the value of the argument in the interval [-pi , +pi ].
9927 <!--page 214 indent 4-->
9929 <a name="7.3.9.2" href="#7.3.9.2"><h5>7.3.9.2 The cimag functions</h5></a>
9933 #include <complex.h>
9934 double cimag(double complex z);
9935 float cimagf(float complex z);
9936 long double cimagl(long double complex z);</pre>
9937 <h6>Description</h6>
9939 The cimag functions compute the imaginary part of z.<sup><a href="#note196"><b>196)</b></a></sup>
9942 The cimag functions return the imaginary part value (as a real).
9945 <p><a name="note196">196)</a> For a variable z of complex type, z == creal(z) + cimag(z)*I.
9948 <a name="7.3.9.3" href="#7.3.9.3"><h5>7.3.9.3 The CMPLX macros</h5></a>
9952 #include <complex.h>
9953 double complex CMPLX(double x, double y);
9954 float complex CMPLXF(float x, float y);
9955 long double complex CMPLXL(long double x, long double y);</pre>
9956 <h6>Description</h6>
9958 The CMPLX macros expand to an expression of the specified complex type, with the real
9959 part having the (converted) value of x and the imaginary part having the (converted)
9961 Recommended practice
9963 The resulting expression should be suitable for use as an initializer for an object with
9964 static or thread storage duration, provided both arguments are likewise suitable.
9967 The CMPLX macros return the complex value x + i y.
9969 NOTE These macros act as if the implementation supported imaginary types and the definitions were:
9971 #define CMPLX(x, y) ((double complex)((double)(x) + \
9972 _Imaginary_I * (double)(y)))
9973 #define CMPLXF(x, y) ((float complex)((float)(x) + \
9974 _Imaginary_I * (float)(y)))
9975 #define CMPLXL(x, y) ((long double complex)((long double)(x) + \
9976 _Imaginary_I * (long double)(y)))</pre>
9981 <!--page 215 indent 4-->
9983 <a name="7.3.9.4" href="#7.3.9.4"><h5>7.3.9.4 The conj functions</h5></a>
9987 #include <complex.h>
9988 double complex conj(double complex z);
9989 float complex conjf(float complex z);
9990 long double complex conjl(long double complex z);</pre>
9991 <h6>Description</h6>
9993 The conj functions compute the complex conjugate of z, by reversing the sign of its
9997 The conj functions return the complex conjugate value.
9999 <a name="7.3.9.5" href="#7.3.9.5"><h5>7.3.9.5 The cproj functions</h5></a>
10003 #include <complex.h>
10004 double complex cproj(double complex z);
10005 float complex cprojf(float complex z);
10006 long double complex cprojl(long double complex z);</pre>
10007 <h6>Description</h6>
10009 The cproj functions compute a projection of z onto the Riemann sphere: z projects to
10010 z except that all complex infinities (even those with one infinite part and one NaN part)
10011 project to positive infinity on the real axis. If z has an infinite part, then cproj(z) is
10014 INFINITY + I * copysign(0.0, cimag(z))</pre>
10017 The cproj functions return the value of the projection onto the Riemann sphere.
10019 <a name="7.3.9.6" href="#7.3.9.6"><h5>7.3.9.6 The creal functions</h5></a>
10023 #include <complex.h>
10024 double creal(double complex z);
10025 float crealf(float complex z);
10026 long double creall(long double complex z);</pre>
10027 <h6>Description</h6>
10029 The creal functions compute the real part of z.<sup><a href="#note197"><b>197)</b></a></sup>
10030 <!--page 216 indent 4-->
10033 The creal functions return the real part value.
10038 <!--page 217 indent 4-->
10041 <p><a name="note197">197)</a> For a variable z of complex type, z == creal(z) + cimag(z)*I.
10044 <a name="7.4" href="#7.4"><h3>7.4 Character handling <ctype.h></h3></a>
10046 The header <ctype.h> declares several functions useful for classifying and mapping
10047 characters.<sup><a href="#note198"><b>198)</b></a></sup> In all cases the argument is an int, the value of which shall be
10048 representable as an unsigned char or shall equal the value of the macro EOF. If the
10049 argument has any other value, the behavior is undefined.
10051 The behavior of these functions is affected by the current locale. Those functions that
10052 have locale-specific aspects only when not in the "C" locale are noted below.
10054 The term printing character refers to a member of a locale-specific set of characters, each
10055 of which occupies one printing position on a display device; the term control character
10056 refers to a member of a locale-specific set of characters that are not printing
10057 characters.<sup><a href="#note199"><b>199)</b></a></sup> All letters and digits are printing characters.
10058 Forward references: EOF (<a href="#7.21.1">7.21.1</a>), localization (<a href="#7.11">7.11</a>).
10061 <p><a name="note198">198)</a> See ''future library directions'' (<a href="#7.30.2">7.30.2</a>).
10063 <p><a name="note199">199)</a> In an implementation that uses the seven-bit US ASCII character set, the printing characters are those
10064 whose values lie from 0x20 (space) through 0x7E (tilde); the control characters are those whose
10065 values lie from 0 (NUL) through 0x1F (US), and the character 0x7F (DEL).
10068 <a name="7.4.1" href="#7.4.1"><h4>7.4.1 Character classification functions</h4></a>
10070 The functions in this subclause return nonzero (true) if and only if the value of the
10071 argument c conforms to that in the description of the function.
10073 <a name="7.4.1.1" href="#7.4.1.1"><h5>7.4.1.1 The isalnum function</h5></a>
10077 #include <ctype.h>
10078 int isalnum(int c);</pre>
10079 <h6>Description</h6>
10081 The isalnum function tests for any character for which isalpha or isdigit is true.
10083 <a name="7.4.1.2" href="#7.4.1.2"><h5>7.4.1.2 The isalpha function</h5></a>
10087 #include <ctype.h>
10088 int isalpha(int c);</pre>
10089 <h6>Description</h6>
10091 The isalpha function tests for any character for which isupper or islower is true,
10092 or any character that is one of a locale-specific set of alphabetic characters for which
10096 <!--page 218 indent 4-->
10097 none of iscntrl, isdigit, ispunct, or isspace is true.<sup><a href="#note200"><b>200)</b></a></sup> In the "C" locale,
10098 isalpha returns true only for the characters for which isupper or islower is true.
10101 <p><a name="note200">200)</a> The functions islower and isupper test true or false separately for each of these additional
10102 characters; all four combinations are possible.
10105 <a name="7.4.1.3" href="#7.4.1.3"><h5>7.4.1.3 The isblank function</h5></a>
10109 #include <ctype.h>
10110 int isblank(int c);</pre>
10111 <h6>Description</h6>
10113 The isblank function tests for any character that is a standard blank character or is one
10114 of a locale-specific set of characters for which isspace is true and that is used to
10115 separate words within a line of text. The standard blank characters are the following:
10116 space (' '), and horizontal tab ('\t'). In the "C" locale, isblank returns true only
10117 for the standard blank characters.
10119 <a name="7.4.1.4" href="#7.4.1.4"><h5>7.4.1.4 The iscntrl function</h5></a>
10123 #include <ctype.h>
10124 int iscntrl(int c);</pre>
10125 <h6>Description</h6>
10127 The iscntrl function tests for any control character.
10129 <a name="7.4.1.5" href="#7.4.1.5"><h5>7.4.1.5 The isdigit function</h5></a>
10133 #include <ctype.h>
10134 int isdigit(int c);</pre>
10135 <h6>Description</h6>
10137 The isdigit function tests for any decimal-digit character (as defined in <a href="#5.2.1">5.2.1</a>).
10139 <a name="7.4.1.6" href="#7.4.1.6"><h5>7.4.1.6 The isgraph function</h5></a>
10143 #include <ctype.h>
10144 int isgraph(int c);</pre>
10149 <!--page 219 indent 4-->
10150 <h6>Description</h6>
10152 The isgraph function tests for any printing character except space (' ').
10154 <a name="7.4.1.7" href="#7.4.1.7"><h5>7.4.1.7 The islower function</h5></a>
10158 #include <ctype.h>
10159 int islower(int c);</pre>
10160 <h6>Description</h6>
10162 The islower function tests for any character that is a lowercase letter or is one of a
10163 locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
10164 isspace is true. In the "C" locale, islower returns true only for the lowercase
10165 letters (as defined in <a href="#5.2.1">5.2.1</a>).
10167 <a name="7.4.1.8" href="#7.4.1.8"><h5>7.4.1.8 The isprint function</h5></a>
10171 #include <ctype.h>
10172 int isprint(int c);</pre>
10173 <h6>Description</h6>
10175 The isprint function tests for any printing character including space (' ').
10177 <a name="7.4.1.9" href="#7.4.1.9"><h5>7.4.1.9 The ispunct function</h5></a>
10181 #include <ctype.h>
10182 int ispunct(int c);</pre>
10183 <h6>Description</h6>
10185 The ispunct function tests for any printing character that is one of a locale-specific set
10186 of punctuation characters for which neither isspace nor isalnum is true. In the "C"
10187 locale, ispunct returns true for every printing character for which neither isspace
10188 nor isalnum is true.
10190 <a name="7.4.1.10" href="#7.4.1.10"><h5>7.4.1.10 The isspace function</h5></a>
10194 #include <ctype.h>
10195 int isspace(int c);</pre>
10196 <h6>Description</h6>
10198 The isspace function tests for any character that is a standard white-space character or
10199 is one of a locale-specific set of characters for which isalnum is false. The standard
10200 <!--page 220 indent 4-->
10201 white-space characters are the following: space (' '), form feed ('\f'), new-line
10202 ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). In the
10203 "C" locale, isspace returns true only for the standard white-space characters.
10205 <a name="7.4.1.11" href="#7.4.1.11"><h5>7.4.1.11 The isupper function</h5></a>
10209 #include <ctype.h>
10210 int isupper(int c);</pre>
10211 <h6>Description</h6>
10213 The isupper function tests for any character that is an uppercase letter or is one of a
10214 locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
10215 isspace is true. In the "C" locale, isupper returns true only for the uppercase
10216 letters (as defined in <a href="#5.2.1">5.2.1</a>).
10218 <a name="7.4.1.12" href="#7.4.1.12"><h5>7.4.1.12 The isxdigit function</h5></a>
10222 #include <ctype.h>
10223 int isxdigit(int c);</pre>
10224 <h6>Description</h6>
10226 The isxdigit function tests for any hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
10228 <a name="7.4.2" href="#7.4.2"><h4>7.4.2 Character case mapping functions</h4></a>
10230 <a name="7.4.2.1" href="#7.4.2.1"><h5>7.4.2.1 The tolower function</h5></a>
10234 #include <ctype.h>
10235 int tolower(int c);</pre>
10236 <h6>Description</h6>
10238 The tolower function converts an uppercase letter to a corresponding lowercase letter.
10241 If the argument is a character for which isupper is true and there are one or more
10242 corresponding characters, as specified by the current locale, for which islower is true,
10243 the tolower function returns one of the corresponding characters (always the same one
10244 for any given locale); otherwise, the argument is returned unchanged.
10245 <!--page 221 indent 4-->
10247 <a name="7.4.2.2" href="#7.4.2.2"><h5>7.4.2.2 The toupper function</h5></a>
10251 #include <ctype.h>
10252 int toupper(int c);</pre>
10253 <h6>Description</h6>
10255 The toupper function converts a lowercase letter to a corresponding uppercase letter.
10258 If the argument is a character for which islower is true and there are one or more
10259 corresponding characters, as specified by the current locale, for which isupper is true,
10260 the toupper function returns one of the corresponding characters (always the same one
10261 for any given locale); otherwise, the argument is returned unchanged.
10262 <!--page 222 indent 4-->
10264 <a name="7.5" href="#7.5"><h3>7.5 Errors <errno.h></h3></a>
10266 The header <errno.h> defines several macros, all relating to the reporting of error
10274 which expand to integer constant expressions with type int, distinct positive values, and
10275 which are suitable for use in #if preprocessing directives; and
10278 which expands to a modifiable lvalue<sup><a href="#note201"><b>201)</b></a></sup> that has type int and thread local storage
10279 duration, the value of which is set to a positive error number by several library functions.
10280 If a macro definition is suppressed in order to access an actual object, or a program
10281 defines an identifier with the name errno, the behavior is undefined.
10283 The value of errno in the initial thread is zero at program startup (the initial value of
10284 errno in other threads is an indeterminate value), but is never set to zero by any library
10285 function.<sup><a href="#note202"><b>202)</b></a></sup> The value of errno may be set to nonzero by a library function call
10286 whether or not there is an error, provided the use of errno is not documented in the
10287 description of the function in this International Standard.
10289 Additional macro definitions, beginning with E and a digit or E and an uppercase
10290 letter,<sup><a href="#note203"><b>203)</b></a></sup> may also be specified by the implementation.
10295 <!--page 223 indent 4-->
10298 <p><a name="note201">201)</a> The macro errno need not be the identifier of an object. It might expand to a modifiable lvalue
10299 resulting from a function call (for example, *errno()).
10301 <p><a name="note202">202)</a> Thus, a program that uses errno for error checking should set it to zero before a library function call,
10302 then inspect it before a subsequent library function call. Of course, a library function can save the
10303 value of errno on entry and then set it to zero, as long as the original value is restored if errno's
10304 value is still zero just before the return.
10306 <p><a name="note203">203)</a> See ''future library directions'' (<a href="#7.30.3">7.30.3</a>).
10309 <a name="7.6" href="#7.6"><h3>7.6 Floating-point environment <fenv.h></h3></a>
10311 The header <fenv.h> defines several macros, and declares types and functions that
10312 provide access to the floating-point environment. The floating-point environment refers
10313 collectively to any floating-point status flags and control modes supported by the
10314 implementation.<sup><a href="#note204"><b>204)</b></a></sup> A floating-point status flag is a system variable whose value is set
10315 (but never cleared) when a floating-point exception is raised, which occurs as a side effect
10316 of exceptional floating-point arithmetic to provide auxiliary information.<sup><a href="#note205"><b>205)</b></a></sup> A floating-
10317 point control mode is a system variable whose value may be set by the user to affect the
10318 subsequent behavior of floating-point arithmetic.
10320 The floating-point environment has thread storage duration. The initial state for a
10321 thread's floating-point environment is the current state of the floating-point environment
10322 of the thread that creates it at the time of creation.
10324 Certain programming conventions support the intended model of use for the floating-
10325 point environment:<sup><a href="#note206"><b>206)</b></a></sup>
10327 <li> a function call does not alter its caller's floating-point control modes, clear its caller's
10328 floating-point status flags, nor depend on the state of its caller's floating-point status
10329 flags unless the function is so documented;
10330 <li> a function call is assumed to require default floating-point control modes, unless its
10331 documentation promises otherwise;
10332 <li> a function call is assumed to have the potential for raising floating-point exceptions,
10333 unless its documentation promises otherwise.
10339 represents the entire floating-point environment.
10344 represents the floating-point status flags collectively, including any status the
10345 implementation associates with the flags.
10348 <!--page 224 indent 4-->
10357 is defined if and only if the implementation supports the floating-point exception by
10358 means of the functions in 7.6.2.<sup><a href="#note207"><b>207)</b></a></sup> Additional implementation-defined floating-point
10359 exceptions, with macro definitions beginning with FE_ and an uppercase letter, may also
10360 be specified by the implementation. The defined macros expand to integer constant
10361 expressions with values such that bitwise ORs of all combinations of the macros result in
10362 distinct values, and furthermore, bitwise ANDs of all combinations of the macros result in
10363 zero.<sup><a href="#note208"><b>208)</b></a></sup>
10367 FE_ALL_EXCEPT</pre>
10368 is simply the bitwise OR of all floating-point exception macros defined by the
10369 implementation. If no such macros are defined, FE_ALL_EXCEPT shall be defined as 0.
10377 is defined if and only if the implementation supports getting and setting the represented
10378 rounding direction by means of the fegetround and fesetround functions.
10379 Additional implementation-defined rounding directions, with macro definitions beginning
10380 with FE_ and an uppercase letter, may also be specified by the implementation. The
10381 defined macros expand to integer constant expressions whose values are distinct
10382 nonnegative values.<sup><a href="#note209"><b>209)</b></a></sup>
10388 <!--page 225 indent 5-->
10391 represents the default floating-point environment -- the one installed at program startup
10393 <li> and has type ''pointer to const-qualified fenv_t''. It can be used as an argument to
10395 <fenv.h> functions that manage the floating-point environment.
10397 Additional implementation-defined environments, with macro definitions beginning with
10398 FE_ and an uppercase letter, and having type ''pointer to const-qualified fenv_t'', may
10399 also be specified by the implementation.
10402 <p><a name="note204">204)</a> This header is designed to support the floating-point exception status flags and directed-rounding
10403 control modes required by IEC 60559, and other similar floating-point state information. It is also
10404 designed to facilitate code portability among all systems.
10406 <p><a name="note205">205)</a> A floating-point status flag is not an object and can be set more than once within an expression.
10408 <p><a name="note206">206)</a> With these conventions, a programmer can safely assume default floating-point control modes (or be
10409 unaware of them). The responsibilities associated with accessing the floating-point environment fall
10410 on the programmer or program that does so explicitly.
10412 <p><a name="note207">207)</a> The implementation supports a floating-point exception if there are circumstances where a call to at
10413 least one of the functions in <a href="#7.6.2">7.6.2</a>, using the macro as the appropriate argument, will succeed. It is not
10414 necessary for all the functions to succeed all the time.
10416 <p><a name="note208">208)</a> The macros should be distinct powers of two.
10418 <p><a name="note209">209)</a> Even though the rounding direction macros may expand to constants corresponding to the values of
10419 FLT_ROUNDS, they are not required to do so.
10422 <a name="7.6.1" href="#7.6.1"><h4>7.6.1 The FENV_ACCESS pragma</h4></a>
10426 #include <fenv.h>
10427 #pragma STDC FENV_ACCESS on-off-switch</pre>
10428 <h6>Description</h6>
10430 The FENV_ACCESS pragma provides a means to inform the implementation when a
10431 program might access the floating-point environment to test floating-point status flags or
10432 run under non-default floating-point control modes.<sup><a href="#note210"><b>210)</b></a></sup> The pragma shall occur either
10433 outside external declarations or preceding all explicit declarations and statements inside a
10434 compound statement. When outside external declarations, the pragma takes effect from
10435 its occurrence until another FENV_ACCESS pragma is encountered, or until the end of
10436 the translation unit. When inside a compound statement, the pragma takes effect from its
10437 occurrence until another FENV_ACCESS pragma is encountered (including within a
10438 nested compound statement), or until the end of the compound statement; at the end of a
10439 compound statement the state for the pragma is restored to its condition just before the
10440 compound statement. If this pragma is used in any other context, the behavior is
10441 undefined. If part of a program tests floating-point status flags, sets floating-point control
10442 modes, or runs under non-default mode settings, but was translated with the state for the
10443 FENV_ACCESS pragma ''off'', the behavior is undefined. The default state (''on'' or
10444 ''off'') for the pragma is implementation-defined. (When execution passes from a part of
10445 the program translated with FENV_ACCESS ''off'' to a part translated with
10446 FENV_ACCESS ''on'', the state of the floating-point status flags is unspecified and the
10447 floating-point control modes have their default settings.)
10452 <!--page 226 indent 4-->
10457 #include <fenv.h>
10460 #pragma STDC FENV_ACCESS ON
10468 If the function g might depend on status flags set as a side effect of the first x + 1, or if the second
10469 x + 1 might depend on control modes set as a side effect of the call to function g, then the program shall
10470 contain an appropriately placed invocation of #pragma STDC FENV_ACCESS ON.<sup><a href="#note211"><b>211)</b></a></sup>
10474 <p><a name="note210">210)</a> The purpose of the FENV_ACCESS pragma is to allow certain optimizations that could subvert flag
10475 tests and mode changes (e.g., global common subexpression elimination, code motion, and constant
10476 folding). In general, if the state of FENV_ACCESS is ''off'', the translator can assume that default
10477 modes are in effect and the flags are not tested.
10479 <p><a name="note211">211)</a> The side effects impose a temporal ordering that requires two evaluations of x + 1. On the other
10480 hand, without the #pragma STDC FENV_ACCESS ON pragma, and assuming the default state is
10481 ''off'', just one evaluation of x + 1 would suffice.
10484 <a name="7.6.2" href="#7.6.2"><h4>7.6.2 Floating-point exceptions</h4></a>
10486 The following functions provide access to the floating-point status flags.<sup><a href="#note212"><b>212)</b></a></sup> The int
10487 input argument for the functions represents a subset of floating-point exceptions, and can
10488 be zero or the bitwise OR of one or more floating-point exception macros, for example
10489 FE_OVERFLOW | FE_INEXACT. For other argument values the behavior of these
10490 functions is undefined.
10493 <p><a name="note212">212)</a> The functions fetestexcept, feraiseexcept, and feclearexcept support the basic
10494 abstraction of flags that are either set or clear. An implementation may endow floating-point status
10495 flags with more information -- for example, the address of the code which first raised the floating-
10496 point exception; the functions fegetexceptflag and fesetexceptflag deal with the full
10500 <a name="7.6.2.1" href="#7.6.2.1"><h5>7.6.2.1 The feclearexcept function</h5></a>
10504 #include <fenv.h>
10505 int feclearexcept(int excepts);</pre>
10506 <h6>Description</h6>
10508 The feclearexcept function attempts to clear the supported floating-point exceptions
10509 represented by its argument.
10512 The feclearexcept function returns zero if the excepts argument is zero or if all
10513 the specified exceptions were successfully cleared. Otherwise, it returns a nonzero value.
10516 <!--page 227 indent 4-->
10518 <a name="7.6.2.2" href="#7.6.2.2"><h5>7.6.2.2 The fegetexceptflag function</h5></a>
10522 #include <fenv.h>
10523 int fegetexceptflag(fexcept_t *flagp,
10524 int excepts);</pre>
10525 <h6>Description</h6>
10527 The fegetexceptflag function attempts to store an implementation-defined
10528 representation of the states of the floating-point status flags indicated by the argument
10529 excepts in the object pointed to by the argument flagp.
10532 The fegetexceptflag function returns zero if the representation was successfully
10533 stored. Otherwise, it returns a nonzero value.
10535 <a name="7.6.2.3" href="#7.6.2.3"><h5>7.6.2.3 The feraiseexcept function</h5></a>
10539 #include <fenv.h>
10540 int feraiseexcept(int excepts);</pre>
10541 <h6>Description</h6>
10543 The feraiseexcept function attempts to raise the supported floating-point exceptions
10544 represented by its argument.<sup><a href="#note213"><b>213)</b></a></sup> The order in which these floating-point exceptions are
10545 raised is unspecified, except as stated in <a href="#F.8.6">F.8.6</a>. Whether the feraiseexcept function
10546 additionally raises the ''inexact'' floating-point exception whenever it raises the
10547 ''overflow'' or ''underflow'' floating-point exception is implementation-defined.
10550 The feraiseexcept function returns zero if the excepts argument is zero or if all
10551 the specified exceptions were successfully raised. Otherwise, it returns a nonzero value.
10556 <!--page 228 indent 4-->
10559 <p><a name="note213">213)</a> The effect is intended to be similar to that of floating-point exceptions raised by arithmetic operations.
10560 Hence, enabled traps for floating-point exceptions raised by this function are taken. The specification
10561 in <a href="#F.8.6">F.8.6</a> is in the same spirit.
10564 <a name="7.6.2.4" href="#7.6.2.4"><h5>7.6.2.4 The fesetexceptflag function</h5></a>
10568 #include <fenv.h>
10569 int fesetexceptflag(const fexcept_t *flagp,
10570 int excepts);</pre>
10571 <h6>Description</h6>
10573 The fesetexceptflag function attempts to set the floating-point status flags
10574 indicated by the argument excepts to the states stored in the object pointed to by
10575 flagp. The value of *flagp shall have been set by a previous call to
10576 fegetexceptflag whose second argument represented at least those floating-point
10577 exceptions represented by the argument excepts. This function does not raise floating-
10578 point exceptions, but only sets the state of the flags.
10581 The fesetexceptflag function returns zero if the excepts argument is zero or if
10582 all the specified flags were successfully set to the appropriate state. Otherwise, it returns
10585 <a name="7.6.2.5" href="#7.6.2.5"><h5>7.6.2.5 The fetestexcept function</h5></a>
10589 #include <fenv.h>
10590 int fetestexcept(int excepts);</pre>
10591 <h6>Description</h6>
10593 The fetestexcept function determines which of a specified subset of the floating-
10594 point exception flags are currently set. The excepts argument specifies the floating-
10595 point status flags to be queried.<sup><a href="#note214"><b>214)</b></a></sup>
10598 The fetestexcept function returns the value of the bitwise OR of the floating-point
10599 exception macros corresponding to the currently set floating-point exceptions included in
10602 EXAMPLE Call f if ''invalid'' is set, then g if ''overflow'' is set:
10607 <!--page 229 indent 4-->
10609 #include <fenv.h>
10612 #pragma STDC FENV_ACCESS ON
10614 feclearexcept(FE_INVALID | FE_OVERFLOW);
10615 // maybe raise exceptions
10616 set_excepts = fetestexcept(FE_INVALID | FE_OVERFLOW);
10617 if (set_excepts & FE_INVALID) f();
10618 if (set_excepts & FE_OVERFLOW) g();
10624 <p><a name="note214">214)</a> This mechanism allows testing several floating-point exceptions with just one function call.
10627 <a name="7.6.3" href="#7.6.3"><h4>7.6.3 Rounding</h4></a>
10629 The fegetround and fesetround functions provide control of rounding direction
10632 <a name="7.6.3.1" href="#7.6.3.1"><h5>7.6.3.1 The fegetround function</h5></a>
10636 #include <fenv.h>
10637 int fegetround(void);</pre>
10638 <h6>Description</h6>
10640 The fegetround function gets the current rounding direction.
10643 The fegetround function returns the value of the rounding direction macro
10644 representing the current rounding direction or a negative value if there is no such
10645 rounding direction macro or the current rounding direction is not determinable.
10647 <a name="7.6.3.2" href="#7.6.3.2"><h5>7.6.3.2 The fesetround function</h5></a>
10651 #include <fenv.h>
10652 int fesetround(int round);</pre>
10653 <h6>Description</h6>
10655 The fesetround function establishes the rounding direction represented by its
10656 argument round. If the argument is not equal to the value of a rounding direction macro,
10657 the rounding direction is not changed.
10660 The fesetround function returns zero if and only if the requested rounding direction
10662 <!--page 230 indent 4-->
10664 EXAMPLE Save, set, and restore the rounding direction. Report an error and abort if setting the
10665 rounding direction fails.
10667 #include <fenv.h>
10668 #include <assert.h>
10669 void f(int round_dir)
10671 #pragma STDC FENV_ACCESS ON
10674 save_round = fegetround();
10675 setround_ok = fesetround(round_dir);
10676 assert(setround_ok == 0);
10678 fesetround(save_round);
10683 <a name="7.6.4" href="#7.6.4"><h4>7.6.4 Environment</h4></a>
10685 The functions in this section manage the floating-point environment -- status flags and
10686 control modes -- as one entity.
10688 <a name="7.6.4.1" href="#7.6.4.1"><h5>7.6.4.1 The fegetenv function</h5></a>
10692 #include <fenv.h>
10693 int fegetenv(fenv_t *envp);</pre>
10694 <h6>Description</h6>
10696 The fegetenv function attempts to store the current floating-point environment in the
10697 object pointed to by envp.
10700 The fegetenv function returns zero if the environment was successfully stored.
10701 Otherwise, it returns a nonzero value.
10703 <a name="7.6.4.2" href="#7.6.4.2"><h5>7.6.4.2 The feholdexcept function</h5></a>
10707 #include <fenv.h>
10708 int feholdexcept(fenv_t *envp);</pre>
10709 <h6>Description</h6>
10711 The feholdexcept function saves the current floating-point environment in the object
10712 pointed to by envp, clears the floating-point status flags, and then installs a non-stop
10713 (continue on floating-point exceptions) mode, if available, for all floating-point
10714 exceptions.<sup><a href="#note215"><b>215)</b></a></sup>
10715 <!--page 231 indent 4-->
10718 The feholdexcept function returns zero if and only if non-stop floating-point
10719 exception handling was successfully installed.
10722 <p><a name="note215">215)</a> IEC 60559 systems have a default non-stop mode, and typically at least one other mode for trap
10723 handling or aborting; if the system provides only the non-stop mode then installing it is trivial. For
10724 such systems, the feholdexcept function can be used in conjunction with the feupdateenv
10725 function to write routines that hide spurious floating-point exceptions from their callers.
10728 <a name="7.6.4.3" href="#7.6.4.3"><h5>7.6.4.3 The fesetenv function</h5></a>
10732 #include <fenv.h>
10733 int fesetenv(const fenv_t *envp);</pre>
10734 <h6>Description</h6>
10736 The fesetenv function attempts to establish the floating-point environment represented
10737 by the object pointed to by envp. The argument envp shall point to an object set by a
10738 call to fegetenv or feholdexcept, or equal a floating-point environment macro.
10739 Note that fesetenv merely installs the state of the floating-point status flags
10740 represented through its argument, and does not raise these floating-point exceptions.
10743 The fesetenv function returns zero if the environment was successfully established.
10744 Otherwise, it returns a nonzero value.
10746 <a name="7.6.4.4" href="#7.6.4.4"><h5>7.6.4.4 The feupdateenv function</h5></a>
10750 #include <fenv.h>
10751 int feupdateenv(const fenv_t *envp);</pre>
10752 <h6>Description</h6>
10754 The feupdateenv function attempts to save the currently raised floating-point
10755 exceptions in its automatic storage, install the floating-point environment represented by
10756 the object pointed to by envp, and then raise the saved floating-point exceptions. The
10757 argument envp shall point to an object set by a call to feholdexcept or fegetenv,
10758 or equal a floating-point environment macro.
10761 The feupdateenv function returns zero if all the actions were successfully carried out.
10762 Otherwise, it returns a nonzero value.
10767 <!--page 232 indent 4-->
10769 EXAMPLE Hide spurious underflow floating-point exceptions:
10770 <!--page 233 indent 4-->
10772 #include <fenv.h>
10775 #pragma STDC FENV_ACCESS ON
10778 if (feholdexcept(&save_env))
10779 return /* indication of an environmental problem */;
10781 if (/* test spurious underflow */)
10782 if (feclearexcept(FE_UNDERFLOW))
10783 return /* indication of an environmental problem */;
10784 if (feupdateenv(&save_env))
10785 return /* indication of an environmental problem */;
10789 <a name="7.7" href="#7.7"><h3>7.7 Characteristics of floating types <float.h></h3></a>
10791 The header <float.h> defines several macros that expand to various limits and
10792 parameters of the standard floating-point types.
10794 The macros, their meanings, and the constraints (or restrictions) on their values are listed
10795 in <a href="#5.2.4.2.2">5.2.4.2.2</a>.
10796 <!--page 234 indent 4-->
10798 <a name="7.8" href="#7.8"><h3>7.8 Format conversion of integer types <inttypes.h></h3></a>
10800 The header <inttypes.h> includes the header <stdint.h> and extends it with
10801 additional facilities provided by hosted implementations.
10803 It declares functions for manipulating greatest-width integers and converting numeric
10804 character strings to greatest-width integers, and it declares the type
10807 which is a structure type that is the type of the value returned by the imaxdiv function.
10808 For each type declared in <stdint.h>, it defines corresponding macros for conversion
10809 specifiers for use with the formatted input/output functions.<sup><a href="#note216"><b>216)</b></a></sup>
10810 Forward references: integer types <stdint.h> (<a href="#7.20">7.20</a>), formatted input/output
10811 functions (<a href="#7.21.6">7.21.6</a>), formatted wide character input/output functions (<a href="#7.28.2">7.28.2</a>).
10814 <p><a name="note216">216)</a> See ''future library directions'' (<a href="#7.30.4">7.30.4</a>).
10817 <a name="7.8.1" href="#7.8.1"><h4>7.8.1 Macros for format specifiers</h4></a>
10819 Each of the following object-like macros expands to a character string literal containing a *
10820 conversion specifier, possibly modified by a length modifier, suitable for use within the
10821 format argument of a formatted input/output function when converting the corresponding
10822 integer type. These macro names have the general form of PRI (character string literals
10823 for the fprintf and fwprintf family) or SCN (character string literals for the
10824 fscanf and fwscanf family),<sup><a href="#note217"><b>217)</b></a></sup> followed by the conversion specifier, followed by a
10825 name corresponding to a similar type name in <a href="#7.20.1">7.20.1</a>. In these names, N represents the
10826 width of the type as described in <a href="#7.20.1">7.20.1</a>. For example, PRIdFAST32 can be used in a
10827 format string to print the value of an integer of type int_fast32_t.
10829 The fprintf macros for signed integers are:
10832 PRIdN PRIdLEASTN PRIdFASTN PRIdMAX PRIdPTR
10833 PRIiN PRIiLEASTN PRIiFASTN PRIiMAX PRIiPTR</pre>
10834 The fprintf macros for unsigned integers are:
10837 PRIoN PRIoLEASTN PRIoFASTN PRIoMAX PRIoPTR
10838 PRIuN PRIuLEASTN PRIuFASTN PRIuMAX PRIuPTR
10839 PRIxN PRIxLEASTN PRIxFASTN PRIxMAX PRIxPTR
10840 PRIXN PRIXLEASTN PRIXFASTN PRIXMAX PRIXPTR</pre>
10841 The fscanf macros for signed integers are:
10845 <!--page 235 indent 4-->
10848 SCNdN SCNdLEASTN SCNdFASTN SCNdMAX SCNdPTR
10849 SCNiN SCNiLEASTN SCNiFASTN SCNiMAX SCNiPTR</pre>
10850 The fscanf macros for unsigned integers are:
10853 SCNoN SCNoLEASTN SCNoFASTN SCNoMAX SCNoPTR
10854 SCNuN SCNuLEASTN SCNuFASTN SCNuMAX SCNuPTR
10855 SCNxN SCNxLEASTN SCNxFASTN SCNxMAX SCNxPTR</pre>
10856 For each type that the implementation provides in <stdint.h>, the corresponding
10857 fprintf macros shall be defined and the corresponding fscanf macros shall be
10858 defined unless the implementation does not have a suitable fscanf length modifier for
10863 #include <inttypes.h>
10864 #include <wchar.h>
10867 uintmax_t i = UINTMAX_MAX; // this type always exists
10868 wprintf(L"The largest integer value is %020"
10875 <p><a name="note217">217)</a> Separate macros are given for use with fprintf and fscanf functions because, in the general case,
10876 different format specifiers may be required for fprintf and fscanf, even when the type is the
10880 <a name="7.8.2" href="#7.8.2"><h4>7.8.2 Functions for greatest-width integer types</h4></a>
10882 <a name="7.8.2.1" href="#7.8.2.1"><h5>7.8.2.1 The imaxabs function</h5></a>
10886 #include <inttypes.h>
10887 intmax_t imaxabs(intmax_t j);</pre>
10888 <h6>Description</h6>
10890 The imaxabs function computes the absolute value of an integer j. If the result cannot
10891 be represented, the behavior is undefined.<sup><a href="#note218"><b>218)</b></a></sup>
10894 The imaxabs function returns the absolute value.
10899 <!--page 236 indent 4-->
10902 <p><a name="note218">218)</a> The absolute value of the most negative number cannot be represented in two's complement.
10905 <a name="7.8.2.2" href="#7.8.2.2"><h5>7.8.2.2 The imaxdiv function</h5></a>
10909 #include <inttypes.h>
10910 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);</pre>
10911 <h6>Description</h6>
10913 The imaxdiv function computes numer / denom and numer % denom in a single
10917 The imaxdiv function returns a structure of type imaxdiv_t comprising both the
10918 quotient and the remainder. The structure shall contain (in either order) the members
10919 quot (the quotient) and rem (the remainder), each of which has type intmax_t. If
10920 either part of the result cannot be represented, the behavior is undefined.
10922 <a name="7.8.2.3" href="#7.8.2.3"><h5>7.8.2.3 The strtoimax and strtoumax functions</h5></a>
10926 #include <inttypes.h>
10927 intmax_t strtoimax(const char * restrict nptr,
10928 char ** restrict endptr, int base);
10929 uintmax_t strtoumax(const char * restrict nptr,
10930 char ** restrict endptr, int base);</pre>
10931 <h6>Description</h6>
10933 The strtoimax and strtoumax functions are equivalent to the strtol, strtoll,
10934 strtoul, and strtoull functions, except that the initial portion of the string is
10935 converted to intmax_t and uintmax_t representation, respectively.
10938 The strtoimax and strtoumax functions return the converted value, if any. If no
10939 conversion could be performed, zero is returned. If the correct value is outside the range
10940 of representable values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned
10941 (according to the return type and sign of the value, if any), and the value of the macro
10942 ERANGE is stored in errno.
10943 Forward references: the strtol, strtoll, strtoul, and strtoull functions
10944 (<a href="#7.22.1.4">7.22.1.4</a>).
10945 <!--page 237 indent 4-->
10947 <a name="7.8.2.4" href="#7.8.2.4"><h5>7.8.2.4 The wcstoimax and wcstoumax functions</h5></a>
10951 #include <stddef.h> // for wchar_t
10952 #include <inttypes.h>
10953 intmax_t wcstoimax(const wchar_t * restrict nptr,
10954 wchar_t ** restrict endptr, int base);
10955 uintmax_t wcstoumax(const wchar_t * restrict nptr,
10956 wchar_t ** restrict endptr, int base);</pre>
10957 <h6>Description</h6>
10959 The wcstoimax and wcstoumax functions are equivalent to the wcstol, wcstoll,
10960 wcstoul, and wcstoull functions except that the initial portion of the wide string is
10961 converted to intmax_t and uintmax_t representation, respectively.
10964 The wcstoimax function returns the converted value, if any. If no conversion could be
10965 performed, zero is returned. If the correct value is outside the range of representable
10966 values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned (according to the
10967 return type and sign of the value, if any), and the value of the macro ERANGE is stored in
10969 Forward references: the wcstol, wcstoll, wcstoul, and wcstoull functions
10970 (<a href="#7.28.4.1.2">7.28.4.1.2</a>).
10971 <!--page 238 indent 4-->
10973 <a name="7.9" href="#7.9"><h3>7.9 Alternative spellings <iso646.h></h3></a>
10975 The header <iso646.h> defines the following eleven macros (on the left) that expand
10976 to the corresponding tokens (on the right):
10977 <!--page 239 indent 4-->
10991 <a name="7.10" href="#7.10"><h3>7.10 Sizes of integer types <limits.h></h3></a>
10993 The header <limits.h> defines several macros that expand to various limits and
10994 parameters of the standard integer types.
10996 The macros, their meanings, and the constraints (or restrictions) on their values are listed
10997 in <a href="#5.2.4.2.1">5.2.4.2.1</a>.
10998 <!--page 240 indent 4-->
11000 <a name="7.11" href="#7.11"><h3>7.11 Localization <locale.h></h3></a>
11002 The header <locale.h> declares two functions, one type, and defines several macros.
11007 which contains members related to the formatting of numeric values. The structure shall
11008 contain at least the following members, in any order. The semantics of the members and
11009 their normal ranges are explained in <a href="#7.11.2.1">7.11.2.1</a>. In the "C" locale, the members shall have
11010 the values specified in the comments.
11011 <!--page 241 indent 4-->
11014 char *decimal_point; // "."
11015 char *thousands_sep; // ""
11016 char *grouping; // ""
11017 char *mon_decimal_point; // ""
11018 char *mon_thousands_sep; // ""
11019 char *mon_grouping; // ""
11020 char *positive_sign; // ""
11021 char *negative_sign; // ""
11022 char *currency_symbol; // ""
11023 char frac_digits; // CHAR_MAX
11024 char p_cs_precedes; // CHAR_MAX
11025 char n_cs_precedes; // CHAR_MAX
11026 char p_sep_by_space; // CHAR_MAX
11027 char n_sep_by_space; // CHAR_MAX
11028 char p_sign_posn; // CHAR_MAX
11029 char n_sign_posn; // CHAR_MAX
11030 char *int_curr_symbol; // ""
11031 char int_frac_digits; // CHAR_MAX
11032 char int_p_cs_precedes; // CHAR_MAX
11033 char int_n_cs_precedes; // CHAR_MAX
11034 char int_p_sep_by_space; // CHAR_MAX
11035 char int_n_sep_by_space; // CHAR_MAX
11036 char int_p_sign_posn; // CHAR_MAX
11037 char int_n_sign_posn; // CHAR_MAX</pre>
11038 The macros defined are NULL (described in <a href="#7.19">7.19</a>); and
11046 which expand to integer constant expressions with distinct values, suitable for use as the
11047 first argument to the setlocale function.<sup><a href="#note219"><b>219)</b></a></sup> Additional macro definitions, beginning
11048 with the characters LC_ and an uppercase letter,<sup><a href="#note220"><b>220)</b></a></sup> may also be specified by the
11052 <p><a name="note219">219)</a> ISO/IEC 9945-2 specifies locale and charmap formats that may be used to specify locales for C.
11054 <p><a name="note220">220)</a> See ''future library directions'' (<a href="#7.30.5">7.30.5</a>).
11057 <a name="7.11.1" href="#7.11.1"><h4>7.11.1 Locale control</h4></a>
11059 <a name="7.11.1.1" href="#7.11.1.1"><h5>7.11.1.1 The setlocale function</h5></a>
11063 #include <locale.h>
11064 char *setlocale(int category, const char *locale);</pre>
11065 <h6>Description</h6>
11067 The setlocale function selects the appropriate portion of the program's locale as
11068 specified by the category and locale arguments. The setlocale function may be
11069 used to change or query the program's entire current locale or portions thereof. The value
11070 LC_ALL for category names the program's entire locale; the other values for
11071 category name only a portion of the program's locale. LC_COLLATE affects the
11072 behavior of the strcoll and strxfrm functions. LC_CTYPE affects the behavior of
11073 the character handling functions<sup><a href="#note221"><b>221)</b></a></sup> and the multibyte and wide character functions.
11074 LC_MONETARY affects the monetary formatting information returned by the
11075 localeconv function. LC_NUMERIC affects the decimal-point character for the
11076 formatted input/output functions and the string conversion functions, as well as the
11077 nonmonetary formatting information returned by the localeconv function. LC_TIME
11078 affects the behavior of the strftime and wcsftime functions.
11080 A value of "C" for locale specifies the minimal environment for C translation; a value
11081 of "" for locale specifies the locale-specific native environment. Other
11082 implementation-defined strings may be passed as the second argument to setlocale.
11084 <!--page 242 indent 4-->
11086 At program startup, the equivalent of
11088 setlocale(LC_ALL, "C");</pre>
11091 A call to the setlocale function may introduce a data race with other calls to the
11092 setlocale function or with calls to functions that are affected by the current locale.
11093 The implementation shall behave as if no library function calls the setlocale function.
11096 If a pointer to a string is given for locale and the selection can be honored, the
11097 setlocale function returns a pointer to the string associated with the specified
11098 category for the new locale. If the selection cannot be honored, the setlocale
11099 function returns a null pointer and the program's locale is not changed.
11101 A null pointer for locale causes the setlocale function to return a pointer to the
11102 string associated with the category for the program's current locale; the program's
11103 locale is not changed.<sup><a href="#note222"><b>222)</b></a></sup>
11105 The pointer to string returned by the setlocale function is such that a subsequent call
11106 with that string value and its associated category will restore that part of the program's
11107 locale. The string pointed to shall not be modified by the program, but may be
11108 overwritten by a subsequent call to the setlocale function.
11109 Forward references: formatted input/output functions (<a href="#7.21.6">7.21.6</a>), multibyte/wide
11110 character conversion functions (<a href="#7.22.7">7.22.7</a>), multibyte/wide string conversion functions
11111 (<a href="#7.22.8">7.22.8</a>), numeric conversion functions (<a href="#7.22.1">7.22.1</a>), the strcoll function (<a href="#7.23.4.3">7.23.4.3</a>), the
11112 strftime function (<a href="#7.26.3.5">7.26.3.5</a>), the strxfrm function (<a href="#7.23.4.5">7.23.4.5</a>).
11115 <p><a name="note221">221)</a> The only functions in <a href="#7.4">7.4</a> whose behavior is not affected by the current locale are isdigit and
11118 <p><a name="note222">222)</a> The implementation shall arrange to encode in a string the various categories due to a heterogeneous
11119 locale when category has the value LC_ALL.
11122 <a name="7.11.2" href="#7.11.2"><h4>7.11.2 Numeric formatting convention inquiry</h4></a>
11124 <a name="7.11.2.1" href="#7.11.2.1"><h5>7.11.2.1 The localeconv function</h5></a>
11128 #include <locale.h>
11129 struct lconv *localeconv(void);</pre>
11130 <h6>Description</h6>
11132 The localeconv function sets the components of an object with type struct lconv
11133 with values appropriate for the formatting of numeric quantities (monetary and otherwise)
11134 according to the rules of the current locale.
11138 <!--page 243 indent 4-->
11140 The members of the structure with type char * are pointers to strings, any of which
11141 (except decimal_point) can point to "", to indicate that the value is not available in
11142 the current locale or is of zero length. Apart from grouping and mon_grouping, the
11143 strings shall start and end in the initial shift state. The members with type char are
11144 nonnegative numbers, any of which can be CHAR_MAX to indicate that the value is not
11145 available in the current locale. The members include the following:
11146 char *decimal_point
11148 The decimal-point character used to format nonmonetary quantities.</pre>
11149 char *thousands_sep
11151 The character used to separate groups of digits before the decimal-point
11152 character in formatted nonmonetary quantities.</pre>
11155 A string whose elements indicate the size of each group of digits in
11156 formatted nonmonetary quantities.</pre>
11157 char *mon_decimal_point
11159 The decimal-point used to format monetary quantities.</pre>
11160 char *mon_thousands_sep
11162 The separator for groups of digits before the decimal-point in formatted
11163 monetary quantities.</pre>
11166 A string whose elements indicate the size of each group of digits in
11167 formatted monetary quantities.</pre>
11168 char *positive_sign
11170 The string used to indicate a nonnegative-valued formatted monetary
11172 char *negative_sign
11174 The string used to indicate a negative-valued formatted monetary quantity.</pre>
11175 char *currency_symbol
11177 The local currency symbol applicable to the current locale.</pre>
11180 The number of fractional digits (those after the decimal-point) to be
11181 displayed in a locally formatted monetary quantity.</pre>
11183 <!--page 244 indent 0-->
11185 Set to 1 or 0 if the currency_symbol respectively precedes or
11186 succeeds the value for a nonnegative locally formatted monetary quantity.</pre>
11189 Set to 1 or 0 if the currency_symbol respectively precedes or
11190 succeeds the value for a negative locally formatted monetary quantity.</pre>
11191 char p_sep_by_space
11193 Set to a value indicating the separation of the currency_symbol, the
11194 sign string, and the value for a nonnegative locally formatted monetary
11196 char n_sep_by_space
11198 Set to a value indicating the separation of the currency_symbol, the
11199 sign string, and the value for a negative locally formatted monetary
11203 Set to a value indicating the positioning of the positive_sign for a
11204 nonnegative locally formatted monetary quantity.</pre>
11207 Set to a value indicating the positioning of the negative_sign for a
11208 negative locally formatted monetary quantity.</pre>
11209 char *int_curr_symbol
11211 The international currency symbol applicable to the current locale. The
11212 first three characters contain the alphabetic international currency symbol
11213 in accordance with those specified in ISO 4217. The fourth character
11214 (immediately preceding the null character) is the character used to separate
11215 the international currency symbol from the monetary quantity.</pre>
11216 char int_frac_digits
11218 The number of fractional digits (those after the decimal-point) to be
11219 displayed in an internationally formatted monetary quantity.</pre>
11220 char int_p_cs_precedes
11222 Set to 1 or 0 if the int_curr_symbol respectively precedes or
11223 succeeds the value for a nonnegative internationally formatted monetary
11225 char int_n_cs_precedes
11227 Set to 1 or 0 if the int_curr_symbol respectively precedes or
11228 succeeds the value for a negative internationally formatted monetary
11230 char int_p_sep_by_space
11231 <!--page 245 indent 4-->
11233 Set to a value indicating the separation of the int_curr_symbol, the
11234 sign string, and the value for a nonnegative internationally formatted
11235 monetary quantity.</pre>
11236 char int_n_sep_by_space
11238 Set to a value indicating the separation of the int_curr_symbol, the
11239 sign string, and the value for a negative internationally formatted monetary
11241 char int_p_sign_posn
11243 Set to a value indicating the positioning of the positive_sign for a
11244 nonnegative internationally formatted monetary quantity.</pre>
11245 char int_n_sign_posn
11248 Set to a value indicating the positioning of the negative_sign for a
11249 negative internationally formatted monetary quantity.</pre>
11250 The elements of grouping and mon_grouping are interpreted according to the
11252 CHAR_MAX No further grouping is to be performed.
11253 0 The previous element is to be repeatedly used for the remainder of the
11256 other The integer value is the number of digits that compose the current group.
11259 The next element is examined to determine the size of the next group of
11260 digits before the current group.</pre>
11261 The values of p_sep_by_space, n_sep_by_space, int_p_sep_by_space,
11262 and int_n_sep_by_space are interpreted according to the following:
11263 0 No space separates the currency symbol and value.
11264 1 If the currency symbol and sign string are adjacent, a space separates them from the
11266 value; otherwise, a space separates the currency symbol from the value.</pre>
11267 2 If the currency symbol and sign string are adjacent, a space separates them;
11269 otherwise, a space separates the sign string from the value.</pre>
11270 For int_p_sep_by_space and int_n_sep_by_space, the fourth character of
11271 int_curr_symbol is used instead of a space.
11273 The values of p_sign_posn, n_sign_posn, int_p_sign_posn, and
11274 int_n_sign_posn are interpreted according to the following:
11275 0 Parentheses surround the quantity and currency symbol.
11276 1 The sign string precedes the quantity and currency symbol.
11277 2 The sign string succeeds the quantity and currency symbol.
11278 3 The sign string immediately precedes the currency symbol.
11279 4 The sign string immediately succeeds the currency symbol.
11280 <!--page 246 indent 5-->
11282 The implementation shall behave as if no library function calls the localeconv
11286 The localeconv function returns a pointer to the filled-in object. The structure
11287 pointed to by the return value shall not be modified by the program, but may be
11288 overwritten by a subsequent call to the localeconv function. In addition, calls to the
11289 setlocale function with categories LC_ALL, LC_MONETARY, or LC_NUMERIC may
11290 overwrite the contents of the structure.
11292 EXAMPLE 1 The following table illustrates rules which may well be used by four countries to format
11293 monetary quantities.
11295 Local format International format</pre>
11297 Country Positive Negative Positive Negative
11299 Country1 1.234,56 mk -1.234,56 mk FIM 1.234,56 FIM -1.234,56
11300 Country2 L.1.234 -L.1.234 ITL 1.234 -ITL 1.234
11301 Country3 fl. 1.234,56 fl. -1.234,56 NLG 1.234,56 NLG -1.234,56
11302 Country4 SFrs.1,234.56 SFrs.1,234.56C CHF 1,234.56 CHF 1,234.56C
11304 For these four countries, the respective values for the monetary members of the structure returned by
11305 localeconv could be:
11307 Country1 Country2 Country3 Country4</pre>
11309 mon_decimal_point "," "" "," "."
11310 mon_thousands_sep "." "." "." ","
11311 mon_grouping "\3" "\3" "\3" "\3"
11312 positive_sign "" "" "" ""
11313 negative_sign "-" "-" "-" "C"
11314 currency_symbol "mk" "L." "\u0192" "SFrs."
11315 frac_digits 2 0 2 2
11316 p_cs_precedes 0 1 1 1
11317 n_cs_precedes 0 1 1 1
11318 p_sep_by_space 1 0 1 0
11319 n_sep_by_space 1 0 2 0
11320 p_sign_posn 1 1 1 1
11321 n_sign_posn 1 1 4 2
11322 int_curr_symbol "FIM " "ITL " "NLG " "CHF "
11323 int_frac_digits 2 0 2 2
11324 int_p_cs_precedes 1 1 1 1
11325 int_n_cs_precedes 1 1 1 1
11326 int_p_sep_by_space 1 1 1 1
11327 int_n_sep_by_space 2 1 2 1
11328 int_p_sign_posn 1 1 1 1
11329 int_n_sign_posn 4 1 4 2
11330 <!--page 247 indent 5-->
11332 EXAMPLE 2 The following table illustrates how the cs_precedes, sep_by_space, and sign_posn members
11333 affect the formatted value.
11335 p_sep_by_space</pre>
11337 p_cs_precedes p_sign_posn 0 1 2
11340 0 0 (<a href="#1.25">1.25</a>$) (<a href="#1.25">1.25</a> $) (<a href="#1.25">1.25</a>$)
11341 1 +1.25$ +1.25 $ + <a href="#1.25">1.25</a>$
11342 2 <a href="#1.25">1.25</a>$+ <a href="#1.25">1.25</a> $+ <a href="#1.25">1.25</a>$ +
11343 3 <a href="#1.25">1.25</a>+$ <a href="#1.25">1.25</a> +$ <a href="#1.25">1.25</a>+ $
11344 4 <a href="#1.25">1.25</a>$+ <a href="#1.25">1.25</a> $+ <a href="#1.25">1.25</a>$ +</pre>
11346 <!--page 248 indent 4-->
11348 1 0 ($1.25) ($ <a href="#1.25">1.25</a>) ($1.25)
11349 1 +$1.25 +$ <a href="#1.25">1.25</a> + $1.25
11350 2 $1.25+ $ <a href="#1.25">1.25</a>+ $1.25 +
11351 3 +$1.25 +$ <a href="#1.25">1.25</a> + $1.25
11352 4 $+1.25 $+ <a href="#1.25">1.25</a> $ +1.25</pre>
11354 <a name="7.12" href="#7.12"><h3>7.12 Mathematics <math.h></h3></a>
11356 The header <math.h> declares two types and many mathematical functions and defines
11357 several macros. Most synopses specify a family of functions consisting of a principal
11358 function with one or more double parameters, a double return value, or both; and
11359 other functions with the same name but with f and l suffixes, which are corresponding
11360 functions with float and long double parameters, return values, or both.<sup><a href="#note223"><b>223)</b></a></sup>
11361 Integer arithmetic functions and conversion functions are discussed later.
11367 are floating types at least as wide as float and double, respectively, and such that
11368 double_t is at least as wide as float_t. If FLT_EVAL_METHOD equals 0,
11369 float_t and double_t are float and double, respectively; if
11370 FLT_EVAL_METHOD equals 1, they are both double; if FLT_EVAL_METHOD equals
11371 2, they are both long double; and for other values of FLT_EVAL_METHOD, they are
11372 otherwise implementation-defined.<sup><a href="#note224"><b>224)</b></a></sup>
11377 expands to a positive double constant expression, not necessarily representable as a
11382 are respectively float and long double analogs of HUGE_VAL.<sup><a href="#note225"><b>225)</b></a></sup>
11387 expands to a constant expression of type float representing positive or unsigned
11388 infinity, if available; else to a positive constant of type float that overflows at
11392 <!--page 249 indent 4-->
11393 translation time.<sup><a href="#note226"><b>226)</b></a></sup>
11398 is defined if and only if the implementation supports quiet NaNs for the float type. It
11399 expands to a constant expression of type float representing a quiet NaN.
11401 The number classification macros
11408 represent the mutually exclusive kinds of floating-point values. They expand to integer
11409 constant expressions with distinct values. Additional implementation-defined floating-
11410 point classifications, with macro definitions beginning with FP_ and an uppercase letter,
11411 may also be specified by the implementation.
11416 is optionally defined. If defined, it indicates that the fma function generally executes
11417 about as fast as, or faster than, a multiply and an add of double operands.<sup><a href="#note227"><b>227)</b></a></sup> The
11422 are, respectively, float and long double analogs of FP_FAST_FMA. If defined,
11423 these macros expand to the integer constant 1.
11429 expand to integer constant expressions whose values are returned by ilogb(x) if x is
11430 zero or NaN, respectively. The value of FP_ILOGB0 shall be either INT_MIN or
11431 -INT_MAX. The value of FP_ILOGBNAN shall be either INT_MAX or INT_MIN.
11434 <!--page 250 indent 4-->
11439 MATH_ERREXCEPT</pre>
11440 expand to the integer constants 1 and 2, respectively; the macro
11442 math_errhandling</pre>
11443 expands to an expression that has type int and the value MATH_ERRNO,
11444 MATH_ERREXCEPT, or the bitwise OR of both. The value of math_errhandling is
11445 constant for the duration of the program. It is unspecified whether
11446 math_errhandling is a macro or an identifier with external linkage. If a macro
11447 definition is suppressed or a program defines an identifier with the name
11448 math_errhandling, the behavior is undefined. If the expression
11449 math_errhandling & MATH_ERREXCEPT can be nonzero, the implementation
11450 shall define the macros FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in
11454 <p><a name="note223">223)</a> Particularly on systems with wide expression evaluation, a <math.h> function might pass arguments
11455 and return values in wider format than the synopsis prototype indicates.
11457 <p><a name="note224">224)</a> The types float_t and double_t are intended to be the implementation's most efficient types at
11458 least as wide as float and double, respectively. For FLT_EVAL_METHOD equal 0, 1, or 2, the
11459 type float_t is the narrowest type used by the implementation to evaluate floating expressions.
11461 <p><a name="note225">225)</a> HUGE_VAL, HUGE_VALF, and HUGE_VALL can be positive infinities in an implementation that
11462 supports infinities.
11464 <p><a name="note226">226)</a> In this case, using INFINITY will violate the constraint in <a href="#6.4.4">6.4.4</a> and thus require a diagnostic.
11466 <p><a name="note227">227)</a> Typically, the FP_FAST_FMA macro is defined if and only if the fma function is implemented
11467 directly with a hardware multiply-add instruction. Software implementations are expected to be
11468 substantially slower.
11471 <a name="7.12.1" href="#7.12.1"><h4>7.12.1 Treatment of error conditions</h4></a>
11473 The behavior of each of the functions in <math.h> is specified for all representable
11474 values of its input arguments, except where stated otherwise. Each function shall execute
11475 as if it were a single operation without raising SIGFPE and without generating any of the
11476 floating-point exceptions ''invalid'', ''divide-by-zero'', or ''overflow'' except to reflect
11477 the result of the function.
11479 For all functions, a domain error occurs if an input argument is outside the domain over
11480 which the mathematical function is defined. The description of each function lists any
11481 required domain errors; an implementation may define additional domain errors, provided
11482 that such errors are consistent with the mathematical definition of the function.<sup><a href="#note228"><b>228)</b></a></sup> On a
11483 domain error, the function returns an implementation-defined value; if the integer
11484 expression math_errhandling & MATH_ERRNO is nonzero, the integer expression
11485 errno acquires the value EDOM; if the integer expression math_errhandling &
11486 MATH_ERREXCEPT is nonzero, the ''invalid'' floating-point exception is raised.
11488 Similarly, a pole error (also known as a singularity or infinitary) occurs if the
11489 mathematical function has an exact infinite result as the finite input argument(s) are
11490 approached in the limit (for example, log(0.0)). The description of each function lists
11491 any required pole errors; an implementation may define additional pole errors, provided
11492 that such errors are consistent with the mathematical definition of the function. On a pole
11493 error, the function returns an implementation-defined value; if the integer expression
11496 <!--page 251 indent 4-->
11497 math_errhandling & MATH_ERRNO is nonzero, the integer expression errno
11498 acquires the value ERANGE; if the integer expression math_errhandling &
11499 MATH_ERREXCEPT is nonzero, the ''divide-by-zero'' floating-point exception is raised.
11501 Likewise, a range error occurs if the mathematical result of the function cannot be
11502 represented in an object of the specified type, due to extreme magnitude.
11504 A floating result overflows if the magnitude of the mathematical result is finite but so
11505 large that the mathematical result cannot be represented without extraordinary roundoff
11506 error in an object of the specified type. If a floating result overflows and default rounding
11507 is in effect, then the function returns the value of the macro HUGE_VAL, HUGE_VALF, or *
11508 HUGE_VALL according to the return type, with the same sign as the correct value of the
11509 function; if the integer expression math_errhandling & MATH_ERRNO is nonzero,
11510 the integer expression errno acquires the value ERANGE; if the integer expression
11511 math_errhandling & MATH_ERREXCEPT is nonzero, the ''overflow'' floating-
11512 point exception is raised.
11514 The result underflows if the magnitude of the mathematical result is so small that the
11515 mathematical result cannot be represented, without extraordinary roundoff error, in an
11516 object of the specified type.<sup><a href="#note229"><b>229)</b></a></sup> If the result underflows, the function returns an
11517 implementation-defined value whose magnitude is no greater than the smallest
11518 normalized positive number in the specified type; if the integer expression
11519 math_errhandling & MATH_ERRNO is nonzero, whether errno acquires the
11520 value ERANGE is implementation-defined; if the integer expression
11521 math_errhandling & MATH_ERREXCEPT is nonzero, whether the ''underflow''
11522 floating-point exception is raised is implementation-defined.
11524 If a domain, pole, or range error occurs and the integer expression
11525 math_errhandling & MATH_ERRNO is zero,<sup><a href="#note230"><b>230)</b></a></sup> then errno shall either be set to
11526 the value corresponding to the error or left unmodified. If no such error occurs, errno
11527 shall be left unmodified regardless of the setting of math_errhandling.
11532 <!--page 252 indent 4-->
11535 <p><a name="note228">228)</a> In an implementation that supports infinities, this allows an infinity as an argument to be a domain
11536 error if the mathematical domain of the function does not include the infinity.
11538 <p><a name="note229">229)</a> The term underflow here is intended to encompass both ''gradual underflow'' as in IEC 60559 and
11539 also ''flush-to-zero'' underflow.
11541 <p><a name="note230">230)</a> Math errors are being indicated by the floating-point exception flags rather than by errno.
11544 <a name="7.12.2" href="#7.12.2"><h4>7.12.2 The FP_CONTRACT pragma</h4></a>
11548 #include <math.h>
11549 #pragma STDC FP_CONTRACT on-off-switch</pre>
11550 <h6>Description</h6>
11552 The FP_CONTRACT pragma can be used to allow (if the state is ''on'') or disallow (if the
11553 state is ''off'') the implementation to contract expressions (<a href="#6.5">6.5</a>). Each pragma can occur
11554 either outside external declarations or preceding all explicit declarations and statements
11555 inside a compound statement. When outside external declarations, the pragma takes
11556 effect from its occurrence until another FP_CONTRACT pragma is encountered, or until
11557 the end of the translation unit. When inside a compound statement, the pragma takes
11558 effect from its occurrence until another FP_CONTRACT pragma is encountered
11559 (including within a nested compound statement), or until the end of the compound
11560 statement; at the end of a compound statement the state for the pragma is restored to its
11561 condition just before the compound statement. If this pragma is used in any other
11562 context, the behavior is undefined. The default state (''on'' or ''off'') for the pragma is
11563 implementation-defined.
11565 <a name="7.12.3" href="#7.12.3"><h4>7.12.3 Classification macros</h4></a>
11567 In the synopses in this subclause, real-floating indicates that the argument shall be an
11568 expression of real floating type.
11570 <a name="7.12.3.1" href="#7.12.3.1"><h5>7.12.3.1 The fpclassify macro</h5></a>
11574 #include <math.h>
11575 int fpclassify(real-floating x);</pre>
11576 <h6>Description</h6>
11578 The fpclassify macro classifies its argument value as NaN, infinite, normal,
11579 subnormal, zero, or into another implementation-defined category. First, an argument
11580 represented in a format wider than its semantic type is converted to its semantic type.
11581 Then classification is based on the type of the argument.<sup><a href="#note231"><b>231)</b></a></sup>
11584 The fpclassify macro returns the value of the number classification macro
11585 appropriate to the value of its argument. *
11588 <!--page 253 indent 4-->
11591 <p><a name="note231">231)</a> Since an expression can be evaluated with more range and precision than its type has, it is important to
11592 know the type that classification is based on. For example, a normal long double value might
11593 become subnormal when converted to double, and zero when converted to float.
11596 <a name="7.12.3.2" href="#7.12.3.2"><h5>7.12.3.2 The isfinite macro</h5></a>
11600 #include <math.h>
11601 int isfinite(real-floating x);</pre>
11602 <h6>Description</h6>
11604 The isfinite macro determines whether its argument has a finite value (zero,
11605 subnormal, or normal, and not infinite or NaN). First, an argument represented in a
11606 format wider than its semantic type is converted to its semantic type. Then determination
11607 is based on the type of the argument.
11610 The isfinite macro returns a nonzero value if and only if its argument has a finite
11613 <a name="7.12.3.3" href="#7.12.3.3"><h5>7.12.3.3 The isinf macro</h5></a>
11617 #include <math.h>
11618 int isinf(real-floating x);</pre>
11619 <h6>Description</h6>
11621 The isinf macro determines whether its argument value is an infinity (positive or
11622 negative). First, an argument represented in a format wider than its semantic type is
11623 converted to its semantic type. Then determination is based on the type of the argument.
11626 The isinf macro returns a nonzero value if and only if its argument has an infinite
11629 <a name="7.12.3.4" href="#7.12.3.4"><h5>7.12.3.4 The isnan macro</h5></a>
11633 #include <math.h>
11634 int isnan(real-floating x);</pre>
11635 <h6>Description</h6>
11637 The isnan macro determines whether its argument value is a NaN. First, an argument
11638 represented in a format wider than its semantic type is converted to its semantic type.
11639 Then determination is based on the type of the argument.<sup><a href="#note232"><b>232)</b></a></sup>
11642 <!--page 254 indent 4-->
11645 The isnan macro returns a nonzero value if and only if its argument has a NaN value.
11648 <p><a name="note232">232)</a> For the isnan macro, the type for determination does not matter unless the implementation supports
11649 NaNs in the evaluation type but not in the semantic type.
11652 <a name="7.12.3.5" href="#7.12.3.5"><h5>7.12.3.5 The isnormal macro</h5></a>
11656 #include <math.h>
11657 int isnormal(real-floating x);</pre>
11658 <h6>Description</h6>
11660 The isnormal macro determines whether its argument value is normal (neither zero,
11661 subnormal, infinite, nor NaN). First, an argument represented in a format wider than its
11662 semantic type is converted to its semantic type. Then determination is based on the type
11666 The isnormal macro returns a nonzero value if and only if its argument has a normal
11669 <a name="7.12.3.6" href="#7.12.3.6"><h5>7.12.3.6 The signbit macro</h5></a>
11673 #include <math.h>
11674 int signbit(real-floating x);</pre>
11675 <h6>Description</h6>
11677 The signbit macro determines whether the sign of its argument value is negative.<sup><a href="#note233"><b>233)</b></a></sup>
11680 The signbit macro returns a nonzero value if and only if the sign of its argument value
11686 <!--page 255 indent 4-->
11689 <p><a name="note233">233)</a> The signbit macro reports the sign of all values, including infinities, zeros, and NaNs. If zero is
11690 unsigned, it is treated as positive.
11693 <a name="7.12.4" href="#7.12.4"><h4>7.12.4 Trigonometric functions</h4></a>
11695 <a name="7.12.4.1" href="#7.12.4.1"><h5>7.12.4.1 The acos functions</h5></a>
11699 #include <math.h>
11700 double acos(double x);
11701 float acosf(float x);
11702 long double acosl(long double x);</pre>
11703 <h6>Description</h6>
11705 The acos functions compute the principal value of the arc cosine of x. A domain error
11706 occurs for arguments not in the interval [-1, +1].
11709 The acos functions return arccos x in the interval [0, pi ] radians.
11711 <a name="7.12.4.2" href="#7.12.4.2"><h5>7.12.4.2 The asin functions</h5></a>
11715 #include <math.h>
11716 double asin(double x);
11717 float asinf(float x);
11718 long double asinl(long double x);</pre>
11719 <h6>Description</h6>
11721 The asin functions compute the principal value of the arc sine of x. A domain error
11722 occurs for arguments not in the interval [-1, +1].
11725 The asin functions return arcsin x in the interval [-pi /2, +pi /2] radians.
11727 <a name="7.12.4.3" href="#7.12.4.3"><h5>7.12.4.3 The atan functions</h5></a>
11731 #include <math.h>
11732 double atan(double x);
11733 float atanf(float x);
11734 long double atanl(long double x);</pre>
11735 <h6>Description</h6>
11737 The atan functions compute the principal value of the arc tangent of x.
11738 <!--page 256 indent 4-->
11741 The atan functions return arctan x in the interval [-pi /2, +pi /2] radians.
11743 <a name="7.12.4.4" href="#7.12.4.4"><h5>7.12.4.4 The atan2 functions</h5></a>
11747 #include <math.h>
11748 double atan2(double y, double x);
11749 float atan2f(float y, float x);
11750 long double atan2l(long double y, long double x);</pre>
11751 <h6>Description</h6>
11753 The atan2 functions compute the value of the arc tangent of y/x, using the signs of both
11754 arguments to determine the quadrant of the return value. A domain error may occur if
11755 both arguments are zero.
11758 The atan2 functions return arctan y/x in the interval [-pi , +pi ] radians.
11760 <a name="7.12.4.5" href="#7.12.4.5"><h5>7.12.4.5 The cos functions</h5></a>
11764 #include <math.h>
11765 double cos(double x);
11766 float cosf(float x);
11767 long double cosl(long double x);</pre>
11768 <h6>Description</h6>
11770 The cos functions compute the cosine of x (measured in radians).
11773 The cos functions return cos x.
11775 <a name="7.12.4.6" href="#7.12.4.6"><h5>7.12.4.6 The sin functions</h5></a>
11779 #include <math.h>
11780 double sin(double x);
11781 float sinf(float x);
11782 long double sinl(long double x);</pre>
11783 <h6>Description</h6>
11785 The sin functions compute the sine of x (measured in radians).
11786 <!--page 257 indent 4-->
11789 The sin functions return sin x.
11791 <a name="7.12.4.7" href="#7.12.4.7"><h5>7.12.4.7 The tan functions</h5></a>
11795 #include <math.h>
11796 double tan(double x);
11797 float tanf(float x);
11798 long double tanl(long double x);</pre>
11799 <h6>Description</h6>
11801 The tan functions return the tangent of x (measured in radians).
11804 The tan functions return tan x.
11806 <a name="7.12.5" href="#7.12.5"><h4>7.12.5 Hyperbolic functions</h4></a>
11808 <a name="7.12.5.1" href="#7.12.5.1"><h5>7.12.5.1 The acosh functions</h5></a>
11812 #include <math.h>
11813 double acosh(double x);
11814 float acoshf(float x);
11815 long double acoshl(long double x);</pre>
11816 <h6>Description</h6>
11818 The acosh functions compute the (nonnegative) arc hyperbolic cosine of x. A domain
11819 error occurs for arguments less than 1.
11822 The acosh functions return arcosh x in the interval [0, +(inf)].
11824 <a name="7.12.5.2" href="#7.12.5.2"><h5>7.12.5.2 The asinh functions</h5></a>
11828 #include <math.h>
11829 double asinh(double x);
11830 float asinhf(float x);
11831 long double asinhl(long double x);</pre>
11832 <h6>Description</h6>
11834 The asinh functions compute the arc hyperbolic sine of x.
11835 <!--page 258 indent 4-->
11838 The asinh functions return arsinh x.
11840 <a name="7.12.5.3" href="#7.12.5.3"><h5>7.12.5.3 The atanh functions</h5></a>
11844 #include <math.h>
11845 double atanh(double x);
11846 float atanhf(float x);
11847 long double atanhl(long double x);</pre>
11848 <h6>Description</h6>
11850 The atanh functions compute the arc hyperbolic tangent of x. A domain error occurs
11851 for arguments not in the interval [-1, +1]. A pole error may occur if the argument equals
11855 The atanh functions return artanh x.
11857 <a name="7.12.5.4" href="#7.12.5.4"><h5>7.12.5.4 The cosh functions</h5></a>
11861 #include <math.h>
11862 double cosh(double x);
11863 float coshf(float x);
11864 long double coshl(long double x);</pre>
11865 <h6>Description</h6>
11867 The cosh functions compute the hyperbolic cosine of x. A range error occurs if the
11868 magnitude of x is too large.
11871 The cosh functions return cosh x.
11873 <a name="7.12.5.5" href="#7.12.5.5"><h5>7.12.5.5 The sinh functions</h5></a>
11877 #include <math.h>
11878 double sinh(double x);
11879 float sinhf(float x);
11880 long double sinhl(long double x);</pre>
11881 <h6>Description</h6>
11883 The sinh functions compute the hyperbolic sine of x. A range error occurs if the
11884 magnitude of x is too large.
11885 <!--page 259 indent 4-->
11888 The sinh functions return sinh x.
11890 <a name="7.12.5.6" href="#7.12.5.6"><h5>7.12.5.6 The tanh functions</h5></a>
11894 #include <math.h>
11895 double tanh(double x);
11896 float tanhf(float x);
11897 long double tanhl(long double x);</pre>
11898 <h6>Description</h6>
11900 The tanh functions compute the hyperbolic tangent of x.
11903 The tanh functions return tanh x.
11905 <a name="7.12.6" href="#7.12.6"><h4>7.12.6 Exponential and logarithmic functions</h4></a>
11907 <a name="7.12.6.1" href="#7.12.6.1"><h5>7.12.6.1 The exp functions</h5></a>
11911 #include <math.h>
11912 double exp(double x);
11913 float expf(float x);
11914 long double expl(long double x);</pre>
11915 <h6>Description</h6>
11917 The exp functions compute the base-e exponential of x. A range error occurs if the
11918 magnitude of x is too large.
11921 The exp functions return ex .
11923 <a name="7.12.6.2" href="#7.12.6.2"><h5>7.12.6.2 The exp2 functions</h5></a>
11927 #include <math.h>
11928 double exp2(double x);
11929 float exp2f(float x);
11930 long double exp2l(long double x);</pre>
11931 <h6>Description</h6>
11933 The exp2 functions compute the base-2 exponential of x. A range error occurs if the
11934 magnitude of x is too large.
11935 <!--page 260 indent 4-->
11938 The exp2 functions return 2x .
11940 <a name="7.12.6.3" href="#7.12.6.3"><h5>7.12.6.3 The expm1 functions</h5></a>
11944 #include <math.h>
11945 double expm1(double x);
11946 float expm1f(float x);
11947 long double expm1l(long double x);</pre>
11948 <h6>Description</h6>
11950 The expm1 functions compute the base-e exponential of the argument, minus 1. A range
11951 error occurs if x is too large.<sup><a href="#note234"><b>234)</b></a></sup>
11954 The expm1 functions return ex - 1.
11957 <p><a name="note234">234)</a> For small magnitude x, expm1(x) is expected to be more accurate than exp(x) - 1.
11960 <a name="7.12.6.4" href="#7.12.6.4"><h5>7.12.6.4 The frexp functions</h5></a>
11964 #include <math.h>
11965 double frexp(double value, int *exp);
11966 float frexpf(float value, int *exp);
11967 long double frexpl(long double value, int *exp);</pre>
11968 <h6>Description</h6>
11970 The frexp functions break a floating-point number into a normalized fraction and an
11971 integral power of 2. They store the integer in the int object pointed to by exp.
11974 If value is not a floating-point number or if the integral power of 2 is outside the range
11975 of int, the results are unspecified. Otherwise, the frexp functions return the value x,
11976 such that x has a magnitude in the interval [1/2, 1) or zero, and value equals x x 2*exp .
11977 If value is zero, both parts of the result are zero.
11982 <!--page 261 indent 4-->
11984 <a name="7.12.6.5" href="#7.12.6.5"><h5>7.12.6.5 The ilogb functions</h5></a>
11988 #include <math.h>
11989 int ilogb(double x);
11990 int ilogbf(float x);
11991 int ilogbl(long double x);</pre>
11992 <h6>Description</h6>
11994 The ilogb functions extract the exponent of x as a signed int value. If x is zero they
11995 compute the value FP_ILOGB0; if x is infinite they compute the value INT_MAX; if x is
11996 a NaN they compute the value FP_ILOGBNAN; otherwise, they are equivalent to calling
11997 the corresponding logb function and casting the returned value to type int. A domain
11998 error or range error may occur if x is zero, infinite, or NaN. If the correct value is outside
11999 the range of the return type, the numeric result is unspecified.
12002 The ilogb functions return the exponent of x as a signed int value.
12003 Forward references: the logb functions (<a href="#7.12.6.11">7.12.6.11</a>).
12005 <a name="7.12.6.6" href="#7.12.6.6"><h5>7.12.6.6 The ldexp functions</h5></a>
12009 #include <math.h>
12010 double ldexp(double x, int exp);
12011 float ldexpf(float x, int exp);
12012 long double ldexpl(long double x, int exp);</pre>
12013 <h6>Description</h6>
12015 The ldexp functions multiply a floating-point number by an integral power of 2. A
12016 range error may occur.
12019 The ldexp functions return x x 2exp .
12021 <a name="7.12.6.7" href="#7.12.6.7"><h5>7.12.6.7 The log functions</h5></a>
12024 <!--page 262 indent 4-->
12026 #include <math.h>
12027 double log(double x);
12028 float logf(float x);
12029 long double logl(long double x);</pre>
12030 <h6>Description</h6>
12032 The log functions compute the base-e (natural) logarithm of x. A domain error occurs if
12033 the argument is negative. A pole error may occur if the argument is zero.
12036 The log functions return loge x.
12038 <a name="7.12.6.8" href="#7.12.6.8"><h5>7.12.6.8 The log10 functions</h5></a>
12042 #include <math.h>
12043 double log10(double x);
12044 float log10f(float x);
12045 long double log10l(long double x);</pre>
12046 <h6>Description</h6>
12048 The log10 functions compute the base-10 (common) logarithm of x. A domain error
12049 occurs if the argument is negative. A pole error may occur if the argument is zero.
12052 The log10 functions return log10 x.
12054 <a name="7.12.6.9" href="#7.12.6.9"><h5>7.12.6.9 The log1p functions</h5></a>
12058 #include <math.h>
12059 double log1p(double x);
12060 float log1pf(float x);
12061 long double log1pl(long double x);</pre>
12062 <h6>Description</h6>
12064 The log1p functions compute the base-e (natural) logarithm of 1 plus the argument.<sup><a href="#note235"><b>235)</b></a></sup>
12065 A domain error occurs if the argument is less than -1. A pole error may occur if the
12066 argument equals -1.
12069 The log1p functions return loge (1 + x).
12074 <!--page 263 indent 4-->
12077 <p><a name="note235">235)</a> For small magnitude x, log1p(x) is expected to be more accurate than log(1 + x).
12080 <a name="7.12.6.10" href="#7.12.6.10"><h5>7.12.6.10 The log2 functions</h5></a>
12084 #include <math.h>
12085 double log2(double x);
12086 float log2f(float x);
12087 long double log2l(long double x);</pre>
12088 <h6>Description</h6>
12090 The log2 functions compute the base-2 logarithm of x. A domain error occurs if the
12091 argument is less than zero. A pole error may occur if the argument is zero.
12094 The log2 functions return log2 x.
12096 <a name="7.12.6.11" href="#7.12.6.11"><h5>7.12.6.11 The logb functions</h5></a>
12100 #include <math.h>
12101 double logb(double x);
12102 float logbf(float x);
12103 long double logbl(long double x);</pre>
12104 <h6>Description</h6>
12106 The logb functions extract the exponent of x, as a signed integer value in floating-point
12107 format. If x is subnormal it is treated as though it were normalized; thus, for positive
12110 1 <= x x FLT_RADIX-logb(x) < FLT_RADIX</pre>
12111 A domain error or pole error may occur if the argument is zero.
12114 The logb functions return the signed exponent of x.
12116 <a name="7.12.6.12" href="#7.12.6.12"><h5>7.12.6.12 The modf functions</h5></a>
12120 #include <math.h>
12121 double modf(double value, double *iptr);
12122 float modff(float value, float *iptr);
12123 long double modfl(long double value, long double *iptr);</pre>
12124 <h6>Description</h6>
12126 The modf functions break the argument value into integral and fractional parts, each of
12127 which has the same type and sign as the argument. They store the integral part (in
12128 <!--page 264 indent 4-->
12129 floating-point format) in the object pointed to by iptr.
12132 The modf functions return the signed fractional part of value.
12134 <a name="7.12.6.13" href="#7.12.6.13"><h5>7.12.6.13 The scalbn and scalbln functions</h5></a>
12138 #include <math.h>
12139 double scalbn(double x, int n);
12140 float scalbnf(float x, int n);
12141 long double scalbnl(long double x, int n);
12142 double scalbln(double x, long int n);
12143 float scalblnf(float x, long int n);
12144 long double scalblnl(long double x, long int n);</pre>
12145 <h6>Description</h6>
12147 The scalbn and scalbln functions compute x x FLT_RADIXn efficiently, not
12148 normally by computing FLT_RADIXn explicitly. A range error may occur.
12151 The scalbn and scalbln functions return x x FLT_RADIXn .
12153 <a name="7.12.7" href="#7.12.7"><h4>7.12.7 Power and absolute-value functions</h4></a>
12155 <a name="7.12.7.1" href="#7.12.7.1"><h5>7.12.7.1 The cbrt functions</h5></a>
12159 #include <math.h>
12160 double cbrt(double x);
12161 float cbrtf(float x);
12162 long double cbrtl(long double x);</pre>
12163 <h6>Description</h6>
12165 The cbrt functions compute the real cube root of x.
12168 The cbrt functions return x1/3 .
12169 <!--page 265 indent 4-->
12171 <a name="7.12.7.2" href="#7.12.7.2"><h5>7.12.7.2 The fabs functions</h5></a>
12175 #include <math.h>
12176 double fabs(double x);
12177 float fabsf(float x);
12178 long double fabsl(long double x);</pre>
12179 <h6>Description</h6>
12181 The fabs functions compute the absolute value of a floating-point number x.
12184 The fabs functions return | x |.
12186 <a name="7.12.7.3" href="#7.12.7.3"><h5>7.12.7.3 The hypot functions</h5></a>
12190 #include <math.h>
12191 double hypot(double x, double y);
12192 float hypotf(float x, float y);
12193 long double hypotl(long double x, long double y);</pre>
12194 <h6>Description</h6>
12196 The hypot functions compute the square root of the sum of the squares of x and y,
12197 without undue overflow or underflow. A range error may occur.
12201 The hypot functions return (sqrt)x2 + y2 .
12206 <a name="7.12.7.4" href="#7.12.7.4"><h5>7.12.7.4 The pow functions</h5></a>
12210 #include <math.h>
12211 double pow(double x, double y);
12212 float powf(float x, float y);
12213 long double powl(long double x, long double y);</pre>
12214 <h6>Description</h6>
12216 The pow functions compute x raised to the power y. A domain error occurs if x is finite
12217 and negative and y is finite and not an integer value. A range error may occur. A domain
12218 error may occur if x is zero and y is zero. A domain error or pole error may occur if x is
12219 zero and y is less than zero.
12220 <!--page 266 indent 4-->
12223 The pow functions return xy .
12225 <a name="7.12.7.5" href="#7.12.7.5"><h5>7.12.7.5 The sqrt functions</h5></a>
12229 #include <math.h>
12230 double sqrt(double x);
12231 float sqrtf(float x);
12232 long double sqrtl(long double x);</pre>
12233 <h6>Description</h6>
12235 The sqrt functions compute the nonnegative square root of x. A domain error occurs if
12236 the argument is less than zero.
12239 The sqrt functions return (sqrt)x.
12244 <a name="7.12.8" href="#7.12.8"><h4>7.12.8 Error and gamma functions</h4></a>
12246 <a name="7.12.8.1" href="#7.12.8.1"><h5>7.12.8.1 The erf functions</h5></a>
12250 #include <math.h>
12251 double erf(double x);
12252 float erff(float x);
12253 long double erfl(long double x);</pre>
12254 <h6>Description</h6>
12256 The erf functions compute the error function of x.
12263 The erf functions return erf x =
12270 <a name="7.12.8.2" href="#7.12.8.2"><h5>7.12.8.2 The erfc functions</h5></a>
12274 #include <math.h>
12275 double erfc(double x);
12276 float erfcf(float x);
12277 long double erfcl(long double x);</pre>
12278 <h6>Description</h6>
12280 The erfc functions compute the complementary error function of x. A range error
12281 occurs if x is too large.
12282 <!--page 267 indent 4-->
12289 The erfc functions return erfc x = 1 - erf x =
12296 <a name="7.12.8.3" href="#7.12.8.3"><h5>7.12.8.3 The lgamma functions</h5></a>
12300 #include <math.h>
12301 double lgamma(double x);
12302 float lgammaf(float x);
12303 long double lgammal(long double x);</pre>
12304 <h6>Description</h6>
12306 The lgamma functions compute the natural logarithm of the absolute value of gamma of
12307 x. A range error occurs if x is too large. A pole error may occur if x is a negative integer
12311 The lgamma functions return loge | (Gamma)(x) |.
12313 <a name="7.12.8.4" href="#7.12.8.4"><h5>7.12.8.4 The tgamma functions</h5></a>
12317 #include <math.h>
12318 double tgamma(double x);
12319 float tgammaf(float x);
12320 long double tgammal(long double x);</pre>
12321 <h6>Description</h6>
12323 The tgamma functions compute the gamma function of x. A domain error or pole error
12324 may occur if x is a negative integer or zero. A range error occurs if the magnitude of x is
12325 too large and may occur if the magnitude of x is too small.
12328 The tgamma functions return (Gamma)(x).
12329 <!--page 268 indent 4-->
12331 <a name="7.12.9" href="#7.12.9"><h4>7.12.9 Nearest integer functions</h4></a>
12333 <a name="7.12.9.1" href="#7.12.9.1"><h5>7.12.9.1 The ceil functions</h5></a>
12337 #include <math.h>
12338 double ceil(double x);
12339 float ceilf(float x);
12340 long double ceill(long double x);</pre>
12341 <h6>Description</h6>
12343 The ceil functions compute the smallest integer value not less than x.
12346 The ceil functions return [^x^], expressed as a floating-point number.
12348 <a name="7.12.9.2" href="#7.12.9.2"><h5>7.12.9.2 The floor functions</h5></a>
12352 #include <math.h>
12353 double floor(double x);
12354 float floorf(float x);
12355 long double floorl(long double x);</pre>
12356 <h6>Description</h6>
12358 The floor functions compute the largest integer value not greater than x.
12361 The floor functions return [_x_], expressed as a floating-point number.
12363 <a name="7.12.9.3" href="#7.12.9.3"><h5>7.12.9.3 The nearbyint functions</h5></a>
12367 #include <math.h>
12368 double nearbyint(double x);
12369 float nearbyintf(float x);
12370 long double nearbyintl(long double x);</pre>
12371 <h6>Description</h6>
12373 The nearbyint functions round their argument to an integer value in floating-point
12374 format, using the current rounding direction and without raising the ''inexact'' floating-
12376 <!--page 269 indent 4-->
12379 The nearbyint functions return the rounded integer value.
12381 <a name="7.12.9.4" href="#7.12.9.4"><h5>7.12.9.4 The rint functions</h5></a>
12385 #include <math.h>
12386 double rint(double x);
12387 float rintf(float x);
12388 long double rintl(long double x);</pre>
12389 <h6>Description</h6>
12391 The rint functions differ from the nearbyint functions (<a href="#7.12.9.3">7.12.9.3</a>) only in that the
12392 rint functions may raise the ''inexact'' floating-point exception if the result differs in
12393 value from the argument.
12396 The rint functions return the rounded integer value.
12398 <a name="7.12.9.5" href="#7.12.9.5"><h5>7.12.9.5 The lrint and llrint functions</h5></a>
12402 #include <math.h>
12403 long int lrint(double x);
12404 long int lrintf(float x);
12405 long int lrintl(long double x);
12406 long long int llrint(double x);
12407 long long int llrintf(float x);
12408 long long int llrintl(long double x);</pre>
12409 <h6>Description</h6>
12411 The lrint and llrint functions round their argument to the nearest integer value,
12412 rounding according to the current rounding direction. If the rounded value is outside the
12413 range of the return type, the numeric result is unspecified and a domain error or range
12417 The lrint and llrint functions return the rounded integer value.
12418 <!--page 270 indent 4-->
12420 <a name="7.12.9.6" href="#7.12.9.6"><h5>7.12.9.6 The round functions</h5></a>
12424 #include <math.h>
12425 double round(double x);
12426 float roundf(float x);
12427 long double roundl(long double x);</pre>
12428 <h6>Description</h6>
12430 The round functions round their argument to the nearest integer value in floating-point
12431 format, rounding halfway cases away from zero, regardless of the current rounding
12435 The round functions return the rounded integer value.
12437 <a name="7.12.9.7" href="#7.12.9.7"><h5>7.12.9.7 The lround and llround functions</h5></a>
12441 #include <math.h>
12442 long int lround(double x);
12443 long int lroundf(float x);
12444 long int lroundl(long double x);
12445 long long int llround(double x);
12446 long long int llroundf(float x);
12447 long long int llroundl(long double x);</pre>
12448 <h6>Description</h6>
12450 The lround and llround functions round their argument to the nearest integer value,
12451 rounding halfway cases away from zero, regardless of the current rounding direction. If
12452 the rounded value is outside the range of the return type, the numeric result is unspecified
12453 and a domain error or range error may occur.
12456 The lround and llround functions return the rounded integer value.
12458 <a name="7.12.9.8" href="#7.12.9.8"><h5>7.12.9.8 The trunc functions</h5></a>
12461 <!--page 271 indent 4-->
12463 #include <math.h>
12464 double trunc(double x);
12465 float truncf(float x);
12466 long double truncl(long double x);</pre>
12467 <h6>Description</h6>
12469 The trunc functions round their argument to the integer value, in floating format,
12470 nearest to but no larger in magnitude than the argument.
12473 The trunc functions return the truncated integer value.
12475 <a name="7.12.10" href="#7.12.10"><h4>7.12.10 Remainder functions</h4></a>
12477 <a name="7.12.10.1" href="#7.12.10.1"><h5>7.12.10.1 The fmod functions</h5></a>
12481 #include <math.h>
12482 double fmod(double x, double y);
12483 float fmodf(float x, float y);
12484 long double fmodl(long double x, long double y);</pre>
12485 <h6>Description</h6>
12487 The fmod functions compute the floating-point remainder of x/y.
12490 The fmod functions return the value x - ny, for some integer n such that, if y is nonzero,
12491 the result has the same sign as x and magnitude less than the magnitude of y. If y is zero,
12492 whether a domain error occurs or the fmod functions return zero is implementation-
12495 <a name="7.12.10.2" href="#7.12.10.2"><h5>7.12.10.2 The remainder functions</h5></a>
12499 #include <math.h>
12500 double remainder(double x, double y);
12501 float remainderf(float x, float y);
12502 long double remainderl(long double x, long double y);</pre>
12503 <h6>Description</h6>
12505 The remainder functions compute the remainder x REM y required by IEC 60559.<sup><a href="#note236"><b>236)</b></a></sup>
12510 <!--page 272 indent 4-->
12513 The remainder functions return x REM y. If y is zero, whether a domain error occurs
12514 or the functions return zero is implementation defined.
12517 <p><a name="note236">236)</a> ''When y != 0, the remainder r = x REM y is defined regardless of the rounding mode by the
12518 mathematical relation r = x - ny, where n is the integer nearest the exact value of x/y; whenever
12519 | n - x/y | = 1/2, then n is even. If r = 0, its sign shall be that of x.'' This definition is applicable for *
12520 all implementations.
12523 <a name="7.12.10.3" href="#7.12.10.3"><h5>7.12.10.3 The remquo functions</h5></a>
12527 #include <math.h>
12528 double remquo(double x, double y, int *quo);
12529 float remquof(float x, float y, int *quo);
12530 long double remquol(long double x, long double y,
12532 <h6>Description</h6>
12534 The remquo functions compute the same remainder as the remainder functions. In
12535 the object pointed to by quo they store a value whose sign is the sign of x/y and whose
12536 magnitude is congruent modulo 2n to the magnitude of the integral quotient of x/y, where
12537 n is an implementation-defined integer greater than or equal to 3.
12540 The remquo functions return x REM y. If y is zero, the value stored in the object
12541 pointed to by quo is unspecified and whether a domain error occurs or the functions
12542 return zero is implementation defined.
12544 <a name="7.12.11" href="#7.12.11"><h4>7.12.11 Manipulation functions</h4></a>
12546 <a name="7.12.11.1" href="#7.12.11.1"><h5>7.12.11.1 The copysign functions</h5></a>
12550 #include <math.h>
12551 double copysign(double x, double y);
12552 float copysignf(float x, float y);
12553 long double copysignl(long double x, long double y);</pre>
12554 <h6>Description</h6>
12556 The copysign functions produce a value with the magnitude of x and the sign of y.
12557 They produce a NaN (with the sign of y) if x is a NaN. On implementations that
12558 represent a signed zero but do not treat negative zero consistently in arithmetic
12559 operations, the copysign functions regard the sign of zero as positive.
12562 The copysign functions return a value with the magnitude of x and the sign of y.
12563 <!--page 273 indent 4-->
12565 <a name="7.12.11.2" href="#7.12.11.2"><h5>7.12.11.2 The nan functions</h5></a>
12569 #include <math.h>
12570 double nan(const char *tagp);
12571 float nanf(const char *tagp);
12572 long double nanl(const char *tagp);</pre>
12573 <h6>Description</h6>
12575 The call nan("n-char-sequence") is equivalent to strtod("NAN(n-char-
12576 sequence)", (char**) NULL); the call nan("") is equivalent to
12577 strtod("NAN()", (char**) NULL). If tagp does not point to an n-char
12578 sequence or an empty string, the call is equivalent to strtod("NAN", (char**)
12579 NULL). Calls to nanf and nanl are equivalent to the corresponding calls to strtof
12583 The nan functions return a quiet NaN, if available, with content indicated through tagp.
12584 If the implementation does not support quiet NaNs, the functions return zero.
12585 Forward references: the strtod, strtof, and strtold functions (<a href="#7.22.1.3">7.22.1.3</a>).
12587 <a name="7.12.11.3" href="#7.12.11.3"><h5>7.12.11.3 The nextafter functions</h5></a>
12591 #include <math.h>
12592 double nextafter(double x, double y);
12593 float nextafterf(float x, float y);
12594 long double nextafterl(long double x, long double y);</pre>
12595 <h6>Description</h6>
12597 The nextafter functions determine the next representable value, in the type of the
12598 function, after x in the direction of y, where x and y are first converted to the type of the
12599 function.<sup><a href="#note237"><b>237)</b></a></sup> The nextafter functions return y if x equals y. A range error may occur
12600 if the magnitude of x is the largest finite value representable in the type and the result is
12601 infinite or not representable in the type.
12604 The nextafter functions return the next representable value in the specified format
12605 after x in the direction of y.
12608 <!--page 274 indent 4-->
12611 <p><a name="note237">237)</a> The argument values are converted to the type of the function, even by a macro implementation of the
12615 <a name="7.12.11.4" href="#7.12.11.4"><h5>7.12.11.4 The nexttoward functions</h5></a>
12619 #include <math.h>
12620 double nexttoward(double x, long double y);
12621 float nexttowardf(float x, long double y);
12622 long double nexttowardl(long double x, long double y);</pre>
12623 <h6>Description</h6>
12625 The nexttoward functions are equivalent to the nextafter functions except that the
12626 second parameter has type long double and the functions return y converted to the
12627 type of the function if x equals y.<sup><a href="#note238"><b>238)</b></a></sup>
12630 <p><a name="note238">238)</a> The result of the nexttoward functions is determined in the type of the function, without loss of
12631 range or precision in a floating second argument.
12634 <a name="7.12.12" href="#7.12.12"><h4>7.12.12 Maximum, minimum, and positive difference functions</h4></a>
12636 <a name="7.12.12.1" href="#7.12.12.1"><h5>7.12.12.1 The fdim functions</h5></a>
12640 #include <math.h>
12641 double fdim(double x, double y);
12642 float fdimf(float x, float y);
12643 long double fdiml(long double x, long double y);</pre>
12644 <h6>Description</h6>
12646 The fdim functions determine the positive difference between their arguments:
12650 {+0 if x <= y</pre>
12651 A range error may occur.
12654 The fdim functions return the positive difference value.
12656 <a name="7.12.12.2" href="#7.12.12.2"><h5>7.12.12.2 The fmax functions</h5></a>
12660 #include <math.h>
12661 double fmax(double x, double y);
12662 float fmaxf(float x, float y);
12663 long double fmaxl(long double x, long double y);</pre>
12667 <!--page 275 indent 4-->
12668 <h6>Description</h6>
12670 The fmax functions determine the maximum numeric value of their arguments.<sup><a href="#note239"><b>239)</b></a></sup>
12673 The fmax functions return the maximum numeric value of their arguments.
12676 <p><a name="note239">239)</a> NaN arguments are treated as missing data: if one argument is a NaN and the other numeric, then the
12677 fmax functions choose the numeric value. See <a href="#F.10.9.2">F.10.9.2</a>.
12680 <a name="7.12.12.3" href="#7.12.12.3"><h5>7.12.12.3 The fmin functions</h5></a>
12684 #include <math.h>
12685 double fmin(double x, double y);
12686 float fminf(float x, float y);
12687 long double fminl(long double x, long double y);</pre>
12688 <h6>Description</h6>
12690 The fmin functions determine the minimum numeric value of their arguments.<sup><a href="#note240"><b>240)</b></a></sup>
12693 The fmin functions return the minimum numeric value of their arguments.
12696 <p><a name="note240">240)</a> The fmin functions are analogous to the fmax functions in their treatment of NaNs.
12699 <a name="7.12.13" href="#7.12.13"><h4>7.12.13 Floating multiply-add</h4></a>
12701 <a name="7.12.13.1" href="#7.12.13.1"><h5>7.12.13.1 The fma functions</h5></a>
12705 #include <math.h>
12706 double fma(double x, double y, double z);
12707 float fmaf(float x, float y, float z);
12708 long double fmal(long double x, long double y,
12709 long double z);</pre>
12710 <h6>Description</h6>
12712 The fma functions compute (x x y) + z, rounded as one ternary operation: they compute
12713 the value (as if) to infinite precision and round once to the result format, according to the
12714 current rounding mode. A range error may occur.
12717 The fma functions return (x x y) + z, rounded as one ternary operation.
12722 <!--page 276 indent 4-->
12724 <a name="7.12.14" href="#7.12.14"><h4>7.12.14 Comparison macros</h4></a>
12726 The relational and equality operators support the usual mathematical relationships
12727 between numeric values. For any ordered pair of numeric values exactly one of the
12728 relationships -- less, greater, and equal -- is true. Relational operators may raise the
12729 ''invalid'' floating-point exception when argument values are NaNs. For a NaN and a
12730 numeric value, or for two NaNs, just the unordered relationship is true.<sup><a href="#note241"><b>241)</b></a></sup> The following
12731 subclauses provide macros that are quiet (non floating-point exception raising) versions
12732 of the relational operators, and other comparison macros that facilitate writing efficient
12733 code that accounts for NaNs without suffering the ''invalid'' floating-point exception. In
12734 the synopses in this subclause, real-floating indicates that the argument shall be an
12735 expression of real floating type<sup><a href="#note242"><b>242)</b></a></sup> (both arguments need not have the same type).<sup><a href="#note243"><b>243)</b></a></sup>
12738 <p><a name="note241">241)</a> IEC 60559 requires that the built-in relational operators raise the ''invalid'' floating-point exception if
12739 the operands compare unordered, as an error indicator for programs written without consideration of
12740 NaNs; the result in these cases is false.
12742 <p><a name="note242">242)</a> If any argument is of integer type, or any other type that is not a real floating type, the behavior is
12745 <p><a name="note243">243)</a> Whether an argument represented in a format wider than its semantic type is converted to the semantic
12746 type is unspecified.
12749 <a name="7.12.14.1" href="#7.12.14.1"><h5>7.12.14.1 The isgreater macro</h5></a>
12753 #include <math.h>
12754 int isgreater(real-floating x, real-floating y);</pre>
12755 <h6>Description</h6>
12757 The isgreater macro determines whether its first argument is greater than its second
12758 argument. The value of isgreater(x, y) is always equal to (x) > (y); however,
12759 unlike (x) > (y), isgreater(x, y) does not raise the ''invalid'' floating-point
12760 exception when x and y are unordered.
12763 The isgreater macro returns the value of (x) > (y).
12765 <a name="7.12.14.2" href="#7.12.14.2"><h5>7.12.14.2 The isgreaterequal macro</h5></a>
12769 #include <math.h>
12770 int isgreaterequal(real-floating x, real-floating y);</pre>
12775 <!--page 277 indent 4-->
12776 <h6>Description</h6>
12778 The isgreaterequal macro determines whether its first argument is greater than or
12779 equal to its second argument. The value of isgreaterequal(x, y) is always equal
12780 to (x) >= (y); however, unlike (x) >= (y), isgreaterequal(x, y) does
12781 not raise the ''invalid'' floating-point exception when x and y are unordered.
12784 The isgreaterequal macro returns the value of (x) >= (y).
12786 <a name="7.12.14.3" href="#7.12.14.3"><h5>7.12.14.3 The isless macro</h5></a>
12790 #include <math.h>
12791 int isless(real-floating x, real-floating y);</pre>
12792 <h6>Description</h6>
12794 The isless macro determines whether its first argument is less than its second
12795 argument. The value of isless(x, y) is always equal to (x) < (y); however,
12796 unlike (x) < (y), isless(x, y) does not raise the ''invalid'' floating-point
12797 exception when x and y are unordered.
12800 The isless macro returns the value of (x) < (y).
12802 <a name="7.12.14.4" href="#7.12.14.4"><h5>7.12.14.4 The islessequal macro</h5></a>
12806 #include <math.h>
12807 int islessequal(real-floating x, real-floating y);</pre>
12808 <h6>Description</h6>
12810 The islessequal macro determines whether its first argument is less than or equal to
12811 its second argument. The value of islessequal(x, y) is always equal to
12812 (x) <= (y); however, unlike (x) <= (y), islessequal(x, y) does not raise
12813 the ''invalid'' floating-point exception when x and y are unordered.
12816 The islessequal macro returns the value of (x) <= (y).
12817 <!--page 278 indent 4-->
12819 <a name="7.12.14.5" href="#7.12.14.5"><h5>7.12.14.5 The islessgreater macro</h5></a>
12823 #include <math.h>
12824 int islessgreater(real-floating x, real-floating y);</pre>
12825 <h6>Description</h6>
12827 The islessgreater macro determines whether its first argument is less than or
12828 greater than its second argument. The islessgreater(x, y) macro is similar to
12829 (x) < (y) || (x) > (y); however, islessgreater(x, y) does not raise
12830 the ''invalid'' floating-point exception when x and y are unordered (nor does it evaluate x
12834 The islessgreater macro returns the value of (x) < (y) || (x) > (y).
12836 <a name="7.12.14.6" href="#7.12.14.6"><h5>7.12.14.6 The isunordered macro</h5></a>
12840 #include <math.h>
12841 int isunordered(real-floating x, real-floating y);</pre>
12842 <h6>Description</h6>
12844 The isunordered macro determines whether its arguments are unordered.
12847 The isunordered macro returns 1 if its arguments are unordered and 0 otherwise.
12848 <!--page 279 indent 4-->
12850 <a name="7.13" href="#7.13"><h3>7.13 Nonlocal jumps <setjmp.h></h3></a>
12852 The header <setjmp.h> defines the macro setjmp, and declares one function and
12853 one type, for bypassing the normal function call and return discipline.<sup><a href="#note244"><b>244)</b></a></sup>
12855 The type declared is
12858 which is an array type suitable for holding the information needed to restore a calling
12859 environment. The environment of a call to the setjmp macro consists of information
12860 sufficient for a call to the longjmp function to return execution to the correct block and
12861 invocation of that block, were it called recursively. It does not include the state of the
12862 floating-point status flags, of open files, or of any other component of the abstract
12865 It is unspecified whether setjmp is a macro or an identifier declared with external
12866 linkage. If a macro definition is suppressed in order to access an actual function, or a
12867 program defines an external identifier with the name setjmp, the behavior is undefined.
12870 <p><a name="note244">244)</a> These functions are useful for dealing with unusual conditions encountered in a low-level function of
12874 <a name="7.13.1" href="#7.13.1"><h4>7.13.1 Save calling environment</h4></a>
12876 <a name="7.13.1.1" href="#7.13.1.1"><h5>7.13.1.1 The setjmp macro</h5></a>
12880 #include <setjmp.h>
12881 int setjmp(jmp_buf env);</pre>
12882 <h6>Description</h6>
12884 The setjmp macro saves its calling environment in its jmp_buf argument for later use
12885 by the longjmp function.
12888 If the return is from a direct invocation, the setjmp macro returns the value zero. If the
12889 return is from a call to the longjmp function, the setjmp macro returns a nonzero
12891 Environmental limits
12893 An invocation of the setjmp macro shall appear only in one of the following contexts:
12895 <li> the entire controlling expression of a selection or iteration statement;
12896 <li> one operand of a relational or equality operator with the other operand an integer
12897 constant expression, with the resulting expression being the entire controlling
12900 <!--page 280 indent 4-->
12901 expression of a selection or iteration statement;
12902 <li> the operand of a unary ! operator with the resulting expression being the entire
12903 controlling expression of a selection or iteration statement; or
12904 <li> the entire expression of an expression statement (possibly cast to void).
12907 If the invocation appears in any other context, the behavior is undefined.
12909 <a name="7.13.2" href="#7.13.2"><h4>7.13.2 Restore calling environment</h4></a>
12911 <a name="7.13.2.1" href="#7.13.2.1"><h5>7.13.2.1 The longjmp function</h5></a>
12915 #include <setjmp.h>
12916 _Noreturn void longjmp(jmp_buf env, int val);</pre>
12917 <h6>Description</h6>
12919 The longjmp function restores the environment saved by the most recent invocation of
12920 the setjmp macro in the same invocation of the program with the corresponding
12921 jmp_buf argument. If there has been no such invocation, or if the function containing
12922 the invocation of the setjmp macro has terminated execution<sup><a href="#note245"><b>245)</b></a></sup> in the interim, or if the
12923 invocation of the setjmp macro was within the scope of an identifier with variably
12924 modified type and execution has left that scope in the interim, the behavior is undefined.
12926 All accessible objects have values, and all other components of the abstract machine<sup><a href="#note246"><b>246)</b></a></sup>
12927 have state, as of the time the longjmp function was called, except that the values of
12928 objects of automatic storage duration that are local to the function containing the
12929 invocation of the corresponding setjmp macro that do not have volatile-qualified type
12930 and have been changed between the setjmp invocation and longjmp call are
12934 After longjmp is completed, program execution continues as if the corresponding
12935 invocation of the setjmp macro had just returned the value specified by val. The
12936 longjmp function cannot cause the setjmp macro to return the value 0; if val is 0,
12937 the setjmp macro returns the value 1.
12939 EXAMPLE The longjmp function that returns control back to the point of the setjmp invocation
12940 might cause memory associated with a variable length array object to be squandered.
12945 <!--page 281 indent -1-->
12946 <!--page 282 indent 4-->
12948 #include <setjmp.h>
12955 int x[n]; // valid: f is not terminated
12961 int a[n]; // a may remain allocated
12966 int b[n]; // b may remain allocated
12967 longjmp(buf, 2); // might cause memory loss
12971 <p><a name="note245">245)</a> For example, by executing a return statement or because another longjmp call has caused a
12972 transfer to a setjmp invocation in a function earlier in the set of nested calls.
12974 <p><a name="note246">246)</a> This includes, but is not limited to, the floating-point status flags and the state of open files.
12977 <a name="7.14" href="#7.14"><h3>7.14 Signal handling <signal.h></h3></a>
12979 The header <signal.h> declares a type and two functions and defines several macros,
12980 for handling various signals (conditions that may be reported during program execution).
12982 The type defined is
12985 which is the (possibly volatile-qualified) integer type of an object that can be accessed as
12986 an atomic entity, even in the presence of asynchronous interrupts.
12988 The macros defined are
12993 which expand to constant expressions with distinct values that have type compatible with
12994 the second argument to, and the return value of, the signal function, and whose values
12995 compare unequal to the address of any declarable function; and the following, which
12996 expand to positive integer constant expressions with type int and distinct values that are
12997 the signal numbers, each corresponding to the specified condition:
13000 SIGABRT abnormal termination, such as is initiated by the abort function
13001 SIGFPE an erroneous arithmetic operation, such as zero divide or an operation
13002 resulting in overflow
13003 SIGILL detection of an invalid function image, such as an invalid instruction
13004 SIGINT receipt of an interactive attention signal
13005 SIGSEGV an invalid access to storage
13006 SIGTERM a termination request sent to the program</pre>
13007 An implementation need not generate any of these signals, except as a result of explicit
13008 calls to the raise function. Additional signals and pointers to undeclarable functions,
13009 with macro definitions beginning, respectively, with the letters SIG and an uppercase
13010 letter or with SIG_ and an uppercase letter,<sup><a href="#note247"><b>247)</b></a></sup> may also be specified by the
13011 implementation. The complete set of signals, their semantics, and their default handling
13012 is implementation-defined; all signal numbers shall be positive.
13017 <!--page 283 indent 4-->
13020 <p><a name="note247">247)</a> See ''future library directions'' (<a href="#7.30.6">7.30.6</a>). The names of the signal numbers reflect the following terms
13021 (respectively): abort, floating-point exception, illegal instruction, interrupt, segmentation violation,
13025 <a name="7.14.1" href="#7.14.1"><h4>7.14.1 Specify signal handling</h4></a>
13027 <a name="7.14.1.1" href="#7.14.1.1"><h5>7.14.1.1 The signal function</h5></a>
13031 #include <signal.h>
13032 void (*signal(int sig, void (*func)(int)))(int);</pre>
13033 <h6>Description</h6>
13035 The signal function chooses one of three ways in which receipt of the signal number
13036 sig is to be subsequently handled. If the value of func is SIG_DFL, default handling
13037 for that signal will occur. If the value of func is SIG_IGN, the signal will be ignored.
13038 Otherwise, func shall point to a function to be called when that signal occurs. An
13039 invocation of such a function because of a signal, or (recursively) of any further functions
13040 called by that invocation (other than functions in the standard library),<sup><a href="#note248"><b>248)</b></a></sup> is called a
13043 When a signal occurs and func points to a function, it is implementation-defined
13044 whether the equivalent of signal(sig, SIG_DFL); is executed or the
13045 implementation prevents some implementation-defined set of signals (at least including
13046 sig) from occurring until the current signal handling has completed; in the case of
13047 SIGILL, the implementation may alternatively define that no action is taken. Then the
13048 equivalent of (*func)(sig); is executed. If and when the function returns, if the
13049 value of sig is SIGFPE, SIGILL, SIGSEGV, or any other implementation-defined
13050 value corresponding to a computational exception, the behavior is undefined; otherwise
13051 the program will resume execution at the point it was interrupted.
13053 If the signal occurs as the result of calling the abort or raise function, the signal
13054 handler shall not call the raise function.
13056 If the signal occurs other than as the result of calling the abort or raise function, the
13057 behavior is undefined if the signal handler refers to any object with static or thread
13058 storage duration that is not a lock-free atomic object other than by assigning a value to an
13059 object declared as volatile sig_atomic_t, or the signal handler calls any function
13060 in the standard library other than the abort function, the _Exit function, the
13061 quick_exit function, or the signal function with the first argument equal to the
13062 signal number corresponding to the signal that caused the invocation of the handler.
13063 Furthermore, if such a call to the signal function results in a SIG_ERR return, the
13064 value of errno is indeterminate.<sup><a href="#note249"><b>249)</b></a></sup>
13067 <!--page 284 indent 4-->
13069 At program startup, the equivalent of
13071 signal(sig, SIG_IGN);</pre>
13072 may be executed for some signals selected in an implementation-defined manner; the
13075 signal(sig, SIG_DFL);</pre>
13076 is executed for all other signals defined by the implementation.
13078 The implementation shall behave as if no library function calls the signal function.
13081 If the request can be honored, the signal function returns the value of func for the
13082 most recent successful call to signal for the specified signal sig. Otherwise, a value of
13083 SIG_ERR is returned and a positive value is stored in errno.
13084 Forward references: the abort function (<a href="#7.22.4.1">7.22.4.1</a>), the exit function (<a href="#7.22.4.4">7.22.4.4</a>), the
13085 _Exit function (<a href="#7.22.4.5">7.22.4.5</a>), the quick_exit function (<a href="#7.22.4.7">7.22.4.7</a>).
13088 <p><a name="note248">248)</a> This includes functions called indirectly via standard library functions (e.g., a SIGABRT handler
13089 called via the abort function).
13091 <p><a name="note249">249)</a> If any signal is generated by an asynchronous signal handler, the behavior is undefined.
13094 <a name="7.14.2" href="#7.14.2"><h4>7.14.2 Send signal</h4></a>
13096 <a name="7.14.2.1" href="#7.14.2.1"><h5>7.14.2.1 The raise function</h5></a>
13100 #include <signal.h>
13101 int raise(int sig);</pre>
13102 <h6>Description</h6>
13104 The raise function carries out the actions described in <a href="#7.14.1.1">7.14.1.1</a> for the signal sig. If a
13105 signal handler is called, the raise function shall not return until after the signal handler
13109 The raise function returns zero if successful, nonzero if unsuccessful.
13110 <!--page 285 indent 4-->
13112 <a name="7.15" href="#7.15"><h3>7.15 Alignment <stdalign.h></h3></a>
13114 The header <stdalign.h> defines two macros.
13119 expands to _Alignas.
13121 The remaining macro is suitable for use in #if preprocessing directives. It is
13123 __alignas_is_defined</pre>
13124 which expands to the integer constant 1.
13125 <!--page 286 indent 4-->
13127 <a name="7.16" href="#7.16"><h3>7.16 Variable arguments <stdarg.h></h3></a>
13129 The header <stdarg.h> declares a type and defines four macros, for advancing
13130 through a list of arguments whose number and types are not known to the called function
13131 when it is translated.
13133 A function may be called with a variable number of arguments of varying types. As
13134 described in <a href="#6.9.1">6.9.1</a>, its parameter list contains one or more parameters. The rightmost
13135 parameter plays a special role in the access mechanism, and will be designated parmN in
13138 The type declared is
13141 which is a complete object type suitable for holding information needed by the macros
13142 va_start, va_arg, va_end, and va_copy. If access to the varying arguments is
13143 desired, the called function shall declare an object (generally referred to as ap in this
13144 subclause) having type va_list. The object ap may be passed as an argument to
13145 another function; if that function invokes the va_arg macro with parameter ap, the
13146 value of ap in the calling function is indeterminate and shall be passed to the va_end
13147 macro prior to any further reference to ap.<sup><a href="#note250"><b>250)</b></a></sup>
13150 <p><a name="note250">250)</a> It is permitted to create a pointer to a va_list and pass that pointer to another function, in which
13151 case the original function may make further use of the original list after the other function returns.
13154 <a name="7.16.1" href="#7.16.1"><h4>7.16.1 Variable argument list access macros</h4></a>
13156 The va_start and va_arg macros described in this subclause shall be implemented
13157 as macros, not functions. It is unspecified whether va_copy and va_end are macros or
13158 identifiers declared with external linkage. If a macro definition is suppressed in order to
13159 access an actual function, or a program defines an external identifier with the same name,
13160 the behavior is undefined. Each invocation of the va_start and va_copy macros
13161 shall be matched by a corresponding invocation of the va_end macro in the same
13164 <a name="7.16.1.1" href="#7.16.1.1"><h5>7.16.1.1 The va_arg macro</h5></a>
13168 #include <stdarg.h>
13169 type va_arg(va_list ap, type);</pre>
13170 <h6>Description</h6>
13172 The va_arg macro expands to an expression that has the specified type and the value of
13173 the next argument in the call. The parameter ap shall have been initialized by the
13174 va_start or va_copy macro (without an intervening invocation of the va_end
13176 <!--page 287 indent 4-->
13177 macro for the same ap). Each invocation of the va_arg macro modifies ap so that the
13178 values of successive arguments are returned in turn. The parameter type shall be a type
13179 name specified such that the type of a pointer to an object that has the specified type can
13180 be obtained simply by postfixing a * to type. If there is no actual next argument, or if
13181 type is not compatible with the type of the actual next argument (as promoted according
13182 to the default argument promotions), the behavior is undefined, except for the following
13185 <li> one type is a signed integer type, the other type is the corresponding unsigned integer
13186 type, and the value is representable in both types;
13187 <li> one type is pointer to void and the other is a pointer to a character type.
13191 The first invocation of the va_arg macro after that of the va_start macro returns the
13192 value of the argument after that specified by parmN . Successive invocations return the
13193 values of the remaining arguments in succession.
13195 <a name="7.16.1.2" href="#7.16.1.2"><h5>7.16.1.2 The va_copy macro</h5></a>
13199 #include <stdarg.h>
13200 void va_copy(va_list dest, va_list src);</pre>
13201 <h6>Description</h6>
13203 The va_copy macro initializes dest as a copy of src, as if the va_start macro had
13204 been applied to dest followed by the same sequence of uses of the va_arg macro as
13205 had previously been used to reach the present state of src. Neither the va_copy nor
13206 va_start macro shall be invoked to reinitialize dest without an intervening
13207 invocation of the va_end macro for the same dest.
13210 The va_copy macro returns no value.
13212 <a name="7.16.1.3" href="#7.16.1.3"><h5>7.16.1.3 The va_end macro</h5></a>
13216 #include <stdarg.h>
13217 void va_end(va_list ap);</pre>
13218 <h6>Description</h6>
13220 The va_end macro facilitates a normal return from the function whose variable
13221 argument list was referred to by the expansion of the va_start macro, or the function
13222 containing the expansion of the va_copy macro, that initialized the va_list ap. The
13223 va_end macro may modify ap so that it is no longer usable (without being reinitialized
13224 <!--page 288 indent 4-->
13225 by the va_start or va_copy macro). If there is no corresponding invocation of the
13226 va_start or va_copy macro, or if the va_end macro is not invoked before the
13227 return, the behavior is undefined.
13230 The va_end macro returns no value.
13232 <a name="7.16.1.4" href="#7.16.1.4"><h5>7.16.1.4 The va_start macro</h5></a>
13236 #include <stdarg.h>
13237 void va_start(va_list ap, parmN);</pre>
13238 <h6>Description</h6>
13240 The va_start macro shall be invoked before any access to the unnamed arguments.
13242 The va_start macro initializes ap for subsequent use by the va_arg and va_end
13243 macros. Neither the va_start nor va_copy macro shall be invoked to reinitialize ap
13244 without an intervening invocation of the va_end macro for the same ap.
13246 The parameter parmN is the identifier of the rightmost parameter in the variable
13247 parameter list in the function definition (the one just before the , ...). If the parameter
13248 parmN is declared with the register storage class, with a function or array type, or
13249 with a type that is not compatible with the type that results after application of the default
13250 argument promotions, the behavior is undefined.
13253 The va_start macro returns no value.
13255 EXAMPLE 1 The function f1 gathers into an array a list of arguments that are pointers to strings (but not
13256 more than MAXARGS arguments), then passes the array as a single argument to function f2. The number of
13257 pointers is specified by the first argument to f1.
13258 <!--page 289 indent 4-->
13260 #include <stdarg.h>
13262 void f1(int n_ptrs, ...)
13265 char *array[MAXARGS];
13267 if (n_ptrs > MAXARGS)
13269 va_start(ap, n_ptrs);
13270 while (ptr_no < n_ptrs)
13271 array[ptr_no++] = va_arg(ap, char *);
13275 Each call to f1 is required to have visible the definition of the function or a declaration such as
13277 void f1(int, ...);</pre>
13280 EXAMPLE 2 The function f3 is similar, but saves the status of the variable argument list after the
13281 indicated number of arguments; after f2 has been called once with the whole list, the trailing part of the list
13282 is gathered again and passed to function f4.
13283 <!--page 290 indent 4-->
13285 #include <stdarg.h>
13287 void f3(int n_ptrs, int f4_after, ...)
13289 va_list ap, ap_save;
13290 char *array[MAXARGS];
13292 if (n_ptrs > MAXARGS)
13294 va_start(ap, f4_after);
13295 while (ptr_no < n_ptrs) {
13296 array[ptr_no++] = va_arg(ap, char *);
13297 if (ptr_no == f4_after)
13298 va_copy(ap_save, ap);
13302 // Now process the saved copy.
13303 n_ptrs -= f4_after;
13305 while (ptr_no < n_ptrs)
13306 array[ptr_no++] = va_arg(ap_save, char *);
13311 <a name="7.17" href="#7.17"><h3>7.17 Atomics <stdatomic.h></h3></a>
13313 <a name="7.17.1" href="#7.17.1"><h4>7.17.1 Introduction</h4></a>
13315 The header <stdatomic.h> defines several macros and declares several types and
13316 functions for performing atomic operations on data shared between threads.
13318 Implementations that define the macro __STDC_NO_THREADS__ need not provide
13319 this header nor support any of its facilities.
13321 The macros defined are the atomic lock-free macros
13323 ATOMIC_CHAR_LOCK_FREE
13324 ATOMIC_CHAR16_T_LOCK_FREE
13325 ATOMIC_CHAR32_T_LOCK_FREE
13326 ATOMIC_WCHAR_T_LOCK_FREE
13327 ATOMIC_SHORT_LOCK_FREE
13328 ATOMIC_INT_LOCK_FREE
13329 ATOMIC_LONG_LOCK_FREE
13330 ATOMIC_LLONG_LOCK_FREE
13331 ATOMIC_ADDRESS_LOCK_FREE</pre>
13332 which indicate the lock-free property of the corresponding atomic types (both signed and
13335 ATOMIC_FLAG_INIT</pre>
13336 which expands to an initializer for an object of type atomic_flag.
13341 which is an enumerated type whose enumerators identify memory ordering constraints;
13344 which is a structure type representing a lock-free, primitive atomic flag;
13347 which is a structure type representing the atomic analog of the type _Bool;
13349 atomic_address</pre>
13350 which is a structure type representing the atomic analog of a pointer type; and several
13351 atomic analogs of integer types.
13353 In the following operation definitions:
13355 <li> An A refers to one of the atomic types.
13356 <!--page 291 indent 4-->
13357 <li> A C refers to its corresponding non-atomic type. The atomic_address atomic
13358 type corresponds to the void * non-atomic type.
13359 <li> An M refers to the type of the other argument for arithmetic operations. For atomic
13360 integer types, M is C. For atomic address types, M is ptrdiff_t.
13361 <li> The functions not ending in _explicit have the same semantics as the
13362 corresponding _explicit function with memory_order_seq_cst for the
13363 memory_order argument.
13366 NOTE Many operations are volatile-qualified. The ''volatile as device register'' semantics have not
13367 changed in the standard. This qualification means that volatility is preserved when applying these
13368 operations to volatile objects.
13371 <a name="7.17.2" href="#7.17.2"><h4>7.17.2 Initialization</h4></a>
13373 <a name="7.17.2.1" href="#7.17.2.1"><h5>7.17.2.1 The ATOMIC_VAR_INIT macro</h5></a>
13377 #include <stdatomic.h>
13378 #define ATOMIC_VAR_INIT(C value)</pre>
13379 <h6>Description</h6>
13381 The ATOMIC_VAR_INIT macro expands to a token sequence suitable for initializing an
13382 atomic object of a type that is initialization-compatible with value. An atomic object
13383 with automatic storage duration that is not explicitly initialized using
13384 ATOMIC_VAR_INIT is initially in an indeterminate state; however, the default (zero)
13385 initialization for objects with static or thread-local storage duration is guaranteed to
13386 produce a valid state.
13388 Concurrent access to the variable being initialized, even via an atomic operation,
13389 constitutes a data race.
13393 atomic_int guide = ATOMIC_VAR_INIT(42);</pre>
13396 <a name="7.17.2.2" href="#7.17.2.2"><h5>7.17.2.2 The atomic_init generic function</h5></a>
13400 #include <stdatomic.h>
13401 void atomic_init(volatile A *obj, C value);</pre>
13402 <h6>Description</h6>
13404 The atomic_init generic function initializes the atomic object pointed to by obj to
13405 the value value, while also initializing any additional state that the implementation
13406 might need to carry for the atomic object.
13407 <!--page 292 indent 4-->
13409 Although this function initializes an atomic object, it does not avoid data races;
13410 concurrent access to the variable being initialized, even via an atomic operation,
13411 constitutes a data race.
13414 The atomic_init generic function returns no value.
13419 atomic_init(&guide, 42);</pre>
13422 <a name="7.17.3" href="#7.17.3"><h4>7.17.3 Order and consistency</h4></a>
13424 The enumerated type memory_order specifies the detailed regular (non-atomic)
13425 memory synchronization operations as defined in <a href="#5.1.2.4">5.1.2.4</a> and may provide for operation
13426 ordering. Its enumeration constants are as follows:
13429 memory_order_relaxed
13430 memory_order_consume
13431 memory_order_acquire
13432 memory_order_release
13433 memory_order_acq_rel
13434 memory_order_seq_cst</pre>
13435 For memory_order_relaxed, no operation orders memory.
13437 For memory_order_release, memory_order_acq_rel, and
13438 memory_order_seq_cst, a store operation performs a release operation on the
13439 affected memory location.
13441 For memory_order_acquire, memory_order_acq_rel, and
13442 memory_order_seq_cst, a load operation performs an acquire operation on the
13443 affected memory location.
13445 For memory_order_consume, a load operation performs a consume operation on the
13446 affected memory location.
13448 For memory_order_seq_cst, there shall be a single total order S on all operations,
13449 consistent with the ''happens before'' order and modification orders for all affected
13450 locations, such that each memory_order_seq_cst operation that loads a value
13451 observes either the last preceding modification according to this order S, or the result of
13452 an operation that is not memory_order_seq_cst.
13454 NOTE 1 Although it is not explicitly required that S include lock operations, it can always be extended to
13455 an order that does include lock and unlock operations, since the ordering between those is already included
13456 in the ''happens before'' ordering.
13459 NOTE 2 Atomic operations specifying memory_order_relaxed are relaxed only with respect to
13460 memory ordering. Implementations must still guarantee that any given atomic access to a particular atomic
13461 <!--page 293 indent 5-->
13462 object be indivisible with respect to all other atomic accesses to that object.
13465 For an atomic operation B that reads the value of an atomic object M, if there is a
13466 memory_order_seq_cst fence X sequenced before B, then B observes either the
13467 last memory_order_seq_cst modification of M preceding X in the total order S or
13468 a later modification of M in its modification order.
13470 For atomic operations A and B on an atomic object M, where A modifies M and B takes
13471 its value, if there is a memory_order_seq_cst fence X such that A is sequenced
13472 before X and B follows X in S, then B observes either the effects of A or a later
13473 modification of M in its modification order.
13475 For atomic operations A and B on an atomic object M, where A modifies M and B takes
13476 its value, if there are memory_order_seq_cst fences X and Y such that A is
13477 sequenced before X, Y is sequenced before B, and X precedes Y in S, then B observes
13478 either the effects of A or a later modification of M in its modification order.
13480 Atomic read-modify-write operations shall always read the last value (in the modification
13481 order) stored before the write associated with the read-modify-write operation.
13483 An atomic store shall only store a value that has been computed from constants and
13484 program input values by a finite sequence of program evaluations, such that each
13485 evaluation observes the values of variables as computed by the last prior assignment in
13486 the sequence.<sup><a href="#note251"><b>251)</b></a></sup> The ordering of evaluations in this sequence shall be such that
13488 <li> If an evaluation B observes a value computed by A in a different thread, then B does
13489 not happen before A.
13490 <li> If an evaluation A is included in the sequence, then all evaluations that assign to the
13491 same variable and happen before A are also included.
13494 NOTE 3 The second requirement disallows ''out-of-thin-air'', or ''speculative'' stores of atomics when
13495 relaxed atomics are used. Since unordered operations are involved, evaluations may appear in this
13496 sequence out of thread order. For example, with x and y initially zero,
13499 r1 = atomic_load_explicit(&y, memory_order_relaxed);
13500 atomic_store_explicit(&x, r1, memory_order_relaxed);</pre>
13504 r2 = atomic_load_explicit(&x, memory_order_relaxed);
13505 atomic_store_explicit(&y, 42, memory_order_relaxed);</pre>
13506 is allowed to produce r1 == 42 && r2 == 42. The sequence of evaluations justifying this consists of:
13511 <!--page 294 indent 5-->
13513 atomic_store_explicit(&y, 42, memory_order_relaxed);
13514 r1 = atomic_load_explicit(&y, memory_order_relaxed);
13515 atomic_store_explicit(&x, r1, memory_order_relaxed);
13516 r2 = atomic_load_explicit(&x, memory_order_relaxed);</pre>
13520 r1 = atomic_load_explicit(&y, memory_order_relaxed);
13521 atomic_store_explicit(&x, r1, memory_order_relaxed);</pre>
13525 r2 = atomic_load_explicit(&x, memory_order_relaxed);
13526 atomic_store_explicit(&y, r2, memory_order_relaxed);</pre>
13527 is not allowed to produce r1 == 42 && r2 = 42, since there is no sequence of evaluations that results
13528 in the computation of 42. In the absence of ''relaxed'' operations and read-modify-write operations with
13529 weaker than memory_order_acq_rel ordering, the second requirement has no impact.
13531 Recommended practice
13533 The requirements do not forbid r1 == 42 && r2 == 42 in the following example,
13534 with x and y initially zero:
13537 r1 = atomic_load_explicit(&x, memory_order_relaxed);
13539 atomic_store_explicit(&y, r1, memory_order_relaxed);</pre>
13543 r2 = atomic_load_explicit(&y, memory_order_relaxed);
13545 atomic_store_explicit(&x, 42, memory_order_relaxed);</pre>
13546 However, this is not useful behavior, and implementations should not allow it.
13548 Implementations should make atomic stores visible to atomic loads within a reasonable
13552 <p><a name="note251">251)</a> Among other implications, atomic variables shall not decay.
13555 <a name="7.17.3.1" href="#7.17.3.1"><h5>7.17.3.1 The kill_dependency macro</h5></a>
13559 #include <stdatomic.h>
13560 type kill_dependency(type y);</pre>
13561 <h6>Description</h6>
13563 The kill_dependency macro terminates a dependency chain; the argument does not
13564 carry a dependency to the return value.
13565 <!--page 295 indent 4-->
13568 The kill_dependency macro returns the value of y.
13570 <a name="7.17.4" href="#7.17.4"><h4>7.17.4 Fences</h4></a>
13572 This subclause introduces synchronization primitives called fences. Fences can have
13573 acquire semantics, release semantics, or both. A fence with acquire semantics is called
13574 an acquire fence; a fence with release semantics is called a release fence.
13576 A release fence A synchronizes with an acquire fence B if there exist atomic operations
13577 X and Y , both operating on some atomic object M, such that A is sequenced before X, X
13578 modifies M, Y is sequenced before B, and Y reads the value written by X or a value
13579 written by any side effect in the hypothetical release sequence X would head if it were a
13582 A release fence A synchronizes with an atomic operation B that performs an acquire
13583 operation on an atomic object M if there exists an atomic operation X such that A is
13584 sequenced before X, X modifies M, and B reads the value written by X or a value written
13585 by any side effect in the hypothetical release sequence X would head if it were a release
13588 An atomic operation A that is a release operation on an atomic object M synchronizes
13589 with an acquire fence B if there exists some atomic operation X on M such that X is
13590 sequenced before B and reads the value written by A or a value written by any side effect
13591 in the release sequence headed by A.
13593 <a name="7.17.4.1" href="#7.17.4.1"><h5>7.17.4.1 The atomic_thread_fence function</h5></a>
13597 #include <stdatomic.h>
13598 void atomic_thread_fence(memory_order order);</pre>
13599 <h6>Description</h6>
13601 Depending on the value of order, this operation:
13603 <li> has no effects, if order == memory_order_relaxed;
13604 <li> is an acquire fence, if order == memory_order_acquire or order ==
13605 memory_order_consume;
13606 <li> is a release fence, if order == memory_order_release;
13607 <li> is both an acquire fence and a release fence, if order ==
13608 memory_order_acq_rel;
13609 <li> is a sequentially consistent acquire and release fence, if order ==
13610 memory_order_seq_cst.
13611 <!--page 296 indent 4-->
13615 The atomic_thread_fence function returns no value.
13617 <a name="7.17.4.2" href="#7.17.4.2"><h5>7.17.4.2 The atomic_signal_fence function</h5></a>
13621 #include <stdatomic.h>
13622 void atomic_signal_fence(memory_order order);</pre>
13623 <h6>Description</h6>
13625 Equivalent to atomic_thread_fence(order), except that ''synchronizes with''
13626 relationships are established only between a thread and a signal handler executed in the
13629 NOTE 1 The atomic_signal_fence function can be used to specify the order in which actions
13630 performed by the thread become visible to the signal handler.
13633 NOTE 2 Compiler optimizations and reorderings of loads and stores are inhibited in the same way as with
13634 atomic_thread_fence, but the hardware fence instructions that atomic_thread_fence would
13635 have inserted are not emitted.
13639 The atomic_signal_fence function returns no value.
13641 <a name="7.17.5" href="#7.17.5"><h4>7.17.5 Lock-free property</h4></a>
13643 The atomic lock-free macros indicate the lock-free property of integer and address atomic
13644 types. A value of 0 indicates that the type is never lock-free; a value of 1 indicates that
13645 the type is sometimes lock-free; a value of 2 indicates that the type is always lock-free.
13647 NOTE Operations that are lock-free should also be address-free. That is, atomic operations on the same
13648 memory location via two different addresses will communicate atomically. The implementation should not
13649 depend on any per-process state. This restriction enables communication via memory mapped into a
13650 process more than once and memory shared between two processes.
13653 <a name="7.17.5.1" href="#7.17.5.1"><h5>7.17.5.1 The atomic_is_lock_free generic function</h5></a>
13657 #include <stdatomic.h>
13658 _Bool atomic_is_lock_free(atomic_type const volatile *obj);</pre>
13659 <h6>Description</h6>
13661 The atomic_is_lock_free generic function indicates whether or not the object
13662 pointed to by obj is lock-free. atomic_type can be any atomic type.
13665 The atomic_is_lock_free generic function returns nonzero (true) if and only if the
13666 object's operations are lock-free. The result of a lock-free query on one object cannot be
13667 <!--page 297 indent 4-->
13668 inferred from the result of a lock-free query on another object.
13670 <a name="7.17.6" href="#7.17.6"><h4>7.17.6 Atomic integer and address types</h4></a>
13672 For each line in the following table, the atomic type name is declared as the
13673 corresponding direct type.
13674 <!--page 298 indent 4-->
13677 Atomic type name Direct type
13678 atomic_char _Atomic char
13679 atomic_schar _Atomic signed char
13680 atomic_uchar _Atomic unsigned char
13681 atomic_short _Atomic short
13682 atomic_ushort _Atomic unsigned short
13683 atomic_int _Atomic int
13684 atomic_uint _Atomic unsigned int
13685 atomic_long _Atomic long
13686 atomic_ulong _Atomic unsigned long
13687 atomic_llong _Atomic long long
13688 atomic_ullong _Atomic unsigned long long
13689 atomic_char16_t _Atomic char16_t
13690 atomic_char32_t _Atomic char32_t
13691 atomic_wchar_t _Atomic wchar_t
13692 atomic_int_least8_t _Atomic int_least8_t
13693 atomic_uint_least8_t _Atomic uint_least8_t
13694 atomic_int_least16_t _Atomic int_least16_t
13695 atomic_uint_least16_t _Atomic uint_least16_t
13696 atomic_int_least32_t _Atomic int_least32_t
13697 atomic_uint_least32_t _Atomic uint_least32_t
13698 atomic_int_least64_t _Atomic int_least64_t
13699 atomic_uint_least64_t _Atomic uint_least64_t
13700 atomic_int_fast8_t _Atomic int_fast8_t
13701 atomic_uint_fast8_t _Atomic uint_fast8_t
13702 atomic_int_fast16_t _Atomic int_fast16_t
13703 atomic_uint_fast16_t _Atomic uint_fast16_t
13704 atomic_int_fast32_t _Atomic int_fast32_t
13705 atomic_uint_fast32_t _Atomic uint_fast32_t
13706 atomic_int_fast64_t _Atomic int_fast64_t
13707 atomic_uint_fast64_t _Atomic uint_fast64_t
13708 atomic_intptr_t _Atomic intptr_t
13709 atomic_uintptr_t _Atomic uintptr_t
13710 atomic_size_t _Atomic size_t
13711 atomic_ptrdiff_t _Atomic ptrdiff_t
13712 atomic_intmax_t _Atomic intmax_t
13713 atomic_uintmax_t _Atomic uintmax_t</pre>
13714 The semantics of the operations on these types are defined in <a href="#7.17.7">7.17.7</a>.
13716 The atomic_bool type provides an atomic boolean.
13717 <!--page 299 indent 4-->
13719 The atomic_address type provides atomic void * operations. The unit of
13720 addition/subtraction shall be one byte.
13722 NOTE The representation of atomic integer and address types need not have the same size as their
13723 corresponding regular types. They should have the same size whenever possible, as it eases effort required
13724 to port existing code.
13727 <a name="7.17.7" href="#7.17.7"><h4>7.17.7 Operations on atomic types</h4></a>
13729 There are only a few kinds of operations on atomic types, though there are many
13730 instances of those kinds. This subclause specifies each general kind.
13732 <a name="7.17.7.1" href="#7.17.7.1"><h5>7.17.7.1 The atomic_store generic functions</h5></a>
13736 #include <stdatomic.h>
13737 void atomic_store(volatile A *object, C desired);
13738 void atomic_store_explicit(volatile A *object,
13739 C desired, memory_order order);</pre>
13740 <h6>Description</h6>
13742 The order argument shall not be memory_order_acquire,
13743 memory_order_consume, nor memory_order_acq_rel. Atomically replace the
13744 value pointed to by object with the value of desired. Memory is affected according
13745 to the value of order.
13748 The atomic_store generic functions return no value.
13750 <a name="7.17.7.2" href="#7.17.7.2"><h5>7.17.7.2 The atomic_load generic functions</h5></a>
13754 #include <stdatomic.h>
13755 C atomic_load(volatile A *object);
13756 C atomic_load_explicit(volatile A *object,
13757 memory_order order);</pre>
13758 <h6>Description</h6>
13760 The order argument shall not be memory_order_release nor
13761 memory_order_acq_rel. Memory is affected according to the value of order.
13763 Atomically returns the value pointed to by object.
13764 <!--page 300 indent 4-->
13766 <a name="7.17.7.3" href="#7.17.7.3"><h5>7.17.7.3 The atomic_exchange generic functions</h5></a>
13770 #include <stdatomic.h>
13771 C atomic_exchange(volatile A *object, C desired);
13772 C atomic_exchange_explicit(volatile A *object,
13773 C desired, memory_order order);</pre>
13774 <h6>Description</h6>
13776 Atomically replace the value pointed to by object with desired. Memory is affected
13777 according to the value of order. These operations are read-modify-write operations
13778 (<a href="#5.1.2.4">5.1.2.4</a>).
13781 Atomically returns the value pointed to by object immediately before the effects.
13783 <a name="7.17.7.4" href="#7.17.7.4"><h5>7.17.7.4 The atomic_compare_exchange generic functions</h5></a>
13787 #include <stdatomic.h>
13788 _Bool atomic_compare_exchange_strong(volatile A *object,
13789 C *expected, C desired);
13790 _Bool atomic_compare_exchange_strong_explicit(
13791 volatile A *object, C *expected, C desired,
13792 memory_order success, memory_order failure);
13793 _Bool atomic_compare_exchange_weak(volatile A *object,
13794 C *expected, C desired);
13795 _Bool atomic_compare_exchange_weak_explicit(
13796 volatile A *object, C *expected, C desired,
13797 memory_order success, memory_order failure);</pre>
13798 <h6>Description</h6>
13800 The failure argument shall not be memory_order_release nor
13801 memory_order_acq_rel. The failure argument shall be no stronger than the
13802 success argument. Atomically, compares the value pointed to by object for equality
13803 with that in expected, and if true, replaces the value pointed to by object with
13804 desired, and if false, updates the value in expected with the value pointed to by
13805 object. Further, if the comparison is true, memory is affected according to the value of
13806 success, and if the comparison is false, memory is affected according to the value of
13807 failure. These operations are atomic read-modify-write operations (<a href="#5.1.2.4">5.1.2.4</a>).
13809 NOTE 1 The effect of the compare-and-exchange operations is
13810 <!--page 301 indent 4-->
13812 if (*object == *expected)
13815 *expected = *object;</pre>
13818 The weak compare-and-exchange operations may fail spuriously, that is, return zero
13819 while leaving the value pointed to by expected unchanged.
13821 NOTE 2 This spurious failure enables implementation of compare-and-exchange on a broader class of
13822 machines, e.g. load-locked store-conditional machines.
13825 EXAMPLE A consequence of spurious failure is that nearly all uses of weak compare-and-exchange will
13828 exp = atomic_load(&cur);
13830 des = function(exp);
13831 } while (!atomic_compare_exchange_weak(&cur, &exp, des));</pre>
13832 When a compare-and-exchange is in a loop, the weak version will yield better performance on some
13833 platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the
13834 strong one is preferable.
13838 The result of the comparison.
13840 <a name="7.17.7.5" href="#7.17.7.5"><h5>7.17.7.5 The atomic_fetch and modify generic functions</h5></a>
13842 The following operations perform arithmetic and bitwise computations. All of these
13843 operations are applicable to an object of any atomic integer type. Only addition and
13844 subtraction are applicable to atomic_address. None of these operations is applicable
13845 to atomic_bool. The key, operator, and computation correspondence is:
13849 or | bitwise inclusive or
13850 xor ^ bitwise exclusive or
13851 and & bitwise and
13855 #include <stdatomic.h>
13856 C atomic_fetch_key(volatile A *object, M operand);
13857 C atomic_fetch_key_explicit(volatile A *object,
13858 M operand, memory_order order);</pre>
13859 <h6>Description</h6>
13861 Atomically replaces the value pointed to by object with the result of the computation
13862 applied to the value pointed to by object and the given operand. Memory is affected
13863 according to the value of order. These operations are atomic read-modify-write
13864 <!--page 302 indent 4-->
13865 operations (<a href="#5.1.2.4">5.1.2.4</a>). For signed integer types, arithmetic is defined to use two's
13866 complement representation with silent wrap-around on overflow; there are no undefined
13867 results. For address types, the result may be an undefined address, but the operations
13868 otherwise have no undefined behavior.
13871 Atomically, the value pointed to by object immediately before the effects.
13873 NOTE The operation of the atomic_fetch and modify generic functions are nearly equivalent to the
13874 operation of the corresponding op= compound assignment operators. The only differences are that the
13875 compound assignment operators are not guaranteed to operate atomically, and the value yielded by a
13876 compound assignment operator is the updated value of the object, whereas the value returned by the
13877 atomic_fetch and modify generic functions is the previous value of the atomic object.
13880 <a name="7.17.8" href="#7.17.8"><h4>7.17.8 Atomic flag type and operations</h4></a>
13882 The atomic_flag type provides the classic test-and-set functionality. It has two
13883 states, set and clear.
13885 Operations on an object of type atomic_flag shall be lock free.
13887 NOTE Hence the operations should also be address-free. No other type requires lock-free operations, so
13888 the atomic_flag type is the minimum hardware-implemented type needed to conform to this
13889 International standard. The remaining types can be emulated with atomic_flag, though with less than
13893 The macro ATOMIC_FLAG_INIT may be used to initialize an atomic_flag to the
13894 clear state. An atomic_flag that is not explicitly initialized with
13895 ATOMIC_FLAG_INIT is initially in an indeterminate state.
13899 atomic_flag guard = ATOMIC_FLAG_INIT;</pre>
13902 <a name="7.17.8.1" href="#7.17.8.1"><h5>7.17.8.1 The atomic_flag_test_and_set functions</h5></a>
13906 #include <stdatomic.h>
13907 bool atomic_flag_test_and_set(
13908 volatile atomic_flag *object);
13909 bool atomic_flag_test_and_set_explicit(
13910 volatile atomic_flag *object, memory_order order);</pre>
13911 <h6>Description</h6>
13913 Atomically sets the value pointed to by object to true. Memory is affected according
13914 to the value of order. These operations are atomic read-modify-write operations
13915 (<a href="#5.1.2.4">5.1.2.4</a>).
13916 <!--page 303 indent 4-->
13919 Atomically, the value of the object immediately before the effects.
13921 <a name="7.17.8.2" href="#7.17.8.2"><h5>7.17.8.2 The atomic_flag_clear functions</h5></a>
13925 #include <stdatomic.h>
13926 void atomic_flag_clear(volatile atomic_flag *object);
13927 void atomic_flag_clear_explicit(
13928 volatile atomic_flag *object, memory_order order);</pre>
13929 <h6>Description</h6>
13931 The order argument shall not be memory_order_acquire nor
13932 memory_order_acq_rel. Atomically sets the value pointed to by object to false.
13933 Memory is affected according to the value of order.
13936 The atomic_flag_clear functions return no value.
13937 <!--page 304 indent 4-->
13939 <a name="7.18" href="#7.18"><h3>7.18 Boolean type and values <stdbool.h></h3></a>
13941 The header <stdbool.h> defines four macros.
13948 The remaining three macros are suitable for use in #if preprocessing directives. They
13952 which expands to the integer constant 1,
13955 which expands to the integer constant 0, and
13957 __bool_true_false_are_defined</pre>
13958 which expands to the integer constant 1.
13960 Notwithstanding the provisions of <a href="#7.1.3">7.1.3</a>, a program may undefine and perhaps then
13961 redefine the macros bool, true, and false.<sup><a href="#note252"><b>252)</b></a></sup>
13966 <!--page 305 indent 4-->
13969 <p><a name="note252">252)</a> See ''future library directions'' (<a href="#7.30.7">7.30.7</a>).
13972 <a name="7.19" href="#7.19"><h3>7.19 Common definitions <stddef.h></h3></a>
13974 The header <stddef.h> defines the following macros and declares the following types.
13975 Some are also defined in other headers, as noted in their respective subclauses.
13980 which is the signed integer type of the result of subtracting two pointers;
13983 which is the unsigned integer type of the result of the sizeof operator;
13986 which is an object type whose alignment is as great as is supported by the implementation
13987 in all contexts; and
13990 which is an integer type whose range of values can represent distinct codes for all
13991 members of the largest extended character set specified among the supported locales; the
13992 null character shall have the code value zero. Each member of the basic character set
13993 shall have a code value equal to its value when used as the lone character in an integer
13994 character constant if an implementation does not define
13995 __STDC_MB_MIGHT_NEQ_WC__.
14000 which expands to an implementation-defined null pointer constant; and
14002 offsetof(type, member-designator)</pre>
14003 which expands to an integer constant expression that has type size_t, the value of
14004 which is the offset in bytes, to the structure member (designated by member-designator),
14005 from the beginning of its structure (designated by type). The type and member designator
14006 shall be such that given
14008 static type t;</pre>
14009 then the expression &(t.member-designator) evaluates to an address constant. (If the
14010 specified member is a bit-field, the behavior is undefined.)
14011 Recommended practice
14013 The types used for size_t and ptrdiff_t should not have an integer conversion rank
14014 greater than that of signed long int unless the implementation supports objects
14015 large enough to make this necessary.
14016 <!--page 306 indent 0-->
14017 Forward references: localization (<a href="#7.11">7.11</a>).
14018 <!--page 307 indent 4-->
14020 <a name="7.20" href="#7.20"><h3>7.20 Integer types <stdint.h></h3></a>
14022 The header <stdint.h> declares sets of integer types having specified widths, and
14023 defines corresponding sets of macros.<sup><a href="#note253"><b>253)</b></a></sup> It also defines macros that specify limits of
14024 integer types corresponding to types defined in other standard headers.
14026 Types are defined in the following categories:
14028 <li> integer types having certain exact widths;
14029 <li> integer types having at least certain specified widths;
14030 <li> fastest integer types having at least certain specified widths;
14031 <li> integer types wide enough to hold pointers to objects;
14032 <li> integer types having greatest width.
14034 (Some of these types may denote the same type.)
14036 Corresponding macros specify limits of the declared types and construct suitable
14039 For each type described herein that the implementation provides,<sup><a href="#note254"><b>254)</b></a></sup> <stdint.h> shall
14040 declare that typedef name and define the associated macros. Conversely, for each type
14041 described herein that the implementation does not provide, <stdint.h> shall not
14042 declare that typedef name nor shall it define the associated macros. An implementation
14043 shall provide those types described as ''required'', but need not provide any of the others
14044 (described as ''optional'').
14047 <p><a name="note253">253)</a> See ''future library directions'' (<a href="#7.30.8">7.30.8</a>).
14049 <p><a name="note254">254)</a> Some of these types may denote implementation-defined extended integer types.
14052 <a name="7.20.1" href="#7.20.1"><h4>7.20.1 Integer types</h4></a>
14054 When typedef names differing only in the absence or presence of the initial u are defined,
14055 they shall denote corresponding signed and unsigned types as described in <a href="#6.2.5">6.2.5</a>; an
14056 implementation providing one of these corresponding types shall also provide the other.
14058 In the following descriptions, the symbol N represents an unsigned decimal integer with
14059 no leading zeros (e.g., 8 or 24, but not 04 or 048).
14064 <!--page 308 indent 4-->
14066 <a name="7.20.1.1" href="#7.20.1.1"><h5>7.20.1.1 Exact-width integer types</h5></a>
14068 The typedef name intN_t designates a signed integer type with width N , no padding
14069 bits, and a two's complement representation. Thus, int8_t denotes such a signed
14070 integer type with a width of exactly 8 bits.
14072 The typedef name uintN_t designates an unsigned integer type with width N and no
14073 padding bits. Thus, uint24_t denotes such an unsigned integer type with a width of
14076 These types are optional. However, if an implementation provides integer types with
14077 widths of 8, 16, 32, or 64 bits, no padding bits, and (for the signed types) that have a
14078 two's complement representation, it shall define the corresponding typedef names.
14080 <a name="7.20.1.2" href="#7.20.1.2"><h5>7.20.1.2 Minimum-width integer types</h5></a>
14082 The typedef name int_leastN_t designates a signed integer type with a width of at
14083 least N , such that no signed integer type with lesser size has at least the specified width.
14084 Thus, int_least32_t denotes a signed integer type with a width of at least 32 bits.
14086 The typedef name uint_leastN_t designates an unsigned integer type with a width
14087 of at least N , such that no unsigned integer type with lesser size has at least the specified
14088 width. Thus, uint_least16_t denotes an unsigned integer type with a width of at
14091 The following types are required:
14093 int_least8_t uint_least8_t
14094 int_least16_t uint_least16_t
14095 int_least32_t uint_least32_t
14096 int_least64_t uint_least64_t</pre>
14097 All other types of this form are optional.
14099 <a name="7.20.1.3" href="#7.20.1.3"><h5>7.20.1.3 Fastest minimum-width integer types</h5></a>
14101 Each of the following types designates an integer type that is usually fastest<sup><a href="#note255"><b>255)</b></a></sup> to operate
14102 with among all integer types that have at least the specified width.
14104 The typedef name int_fastN_t designates the fastest signed integer type with a width
14105 of at least N . The typedef name uint_fastN_t designates the fastest unsigned integer
14106 type with a width of at least N .
14111 <!--page 309 indent 4-->
14113 The following types are required:
14115 int_fast8_t uint_fast8_t
14116 int_fast16_t uint_fast16_t
14117 int_fast32_t uint_fast32_t
14118 int_fast64_t uint_fast64_t</pre>
14119 All other types of this form are optional.
14122 <p><a name="note255">255)</a> The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear
14123 grounds for choosing one type over another, it will simply pick some integer type satisfying the
14124 signedness and width requirements.
14127 <a name="7.20.1.4" href="#7.20.1.4"><h5>7.20.1.4 Integer types capable of holding object pointers</h5></a>
14129 The following type designates a signed integer type with the property that any valid
14130 pointer to void can be converted to this type, then converted back to pointer to void,
14131 and the result will compare equal to the original pointer:
14134 The following type designates an unsigned integer type with the property that any valid
14135 pointer to void can be converted to this type, then converted back to pointer to void,
14136 and the result will compare equal to the original pointer:
14139 These types are optional.
14141 <a name="7.20.1.5" href="#7.20.1.5"><h5>7.20.1.5 Greatest-width integer types</h5></a>
14143 The following type designates a signed integer type capable of representing any value of
14144 any signed integer type:
14147 The following type designates an unsigned integer type capable of representing any value
14148 of any unsigned integer type:
14151 These types are required.
14153 <a name="7.20.2" href="#7.20.2"><h4>7.20.2 Limits of specified-width integer types</h4></a>
14155 The following object-like macros specify the minimum and maximum limits of the types *
14156 declared in <stdint.h>. Each macro name corresponds to a similar type name in
14157 <a href="#7.20.1">7.20.1</a>.
14159 Each instance of any defined macro shall be replaced by a constant expression suitable
14160 for use in #if preprocessing directives, and this expression shall have the same type as
14161 would an expression that is an object of the corresponding type converted according to
14162 the integer promotions. Its implementation-defined value shall be equal to or greater in
14163 magnitude (absolute value) than the corresponding value given below, with the same sign,
14164 except where stated to be exactly the given value.
14165 <!--page 310 indent 4-->
14167 <a name="7.20.2.1" href="#7.20.2.1"><h5>7.20.2.1 Limits of exact-width integer types</h5></a>
14170 <li> minimum values of exact-width signed integer types
14172 INTN_MIN exactly -(2 N -1 )</pre>
14173 <li> maximum values of exact-width signed integer types
14175 INTN_MAX exactly 2 N -1 - 1</pre>
14176 <li> maximum values of exact-width unsigned integer types
14177 UINTN_MAX exactly 2 N - 1
14180 <a name="7.20.2.2" href="#7.20.2.2"><h5>7.20.2.2 Limits of minimum-width integer types</h5></a>
14183 <li> minimum values of minimum-width signed integer types
14185 INT_LEASTN_MIN -(2 N -1 - 1)</pre>
14186 <li> maximum values of minimum-width signed integer types
14188 INT_LEASTN_MAX 2 N -1 - 1</pre>
14189 <li> maximum values of minimum-width unsigned integer types
14190 UINT_LEASTN_MAX 2N - 1
14193 <a name="7.20.2.3" href="#7.20.2.3"><h5>7.20.2.3 Limits of fastest minimum-width integer types</h5></a>
14196 <li> minimum values of fastest minimum-width signed integer types
14198 INT_FASTN_MIN -(2 N -1 - 1)</pre>
14199 <li> maximum values of fastest minimum-width signed integer types
14200 INT_FASTN_MAX 2 N -1 - 1
14201 <li> maximum values of fastest minimum-width unsigned integer types
14202 UINT_FASTN_MAX 2N - 1
14205 <a name="7.20.2.4" href="#7.20.2.4"><h5>7.20.2.4 Limits of integer types capable of holding object pointers</h5></a>
14208 <li> minimum value of pointer-holding signed integer type
14210 INTPTR_MIN -(215 - 1)</pre>
14211 <li> maximum value of pointer-holding signed integer type
14213 <li> maximum value of pointer-holding unsigned integer type
14214 UINTPTR_MAX 216 - 1
14215 <!--page 311 indent 4-->
14218 <a name="7.20.2.5" href="#7.20.2.5"><h5>7.20.2.5 Limits of greatest-width integer types</h5></a>
14221 <li> minimum value of greatest-width signed integer type
14222 INTMAX_MIN -(263 - 1)
14223 <li> maximum value of greatest-width signed integer type
14225 <li> maximum value of greatest-width unsigned integer type
14226 UINTMAX_MAX 264 - 1
14229 <a name="7.20.3" href="#7.20.3"><h4>7.20.3 Limits of other integer types</h4></a>
14231 The following object-like macros specify the minimum and maximum limits of integer *
14232 types corresponding to types defined in other standard headers.
14234 Each instance of these macros shall be replaced by a constant expression suitable for use
14235 in #if preprocessing directives, and this expression shall have the same type as would an
14236 expression that is an object of the corresponding type converted according to the integer
14237 promotions. Its implementation-defined value shall be equal to or greater in magnitude
14238 (absolute value) than the corresponding value given below, with the same sign. An
14239 implementation shall define only the macros corresponding to those typedef names it
14240 actually provides.<sup><a href="#note256"><b>256)</b></a></sup>
14242 <li> limits of ptrdiff_t
14245 <li> limits of sig_atomic_t
14246 SIG_ATOMIC_MIN see below
14247 SIG_ATOMIC_MAX see below
14248 <li> limit of size_t
14250 <li> limits of wchar_t
14251 WCHAR_MIN see below
14252 WCHAR_MAX see below
14253 <li> limits of wint_t
14258 <!--page 312 indent 4-->
14263 If sig_atomic_t (see <a href="#7.14">7.14</a>) is defined as a signed integer type, the value of
14264 SIG_ATOMIC_MIN shall be no greater than -127 and the value of SIG_ATOMIC_MAX
14265 shall be no less than 127; otherwise, sig_atomic_t is defined as an unsigned integer
14266 type, and the value of SIG_ATOMIC_MIN shall be 0 and the value of
14267 SIG_ATOMIC_MAX shall be no less than 255.
14269 If wchar_t (see <a href="#7.19">7.19</a>) is defined as a signed integer type, the value of WCHAR_MIN
14270 shall be no greater than -127 and the value of WCHAR_MAX shall be no less than 127;
14271 otherwise, wchar_t is defined as an unsigned integer type, and the value of
14272 WCHAR_MIN shall be 0 and the value of WCHAR_MAX shall be no less than 255.<sup><a href="#note257"><b>257)</b></a></sup>
14274 If wint_t (see <a href="#7.28">7.28</a>) is defined as a signed integer type, the value of WINT_MIN shall
14275 be no greater than -32767 and the value of WINT_MAX shall be no less than 32767;
14276 otherwise, wint_t is defined as an unsigned integer type, and the value of WINT_MIN
14277 shall be 0 and the value of WINT_MAX shall be no less than 65535.
14280 <p><a name="note256">256)</a> A freestanding implementation need not provide all of these types.
14282 <p><a name="note257">257)</a> The values WCHAR_MIN and WCHAR_MAX do not necessarily correspond to members of the extended
14286 <a name="7.20.4" href="#7.20.4"><h4>7.20.4 Macros for integer constants</h4></a>
14288 The following function-like macros expand to integer constants suitable for initializing *
14289 objects that have integer types corresponding to types defined in <stdint.h>. Each
14290 macro name corresponds to a similar type name in <a href="#7.20.1.2">7.20.1.2</a> or <a href="#7.20.1.5">7.20.1.5</a>.
14292 The argument in any instance of these macros shall be an unsuffixed integer constant (as
14293 defined in <a href="#6.4.4.1">6.4.4.1</a>) with a value that does not exceed the limits for the corresponding type.
14295 Each invocation of one of these macros shall expand to an integer constant expression
14296 suitable for use in #if preprocessing directives. The type of the expression shall have
14297 the same type as would an expression of the corresponding type converted according to
14298 the integer promotions. The value of the expression shall be that of the argument.
14300 <a name="7.20.4.1" href="#7.20.4.1"><h5>7.20.4.1 Macros for minimum-width integer constants</h5></a>
14302 The macro INTN_C(value) shall expand to an integer constant expression
14303 corresponding to the type int_leastN_t. The macro UINTN_C(value) shall expand
14304 to an integer constant expression corresponding to the type uint_leastN_t. For
14305 example, if uint_least64_t is a name for the type unsigned long long int,
14306 then UINT64_C(0x123) might expand to the integer constant 0x123ULL.
14311 <!--page 313 indent 4-->
14313 <a name="7.20.4.2" href="#7.20.4.2"><h5>7.20.4.2 Macros for greatest-width integer constants</h5></a>
14315 The following macro expands to an integer constant expression having the value specified
14316 by its argument and the type intmax_t:
14318 INTMAX_C(value)</pre>
14319 The following macro expands to an integer constant expression having the value specified
14320 by its argument and the type uintmax_t:
14321 <!--page 314 indent 4-->
14323 UINTMAX_C(value)</pre>
14325 <a name="7.21" href="#7.21"><h3>7.21 Input/output <stdio.h></h3></a>
14327 <a name="7.21.1" href="#7.21.1"><h4>7.21.1 Introduction</h4></a>
14329 The header <stdio.h> defines several macros, and declares three types and many
14330 functions for performing input and output.
14332 The types declared are size_t (described in <a href="#7.19">7.19</a>);
14335 which is an object type capable of recording all the information needed to control a
14336 stream, including its file position indicator, a pointer to its associated buffer (if any), an
14337 error indicator that records whether a read/write error has occurred, and an end-of-file
14338 indicator that records whether the end of the file has been reached; and
14341 which is a complete object type other than an array type capable of recording all the
14342 information needed to specify uniquely every position within a file.
14344 The macros are NULL (described in <a href="#7.19">7.19</a>);
14349 which expand to integer constant expressions with distinct values, suitable for use as the
14350 third argument to the setvbuf function;
14353 which expands to an integer constant expression that is the size of the buffer used by the
14357 which expands to an integer constant expression, with type int and a negative value, that
14358 is returned by several functions to indicate end-of-file, that is, no more input from a
14362 which expands to an integer constant expression that is the minimum number of files that
14363 the implementation guarantees can be open simultaneously;
14366 which expands to an integer constant expression that is the size needed for an array of
14367 char large enough to hold the longest file name string that the implementation
14368 <!--page 315 indent 4-->
14369 guarantees can be opened;<sup><a href="#note258"><b>258)</b></a></sup>
14372 which expands to an integer constant expression that is the size needed for an array of
14373 char large enough to hold a temporary file name string generated by the tmpnam
14379 which expand to integer constant expressions with distinct values, suitable for use as the
14380 third argument to the fseek function;
14383 which expands to an integer constant expression that is the minimum number of unique
14384 file names that can be generated by the tmpnam function;
14389 which are expressions of type ''pointer to FILE'' that point to the FILE objects
14390 associated, respectively, with the standard error, input, and output streams.
14392 The header <wchar.h> declares a number of functions useful for wide character input
14393 and output. The wide character input/output functions described in that subclause
14394 provide operations analogous to most of those described here, except that the
14395 fundamental units internal to the program are wide characters. The external
14396 representation (in the file) is a sequence of ''generalized'' multibyte characters, as
14397 described further in <a href="#7.21.3">7.21.3</a>.
14399 The input/output functions are given the following collective terms:
14401 <li> The wide character input functions -- those functions described in <a href="#7.28">7.28</a> that perform
14402 input into wide characters and wide strings: fgetwc, fgetws, getwc, getwchar,
14403 fwscanf, wscanf, vfwscanf, and vwscanf.
14404 <li> The wide character output functions -- those functions described in <a href="#7.28">7.28</a> that perform
14405 output from wide characters and wide strings: fputwc, fputws, putwc,
14406 putwchar, fwprintf, wprintf, vfwprintf, and vwprintf.
14409 <!--page 316 indent 4-->
14410 <li> The wide character input/output functions -- the union of the ungetwc function, the
14411 wide character input functions, and the wide character output functions.
14412 <li> The byte input/output functions -- those functions described in this subclause that
14413 perform input/output: fgetc, fgets, fprintf, fputc, fputs, fread,
14414 fscanf, fwrite, getc, getchar, printf, putc, putchar, puts, scanf, *
14415 ungetc, vfprintf, vfscanf, vprintf, and vscanf.
14417 Forward references: files (<a href="#7.21.3">7.21.3</a>), the fseek function (<a href="#7.21.9.2">7.21.9.2</a>), streams (<a href="#7.21.2">7.21.2</a>), the
14418 tmpnam function (<a href="#7.21.4.4">7.21.4.4</a>), <wchar.h> (<a href="#7.28">7.28</a>).
14421 <p><a name="note258">258)</a> If the implementation imposes no practical limit on the length of file name strings, the value of
14422 FILENAME_MAX should instead be the recommended size of an array intended to hold a file name
14423 string. Of course, file name string contents are subject to other system-specific constraints; therefore
14424 all possible strings of length FILENAME_MAX cannot be expected to be opened successfully.
14427 <a name="7.21.2" href="#7.21.2"><h4>7.21.2 Streams</h4></a>
14429 Input and output, whether to or from physical devices such as terminals and tape drives,
14430 or whether to or from files supported on structured storage devices, are mapped into
14431 logical data streams, whose properties are more uniform than their various inputs and
14432 outputs. Two forms of mapping are supported, for text streams and for binary
14433 streams.<sup><a href="#note259"><b>259)</b></a></sup>
14435 A text stream is an ordered sequence of characters composed into lines, each line
14436 consisting of zero or more characters plus a terminating new-line character. Whether the
14437 last line requires a terminating new-line character is implementation-defined. Characters
14438 may have to be added, altered, or deleted on input and output to conform to differing
14439 conventions for representing text in the host environment. Thus, there need not be a one-
14440 to-one correspondence between the characters in a stream and those in the external
14441 representation. Data read in from a text stream will necessarily compare equal to the data
14442 that were earlier written out to that stream only if: the data consist only of printing
14443 characters and the control characters horizontal tab and new-line; no new-line character is
14444 immediately preceded by space characters; and the last character is a new-line character.
14445 Whether space characters that are written out immediately before a new-line character
14446 appear when read in is implementation-defined.
14448 A binary stream is an ordered sequence of characters that can transparently record
14449 internal data. Data read in from a binary stream shall compare equal to the data that were
14450 earlier written out to that stream, under the same implementation. Such a stream may,
14451 however, have an implementation-defined number of null characters appended to the end
14454 Each stream has an orientation. After a stream is associated with an external file, but
14455 before any operations are performed on it, the stream is without orientation. Once a wide
14456 character input/output function has been applied to a stream without orientation, the
14459 <!--page 317 indent 4-->
14460 stream becomes a wide-oriented stream. Similarly, once a byte input/output function has
14461 been applied to a stream without orientation, the stream becomes a byte-oriented stream.
14462 Only a call to the freopen function or the fwide function can otherwise alter the
14463 orientation of a stream. (A successful call to freopen removes any orientation.)<sup><a href="#note260"><b>260)</b></a></sup>
14465 Byte input/output functions shall not be applied to a wide-oriented stream and wide
14466 character input/output functions shall not be applied to a byte-oriented stream. The
14467 remaining stream operations do not affect, and are not affected by, a stream's orientation,
14468 except for the following additional restrictions:
14470 <li> Binary wide-oriented streams have the file-positioning restrictions ascribed to both
14471 text and binary streams.
14472 <li> For wide-oriented streams, after a successful call to a file-positioning function that
14473 leaves the file position indicator prior to the end-of-file, a wide character output
14474 function can overwrite a partial multibyte character; any file contents beyond the
14475 byte(s) written are henceforth indeterminate.
14478 Each wide-oriented stream has an associated mbstate_t object that stores the current
14479 parse state of the stream. A successful call to fgetpos stores a representation of the
14480 value of this mbstate_t object as part of the value of the fpos_t object. A later
14481 successful call to fsetpos using the same stored fpos_t value restores the value of
14482 the associated mbstate_t object as well as the position within the controlled stream.
14483 Environmental limits
14485 An implementation shall support text files with lines containing at least 254 characters,
14486 including the terminating new-line character. The value of the macro BUFSIZ shall be at
14488 Forward references: the freopen function (<a href="#7.21.5.4">7.21.5.4</a>), the fwide function (<a href="#7.28.3.5">7.28.3.5</a>),
14489 mbstate_t (<a href="#7.29.1">7.29.1</a>), the fgetpos function (<a href="#7.21.9.1">7.21.9.1</a>), the fsetpos function
14490 (<a href="#7.21.9.3">7.21.9.3</a>).
14495 <!--page 318 indent 4-->
14498 <p><a name="note259">259)</a> An implementation need not distinguish between text streams and binary streams. In such an
14499 implementation, there need be no new-line characters in a text stream nor any limit to the length of a
14502 <p><a name="note260">260)</a> The three predefined streams stdin, stdout, and stderr are unoriented at program startup.
14505 <a name="7.21.3" href="#7.21.3"><h4>7.21.3 Files</h4></a>
14507 A stream is associated with an external file (which may be a physical device) by opening
14508 a file, which may involve creating a new file. Creating an existing file causes its former
14509 contents to be discarded, if necessary. If a file can support positioning requests (such as a
14510 disk file, as opposed to a terminal), then a file position indicator associated with the
14511 stream is positioned at the start (character number zero) of the file, unless the file is
14512 opened with append mode in which case it is implementation-defined whether the file
14513 position indicator is initially positioned at the beginning or the end of the file. The file
14514 position indicator is maintained by subsequent reads, writes, and positioning requests, to
14515 facilitate an orderly progression through the file.
14517 Binary files are not truncated, except as defined in <a href="#7.21.5.3">7.21.5.3</a>. Whether a write on a text
14518 stream causes the associated file to be truncated beyond that point is implementation-
14521 When a stream is unbuffered, characters are intended to appear from the source or at the
14522 destination as soon as possible. Otherwise characters may be accumulated and
14523 transmitted to or from the host environment as a block. When a stream is fully buffered,
14524 characters are intended to be transmitted to or from the host environment as a block when
14525 a buffer is filled. When a stream is line buffered, characters are intended to be
14526 transmitted to or from the host environment as a block when a new-line character is
14527 encountered. Furthermore, characters are intended to be transmitted as a block to the host
14528 environment when a buffer is filled, when input is requested on an unbuffered stream, or
14529 when input is requested on a line buffered stream that requires the transmission of
14530 characters from the host environment. Support for these characteristics is
14531 implementation-defined, and may be affected via the setbuf and setvbuf functions.
14533 A file may be disassociated from a controlling stream by closing the file. Output streams
14534 are flushed (any unwritten buffer contents are transmitted to the host environment) before
14535 the stream is disassociated from the file. The value of a pointer to a FILE object is
14536 indeterminate after the associated file is closed (including the standard text streams).
14537 Whether a file of zero length (on which no characters have been written by an output
14538 stream) actually exists is implementation-defined.
14540 The file may be subsequently reopened, by the same or another program execution, and
14541 its contents reclaimed or modified (if it can be repositioned at its start). If the main
14542 function returns to its original caller, or if the exit function is called, all open files are
14543 closed (hence all output streams are flushed) before program termination. Other paths to
14544 program termination, such as calling the abort function, need not close all files
14547 The address of the FILE object used to control a stream may be significant; a copy of a
14548 FILE object need not serve in place of the original.
14549 <!--page 319 indent 5-->
14551 At program startup, three text streams are predefined and need not be opened explicitly
14553 <li> standard input (for reading conventional input), standard output (for writing
14555 conventional output), and standard error (for writing diagnostic output). As initially
14556 opened, the standard error stream is not fully buffered; the standard input and standard
14557 output streams are fully buffered if and only if the stream can be determined not to refer
14558 to an interactive device.
14560 Functions that open additional (nontemporary) files require a file name, which is a string.
14561 The rules for composing valid file names are implementation-defined. Whether the same
14562 file can be simultaneously open multiple times is also implementation-defined.
14564 Although both text and binary wide-oriented streams are conceptually sequences of wide
14565 characters, the external file associated with a wide-oriented stream is a sequence of
14566 multibyte characters, generalized as follows:
14568 <li> Multibyte encodings within files may contain embedded null bytes (unlike multibyte
14569 encodings valid for use internal to the program).
14570 <li> A file need not begin nor end in the initial shift state.<sup><a href="#note261"><b>261)</b></a></sup>
14573 Moreover, the encodings used for multibyte characters may differ among files. Both the
14574 nature and choice of such encodings are implementation-defined.
14576 The wide character input functions read multibyte characters from the stream and convert
14577 them to wide characters as if they were read by successive calls to the fgetwc function.
14578 Each conversion occurs as if by a call to the mbrtowc function, with the conversion state
14579 described by the stream's own mbstate_t object. The byte input functions read
14580 characters from the stream as if by successive calls to the fgetc function.
14582 The wide character output functions convert wide characters to multibyte characters and
14583 write them to the stream as if they were written by successive calls to the fputwc
14584 function. Each conversion occurs as if by a call to the wcrtomb function, with the
14585 conversion state described by the stream's own mbstate_t object. The byte output
14586 functions write characters to the stream as if by successive calls to the fputc function.
14588 In some cases, some of the byte input/output functions also perform conversions between
14589 multibyte characters and wide characters. These conversions also occur as if by calls to
14590 the mbrtowc and wcrtomb functions.
14592 An encoding error occurs if the character sequence presented to the underlying
14593 mbrtowc function does not form a valid (generalized) multibyte character, or if the code
14594 value passed to the underlying wcrtomb does not correspond to a valid (generalized)
14597 <!--page 320 indent 5-->
14598 multibyte character. The wide character input/output functions and the byte input/output
14599 functions store the value of the macro EILSEQ in errno if and only if an encoding error
14601 Environmental limits
14603 The value of FOPEN_MAX shall be at least eight, including the three standard text
14605 Forward references: the exit function (<a href="#7.22.4.4">7.22.4.4</a>), the fgetc function (<a href="#7.21.7.1">7.21.7.1</a>), the
14606 fopen function (<a href="#7.21.5.3">7.21.5.3</a>), the fputc function (<a href="#7.21.7.3">7.21.7.3</a>), the setbuf function
14607 (<a href="#7.21.5.5">7.21.5.5</a>), the setvbuf function (<a href="#7.21.5.6">7.21.5.6</a>), the fgetwc function (<a href="#7.28.3.1">7.28.3.1</a>), the
14608 fputwc function (<a href="#7.28.3.3">7.28.3.3</a>), conversion state (<a href="#7.28.6">7.28.6</a>), the mbrtowc function
14609 (<a href="#7.28.6.3.2">7.28.6.3.2</a>), the wcrtomb function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
14612 <p><a name="note261">261)</a> Setting the file position indicator to end-of-file, as with fseek(file, 0, SEEK_END), has
14613 undefined behavior for a binary stream (because of possible trailing null characters) or for any stream
14614 with state-dependent encoding that does not assuredly end in the initial shift state.
14617 <a name="7.21.4" href="#7.21.4"><h4>7.21.4 Operations on files</h4></a>
14619 <a name="7.21.4.1" href="#7.21.4.1"><h5>7.21.4.1 The remove function</h5></a>
14623 #include <stdio.h>
14624 int remove(const char *filename);</pre>
14625 <h6>Description</h6>
14627 The remove function causes the file whose name is the string pointed to by filename
14628 to be no longer accessible by that name. A subsequent attempt to open that file using that
14629 name will fail, unless it is created anew. If the file is open, the behavior of the remove
14630 function is implementation-defined.
14633 The remove function returns zero if the operation succeeds, nonzero if it fails.
14635 <a name="7.21.4.2" href="#7.21.4.2"><h5>7.21.4.2 The rename function</h5></a>
14639 #include <stdio.h>
14640 int rename(const char *old, const char *new);</pre>
14641 <h6>Description</h6>
14643 The rename function causes the file whose name is the string pointed to by old to be
14644 henceforth known by the name given by the string pointed to by new. The file named
14645 old is no longer accessible by that name. If a file named by the string pointed to by new
14646 exists prior to the call to the rename function, the behavior is implementation-defined.
14647 <!--page 321 indent 4-->
14650 The rename function returns zero if the operation succeeds, nonzero if it fails,<sup><a href="#note262"><b>262)</b></a></sup> in
14651 which case if the file existed previously it is still known by its original name.
14654 <p><a name="note262">262)</a> Among the reasons the implementation may cause the rename function to fail are that the file is open
14655 or that it is necessary to copy its contents to effectuate its renaming.
14658 <a name="7.21.4.3" href="#7.21.4.3"><h5>7.21.4.3 The tmpfile function</h5></a>
14662 #include <stdio.h>
14663 FILE *tmpfile(void);</pre>
14664 <h6>Description</h6>
14666 The tmpfile function creates a temporary binary file that is different from any other
14667 existing file and that will automatically be removed when it is closed or at program
14668 termination. If the program terminates abnormally, whether an open temporary file is
14669 removed is implementation-defined. The file is opened for update with "wb+" mode.
14670 Recommended practice
14672 It should be possible to open at least TMP_MAX temporary files during the lifetime of the
14673 program (this limit may be shared with tmpnam) and there should be no limit on the
14674 number simultaneously open other than this limit and any limit on the number of open
14678 The tmpfile function returns a pointer to the stream of the file that it created. If the file
14679 cannot be created, the tmpfile function returns a null pointer.
14680 Forward references: the fopen function (<a href="#7.21.5.3">7.21.5.3</a>).
14682 <a name="7.21.4.4" href="#7.21.4.4"><h5>7.21.4.4 The tmpnam function</h5></a>
14686 #include <stdio.h>
14687 char *tmpnam(char *s);</pre>
14688 <h6>Description</h6>
14690 The tmpnam function generates a string that is a valid file name and that is not the same
14691 as the name of an existing file.<sup><a href="#note263"><b>263)</b></a></sup> The function is potentially capable of generating at
14694 <!--page 322 indent 4-->
14695 least TMP_MAX different strings, but any or all of them may already be in use by existing
14696 files and thus not be suitable return values.
14698 The tmpnam function generates a different string each time it is called.
14700 Calls to the tmpnam function with a null pointer argument may introduce data races with
14701 each other. The implementation shall behave as if no library function calls the tmpnam
14705 If no suitable string can be generated, the tmpnam function returns a null pointer.
14706 Otherwise, if the argument is a null pointer, the tmpnam function leaves its result in an
14707 internal static object and returns a pointer to that object (subsequent calls to the tmpnam
14708 function may modify the same object). If the argument is not a null pointer, it is assumed
14709 to point to an array of at least L_tmpnam chars; the tmpnam function writes its result
14710 in that array and returns the argument as its value.
14711 Environmental limits
14713 The value of the macro TMP_MAX shall be at least 25.
14716 <p><a name="note263">263)</a> Files created using strings generated by the tmpnam function are temporary only in the sense that
14717 their names should not collide with those generated by conventional naming rules for the
14718 implementation. It is still necessary to use the remove function to remove such files when their use
14719 is ended, and before program termination.
14722 <a name="7.21.5" href="#7.21.5"><h4>7.21.5 File access functions</h4></a>
14724 <a name="7.21.5.1" href="#7.21.5.1"><h5>7.21.5.1 The fclose function</h5></a>
14728 #include <stdio.h>
14729 int fclose(FILE *stream);</pre>
14730 <h6>Description</h6>
14732 A successful call to the fclose function causes the stream pointed to by stream to be
14733 flushed and the associated file to be closed. Any unwritten buffered data for the stream
14734 are delivered to the host environment to be written to the file; any unread buffered data
14735 are discarded. Whether or not the call succeeds, the stream is disassociated from the file
14736 and any buffer set by the setbuf or setvbuf function is disassociated from the stream
14737 (and deallocated if it was automatically allocated).
14740 The fclose function returns zero if the stream was successfully closed, or EOF if any
14741 errors were detected.
14742 <!--page 323 indent 4-->
14744 <a name="7.21.5.2" href="#7.21.5.2"><h5>7.21.5.2 The fflush function</h5></a>
14748 #include <stdio.h>
14749 int fflush(FILE *stream);</pre>
14750 <h6>Description</h6>
14752 If stream points to an output stream or an update stream in which the most recent
14753 operation was not input, the fflush function causes any unwritten data for that stream
14754 to be delivered to the host environment to be written to the file; otherwise, the behavior is
14757 If stream is a null pointer, the fflush function performs this flushing action on all
14758 streams for which the behavior is defined above.
14761 The fflush function sets the error indicator for the stream and returns EOF if a write
14762 error occurs, otherwise it returns zero.
14763 Forward references: the fopen function (<a href="#7.21.5.3">7.21.5.3</a>).
14765 <a name="7.21.5.3" href="#7.21.5.3"><h5>7.21.5.3 The fopen function</h5></a>
14769 #include <stdio.h>
14770 FILE *fopen(const char * restrict filename,
14771 const char * restrict mode);</pre>
14772 <h6>Description</h6>
14774 The fopen function opens the file whose name is the string pointed to by filename,
14775 and associates a stream with it.
14777 The argument mode points to a string. If the string is one of the following, the file is
14778 open in the indicated mode. Otherwise, the behavior is undefined.<sup><a href="#note264"><b>264)</b></a></sup>
14779 r open text file for reading
14780 w truncate to zero length or create text file for writing
14781 wx create text file for writing
14782 a append; open or create text file for writing at end-of-file
14783 rb open binary file for reading
14784 wb truncate to zero length or create binary file for writing
14787 <!--page 324 indent 4-->
14788 wbx create binary file for writing
14789 ab append; open or create binary file for writing at end-of-file
14790 r+ open text file for update (reading and writing)
14791 w+ truncate to zero length or create text file for update
14792 w+x create text file for update
14793 a+ append; open or create text file for update, writing at end-of-file
14794 r+b or rb+ open binary file for update (reading and writing)
14795 w+b or wb+ truncate to zero length or create binary file for update
14796 w+bx or wb+x create binary file for update
14797 a+b or ab+ append; open or create binary file for update, writing at end-of-file
14799 Opening a file with read mode ('r' as the first character in the mode argument) fails if
14800 the file does not exist or cannot be read.
14802 Opening a file with exclusive mode ('x' as the last character in the mode argument)
14803 fails if the file already exists or cannot be created. Otherwise, the file is created with
14804 exclusive (also known as non-shared) access to the extent that the underlying system
14805 supports exclusive access.
14807 Opening a file with append mode ('a' as the first character in the mode argument)
14808 causes all subsequent writes to the file to be forced to the then current end-of-file,
14809 regardless of intervening calls to the fseek function. In some implementations, opening
14810 a binary file with append mode ('b' as the second or third character in the above list of
14811 mode argument values) may initially position the file position indicator for the stream
14812 beyond the last data written, because of null character padding.
14814 When a file is opened with update mode ('+' as the second or third character in the
14815 above list of mode argument values), both input and output may be performed on the
14816 associated stream. However, output shall not be directly followed by input without an
14817 intervening call to the fflush function or to a file positioning function (fseek,
14818 fsetpos, or rewind), and input shall not be directly followed by output without an
14819 intervening call to a file positioning function, unless the input operation encounters end-
14820 of-file. Opening (or creating) a text file with update mode may instead open (or create) a
14821 binary stream in some implementations.
14823 When opened, a stream is fully buffered if and only if it can be determined not to refer to
14824 an interactive device. The error and end-of-file indicators for the stream are cleared.
14827 The fopen function returns a pointer to the object controlling the stream. If the open
14828 operation fails, fopen returns a null pointer.
14829 Forward references: file positioning functions (<a href="#7.21.9">7.21.9</a>).
14830 <!--page 325 indent 4-->
14833 <p><a name="note264">264)</a> If the string begins with one of the above sequences, the implementation might choose to ignore the
14834 remaining characters, or it might use them to select different kinds of a file (some of which might not
14835 conform to the properties in <a href="#7.21.2">7.21.2</a>).
14838 <a name="7.21.5.4" href="#7.21.5.4"><h5>7.21.5.4 The freopen function</h5></a>
14842 #include <stdio.h>
14843 FILE *freopen(const char * restrict filename,
14844 const char * restrict mode,
14845 FILE * restrict stream);</pre>
14846 <h6>Description</h6>
14848 The freopen function opens the file whose name is the string pointed to by filename
14849 and associates the stream pointed to by stream with it. The mode argument is used just
14850 as in the fopen function.<sup><a href="#note265"><b>265)</b></a></sup>
14852 If filename is a null pointer, the freopen function attempts to change the mode of
14853 the stream to that specified by mode, as if the name of the file currently associated with
14854 the stream had been used. It is implementation-defined which changes of mode are
14855 permitted (if any), and under what circumstances.
14857 The freopen function first attempts to close any file that is associated with the specified
14858 stream. Failure to close the file is ignored. The error and end-of-file indicators for the
14859 stream are cleared.
14862 The freopen function returns a null pointer if the open operation fails. Otherwise,
14863 freopen returns the value of stream.
14866 <p><a name="note265">265)</a> The primary use of the freopen function is to change the file associated with a standard text stream
14867 (stderr, stdin, or stdout), as those identifiers need not be modifiable lvalues to which the value
14868 returned by the fopen function may be assigned.
14871 <a name="7.21.5.5" href="#7.21.5.5"><h5>7.21.5.5 The setbuf function</h5></a>
14875 #include <stdio.h>
14876 void setbuf(FILE * restrict stream,
14877 char * restrict buf);</pre>
14878 <h6>Description</h6>
14880 Except that it returns no value, the setbuf function is equivalent to the setvbuf
14881 function invoked with the values _IOFBF for mode and BUFSIZ for size, or (if buf
14882 is a null pointer), with the value _IONBF for mode.
14887 <!--page 326 indent 4-->
14890 The setbuf function returns no value.
14891 Forward references: the setvbuf function (<a href="#7.21.5.6">7.21.5.6</a>).
14893 <a name="7.21.5.6" href="#7.21.5.6"><h5>7.21.5.6 The setvbuf function</h5></a>
14897 #include <stdio.h>
14898 int setvbuf(FILE * restrict stream,
14899 char * restrict buf,
14900 int mode, size_t size);</pre>
14901 <h6>Description</h6>
14903 The setvbuf function may be used only after the stream pointed to by stream has
14904 been associated with an open file and before any other operation (other than an
14905 unsuccessful call to setvbuf) is performed on the stream. The argument mode
14906 determines how stream will be buffered, as follows: _IOFBF causes input/output to be
14907 fully buffered; _IOLBF causes input/output to be line buffered; _IONBF causes
14908 input/output to be unbuffered. If buf is not a null pointer, the array it points to may be
14909 used instead of a buffer allocated by the setvbuf function<sup><a href="#note266"><b>266)</b></a></sup> and the argument size
14910 specifies the size of the array; otherwise, size may determine the size of a buffer
14911 allocated by the setvbuf function. The contents of the array at any time are
14915 The setvbuf function returns zero on success, or nonzero if an invalid value is given
14916 for mode or if the request cannot be honored.
14921 <!--page 327 indent 4-->
14924 <p><a name="note266">266)</a> The buffer has to have a lifetime at least as great as the open stream, so the stream should be closed
14925 before a buffer that has automatic storage duration is deallocated upon block exit.
14928 <a name="7.21.6" href="#7.21.6"><h4>7.21.6 Formatted input/output functions</h4></a>
14930 The formatted input/output functions shall behave as if there is a sequence point after the
14931 actions associated with each specifier.<sup><a href="#note267"><b>267)</b></a></sup>
14934 <p><a name="note267">267)</a> The fprintf functions perform writes to memory for the %n specifier.
14937 <a name="7.21.6.1" href="#7.21.6.1"><h5>7.21.6.1 The fprintf function</h5></a>
14941 #include <stdio.h>
14942 int fprintf(FILE * restrict stream,
14943 const char * restrict format, ...);</pre>
14944 <h6>Description</h6>
14946 The fprintf function writes output to the stream pointed to by stream, under control
14947 of the string pointed to by format that specifies how subsequent arguments are
14948 converted for output. If there are insufficient arguments for the format, the behavior is
14949 undefined. If the format is exhausted while arguments remain, the excess arguments are
14950 evaluated (as always) but are otherwise ignored. The fprintf function returns when
14951 the end of the format string is encountered.
14953 The format shall be a multibyte character sequence, beginning and ending in its initial
14954 shift state. The format is composed of zero or more directives: ordinary multibyte
14955 characters (not %), which are copied unchanged to the output stream; and conversion
14956 specifications, each of which results in fetching zero or more subsequent arguments,
14957 converting them, if applicable, according to the corresponding conversion specifier, and
14958 then writing the result to the output stream.
14960 Each conversion specification is introduced by the character %. After the %, the following
14961 appear in sequence:
14963 <li> Zero or more flags (in any order) that modify the meaning of the conversion
14965 <li> An optional minimum field width. If the converted value has fewer characters than the
14966 field width, it is padded with spaces (by default) on the left (or right, if the left
14967 adjustment flag, described later, has been given) to the field width. The field width
14968 takes the form of an asterisk * (described later) or a nonnegative decimal integer.<sup><a href="#note268"><b>268)</b></a></sup>
14969 <li> An optional precision that gives the minimum number of digits to appear for the d, i,
14970 o, u, x, and X conversions, the number of digits to appear after the decimal-point
14971 character for a, A, e, E, f, and F conversions, the maximum number of significant
14972 digits for the g and G conversions, or the maximum number of bytes to be written for
14975 <!--page 328 indent 4-->
14976 s conversions. The precision takes the form of a period (.) followed either by an
14977 asterisk * (described later) or by an optional decimal integer; if only the period is
14978 specified, the precision is taken as zero. If a precision appears with any other
14979 conversion specifier, the behavior is undefined.
14980 <li> An optional length modifier that specifies the size of the argument.
14981 <li> A conversion specifier character that specifies the type of conversion to be applied.
14984 As noted above, a field width, or precision, or both, may be indicated by an asterisk. In
14985 this case, an int argument supplies the field width or precision. The arguments
14986 specifying field width, or precision, or both, shall appear (in that order) before the
14987 argument (if any) to be converted. A negative field width argument is taken as a - flag
14988 followed by a positive field width. A negative precision argument is taken as if the
14989 precision were omitted.
14991 The flag characters and their meanings are:
14992 - The result of the conversion is left-justified within the field. (It is right-justified if
14994 this flag is not specified.)</pre>
14995 + The result of a signed conversion always begins with a plus or minus sign. (It
14997 begins with a sign only when a negative value is converted if this flag is not
14998 specified.)<sup><a href="#note269"><b>269)</b></a></sup></pre>
14999 space If the first character of a signed conversion is not a sign, or if a signed conversion
15001 results in no characters, a space is prefixed to the result. If the space and + flags
15002 both appear, the space flag is ignored.</pre>
15003 # The result is converted to an ''alternative form''. For o conversion, it increases
15005 the precision, if and only if necessary, to force the first digit of the result to be a
15006 zero (if the value and precision are both 0, a single 0 is printed). For x (or X)
15007 conversion, a nonzero result has 0x (or 0X) prefixed to it. For a, A, e, E, f, F, g,
15008 and G conversions, the result of converting a floating-point number always
15009 contains a decimal-point character, even if no digits follow it. (Normally, a
15010 decimal-point character appears in the result of these conversions only if a digit
15011 follows it.) For g and G conversions, trailing zeros are not removed from the
15012 result. For other conversions, the behavior is undefined.</pre>
15013 0 For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions, leading zeros
15015 (following any indication of sign or base) are used to pad to the field width rather
15016 than performing space padding, except when converting an infinity or NaN. If the
15017 0 and - flags both appear, the 0 flag is ignored. For d, i, o, u, x, and X</pre>
15020 <!--page 329 indent 4-->
15023 conversions, if a precision is specified, the 0 flag is ignored. For other
15024 conversions, the behavior is undefined.</pre>
15025 The length modifiers and their meanings are:
15026 hh Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15028 signed char or unsigned char argument (the argument will have
15029 been promoted according to the integer promotions, but its value shall be
15030 converted to signed char or unsigned char before printing); or that
15031 a following n conversion specifier applies to a pointer to a signed char
15033 h Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15035 short int or unsigned short int argument (the argument will
15036 have been promoted according to the integer promotions, but its value shall
15037 be converted to short int or unsigned short int before printing);
15038 or that a following n conversion specifier applies to a pointer to a short
15039 int argument.</pre>
15040 l (ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15042 long int or unsigned long int argument; that a following n
15043 conversion specifier applies to a pointer to a long int argument; that a
15044 following c conversion specifier applies to a wint_t argument; that a
15045 following s conversion specifier applies to a pointer to a wchar_t
15046 argument; or has no effect on a following a, A, e, E, f, F, g, or G conversion
15048 ll (ell-ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15050 long long int or unsigned long long int argument; or that a
15051 following n conversion specifier applies to a pointer to a long long int
15053 j Specifies that a following d, i, o, u, x, or X conversion specifier applies to
15055 an intmax_t or uintmax_t argument; or that a following n conversion
15056 specifier applies to a pointer to an intmax_t argument.</pre>
15057 z Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15059 size_t or the corresponding signed integer type argument; or that a
15060 following n conversion specifier applies to a pointer to a signed integer type
15061 corresponding to size_t argument.</pre>
15062 t Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
15063 <!--page 330 indent 4-->
15065 ptrdiff_t or the corresponding unsigned integer type argument; or that a
15066 following n conversion specifier applies to a pointer to a ptrdiff_t
15068 L Specifies that a following a, A, e, E, f, F, g, or G conversion specifier
15070 applies to a long double argument.</pre>
15071 If a length modifier appears with any conversion specifier other than as specified above,
15072 the behavior is undefined.
15074 The conversion specifiers and their meanings are:
15075 d,i The int argument is converted to signed decimal in the style [-]dddd. The
15077 precision specifies the minimum number of digits to appear; if the value
15078 being converted can be represented in fewer digits, it is expanded with
15079 leading zeros. The default precision is 1. The result of converting a zero
15080 value with a precision of zero is no characters.</pre>
15081 o,u,x,X The unsigned int argument is converted to unsigned octal (o), unsigned
15083 decimal (u), or unsigned hexadecimal notation (x or X) in the style dddd; the
15084 letters abcdef are used for x conversion and the letters ABCDEF for X
15085 conversion. The precision specifies the minimum number of digits to appear;
15086 if the value being converted can be represented in fewer digits, it is expanded
15087 with leading zeros. The default precision is 1. The result of converting a
15088 zero value with a precision of zero is no characters.</pre>
15089 f,F A double argument representing a floating-point number is converted to
15091 decimal notation in the style [-]ddd.ddd, where the number of digits after
15092 the decimal-point character is equal to the precision specification. If the
15093 precision is missing, it is taken as 6; if the precision is zero and the # flag is
15094 not specified, no decimal-point character appears. If a decimal-point
15095 character appears, at least one digit appears before it. The value is rounded to
15096 the appropriate number of digits.
15097 A double argument representing an infinity is converted in one of the styles
15098 [-]inf or [-]infinity -- which style is implementation-defined. A
15099 double argument representing a NaN is converted in one of the styles
15100 [-]nan or [-]nan(n-char-sequence) -- which style, and the meaning of
15101 any n-char-sequence, is implementation-defined. The F conversion specifier
15102 produces INF, INFINITY, or NAN instead of inf, infinity, or nan,
15103 respectively.<sup><a href="#note270"><b>270)</b></a></sup></pre>
15104 e,E A double argument representing a floating-point number is converted in the
15106 style [-]d.ddd e(+-)dd, where there is one digit (which is nonzero if the
15107 argument is nonzero) before the decimal-point character and the number of
15108 digits after it is equal to the precision; if the precision is missing, it is taken as</pre>
15111 <!--page 331 indent 0-->
15113 6; if the precision is zero and the # flag is not specified, no decimal-point
15114 character appears. The value is rounded to the appropriate number of digits.
15115 The E conversion specifier produces a number with E instead of e
15116 introducing the exponent. The exponent always contains at least two digits,
15117 and only as many more digits as necessary to represent the exponent. If the
15118 value is zero, the exponent is zero.
15119 A double argument representing an infinity or NaN is converted in the style
15120 of an f or F conversion specifier.</pre>
15121 g,G A double argument representing a floating-point number is converted in
15123 style f or e (or in style F or E in the case of a G conversion specifier),
15124 depending on the value converted and the precision. Let P equal the
15125 precision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero.
15126 Then, if a conversion with style E would have an exponent of X:
15127 -- if P > X >= -4, the conversion is with style f (or F) and precision
15129 -- otherwise, the conversion is with style e (or E) and precision P - 1.
15130 Finally, unless the # flag is used, any trailing zeros are removed from the
15131 fractional portion of the result and the decimal-point character is removed if
15132 there is no fractional portion remaining.
15133 A double argument representing an infinity or NaN is converted in the style
15134 of an f or F conversion specifier.</pre>
15135 a,A A double argument representing a floating-point number is converted in the
15137 style [-]0xh.hhhh p(+-)d, where there is one hexadecimal digit (which is
15138 nonzero if the argument is a normalized floating-point number and is
15139 otherwise unspecified) before the decimal-point character<sup><a href="#note271"><b>271)</b></a></sup> and the number
15140 of hexadecimal digits after it is equal to the precision; if the precision is
15141 missing and FLT_RADIX is a power of 2, then the precision is sufficient for
15142 an exact representation of the value; if the precision is missing and
15143 FLT_RADIX is not a power of 2, then the precision is sufficient to</pre>
15148 <!--page 332 indent 0-->
15150 distinguish<sup><a href="#note272"><b>272)</b></a></sup> values of type double, except that trailing zeros may be
15151 omitted; if the precision is zero and the # flag is not specified, no decimal-
15152 point character appears. The letters abcdef are used for a conversion and
15153 the letters ABCDEF for A conversion. The A conversion specifier produces a
15154 number with X and P instead of x and p. The exponent always contains at
15155 least one digit, and only as many more digits as necessary to represent the
15156 decimal exponent of 2. If the value is zero, the exponent is zero.
15157 A double argument representing an infinity or NaN is converted in the style
15158 of an f or F conversion specifier.</pre>
15159 c If no l length modifier is present, the int argument is converted to an
15161 unsigned char, and the resulting character is written.
15162 If an l length modifier is present, the wint_t argument is converted as if by
15163 an ls conversion specification with no precision and an argument that points
15164 to the initial element of a two-element array of wchar_t, the first element
15165 containing the wint_t argument to the lc conversion specification and the
15166 second a null wide character.</pre>
15167 s If no l length modifier is present, the argument shall be a pointer to the initial
15169 element of an array of character type.<sup><a href="#note273"><b>273)</b></a></sup> Characters from the array are
15170 written up to (but not including) the terminating null character. If the
15171 precision is specified, no more than that many bytes are written. If the
15172 precision is not specified or is greater than the size of the array, the array shall
15173 contain a null character.
15174 If an l length modifier is present, the argument shall be a pointer to the initial
15175 element of an array of wchar_t type. Wide characters from the array are
15176 converted to multibyte characters (each as if by a call to the wcrtomb
15177 function, with the conversion state described by an mbstate_t object
15178 initialized to zero before the first wide character is converted) up to and
15179 including a terminating null wide character. The resulting multibyte
15180 characters are written up to (but not including) the terminating null character
15181 (byte). If no precision is specified, the array shall contain a null wide
15182 character. If a precision is specified, no more than that many bytes are
15183 written (including shift sequences, if any), and the array shall contain a null
15184 wide character if, to equal the multibyte character sequence length given by</pre>
15186 <!--page 333 indent 5-->
15188 the precision, the function would need to access a wide character one past the
15189 end of the array. In no case is a partial multibyte character written.<sup><a href="#note274"><b>274)</b></a></sup></pre>
15190 p The argument shall be a pointer to void. The value of the pointer is
15192 converted to a sequence of printing characters, in an implementation-defined
15194 n The argument shall be a pointer to signed integer into which is written the
15196 number of characters written to the output stream so far by this call to
15197 fprintf. No argument is converted, but one is consumed. If the conversion
15198 specification includes any flags, a field width, or a precision, the behavior is
15200 % A % character is written. No argument is converted. The complete
15203 conversion specification shall be %%.</pre>
15204 If a conversion specification is invalid, the behavior is undefined.<sup><a href="#note275"><b>275)</b></a></sup> If any argument is
15205 not the correct type for the corresponding conversion specification, the behavior is
15208 In no case does a nonexistent or small field width cause truncation of a field; if the result
15209 of a conversion is wider than the field width, the field is expanded to contain the
15212 For a and A conversions, if FLT_RADIX is a power of 2, the value is correctly rounded
15213 to a hexadecimal floating number with the given precision.
15214 Recommended practice
15216 For a and A conversions, if FLT_RADIX is not a power of 2 and the result is not exactly
15217 representable in the given precision, the result should be one of the two adjacent numbers
15218 in hexadecimal floating style with the given precision, with the extra stipulation that the
15219 error should have a correct sign for the current rounding direction.
15221 For e, E, f, F, g, and G conversions, if the number of significant decimal digits is at most
15222 DECIMAL_DIG, then the result should be correctly rounded.<sup><a href="#note276"><b>276)</b></a></sup> If the number of
15223 significant decimal digits is more than DECIMAL_DIG but the source value is exactly
15224 representable with DECIMAL_DIG digits, then the result should be an exact
15225 representation with trailing zeros. Otherwise, the source value is bounded by two
15226 adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value
15229 <!--page 334 indent 5-->
15230 of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
15231 the error should have a correct sign for the current rounding direction.
15234 The fprintf function returns the number of characters transmitted, or a negative value
15235 if an output or encoding error occurred.
15236 Environmental limits
15238 The number of characters that can be produced by any single conversion shall be at least
15241 EXAMPLE 1 To print a date and time in the form ''Sunday, July 3, 10:02'' followed by pi to five decimal
15244 #include <math.h>
15245 #include <stdio.h>
15247 char *weekday, *month; // pointers to strings
15248 int day, hour, min;
15249 fprintf(stdout, "%s, %s %d, %.2d:%.2d\n",
15250 weekday, month, day, hour, min);
15251 fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0));</pre>
15254 EXAMPLE 2 In this example, multibyte characters do not have a state-dependent encoding, and the
15255 members of the extended character set that consist of more than one byte each consist of exactly two bytes,
15256 the first of which is denoted here by a and the second by an uppercase letter.
15258 Given the following wide string with length seven,
15260 static wchar_t wstr[] = L" X Yabc Z W";</pre>
15263 fprintf(stdout, "|1234567890123|\n");
15264 fprintf(stdout, "|%13ls|\n", wstr);
15265 fprintf(stdout, "|%-13.9ls|\n", wstr);
15266 fprintf(stdout, "|%13.10ls|\n", wstr);
15267 fprintf(stdout, "|%13.11ls|\n", wstr);
15268 fprintf(stdout, "|%13.15ls|\n", &wstr[2]);
15269 fprintf(stdout, "|%13lc|\n", (wint_t) wstr[5]);</pre>
15270 will print the following seven lines:
15280 Forward references: conversion state (<a href="#7.28.6">7.28.6</a>), the wcrtomb function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
15281 <!--page 335 indent 4-->
15284 <p><a name="note268">268)</a> Note that 0 is taken as a flag, not as the beginning of a field width.
15286 <p><a name="note269">269)</a> The results of all floating conversions of a negative zero, and of negative values that round to zero,
15287 include a minus sign.
15289 <p><a name="note270">270)</a> When applied to infinite and NaN values, the -, +, and space flag characters have their usual meaning;
15290 the # and 0 flag characters have no effect.
15292 <p><a name="note271">271)</a> Binary implementations can choose the hexadecimal digit to the left of the decimal-point character so
15293 that subsequent digits align to nibble (4-bit) boundaries.
15295 <p><a name="note272">272)</a> The precision p is sufficient to distinguish values of the source type if 16 p-1 > b n where b is
15296 FLT_RADIX and n is the number of base-b digits in the significand of the source type. A smaller p
15297 might suffice depending on the implementation's scheme for determining the digit to the left of the
15298 decimal-point character.
15300 <p><a name="note273">273)</a> No special provisions are made for multibyte characters.
15302 <p><a name="note274">274)</a> Redundant shift sequences may result if multibyte characters have a state-dependent encoding.
15304 <p><a name="note275">275)</a> See ''future library directions'' (<a href="#7.30.9">7.30.9</a>).
15306 <p><a name="note276">276)</a> For binary-to-decimal conversion, the result format's values are the numbers representable with the
15307 given format specifier. The number of significant digits is determined by the format specifier, and in
15308 the case of fixed-point conversion by the source value as well.
15311 <a name="7.21.6.2" href="#7.21.6.2"><h5>7.21.6.2 The fscanf function</h5></a>
15315 #include <stdio.h>
15316 int fscanf(FILE * restrict stream,
15317 const char * restrict format, ...);</pre>
15318 <h6>Description</h6>
15320 The fscanf function reads input from the stream pointed to by stream, under control
15321 of the string pointed to by format that specifies the admissible input sequences and how
15322 they are to be converted for assignment, using subsequent arguments as pointers to the
15323 objects to receive the converted input. If there are insufficient arguments for the format,
15324 the behavior is undefined. If the format is exhausted while arguments remain, the excess
15325 arguments are evaluated (as always) but are otherwise ignored.
15327 The format shall be a multibyte character sequence, beginning and ending in its initial
15328 shift state. The format is composed of zero or more directives: one or more white-space
15329 characters, an ordinary multibyte character (neither % nor a white-space character), or a
15330 conversion specification. Each conversion specification is introduced by the character %.
15331 After the %, the following appear in sequence:
15333 <li> An optional assignment-suppressing character *.
15334 <li> An optional decimal integer greater than zero that specifies the maximum field width
15336 <li> An optional length modifier that specifies the size of the receiving object.
15337 <li> A conversion specifier character that specifies the type of conversion to be applied.
15340 The fscanf function executes each directive of the format in turn. When all directives
15341 have been executed, or if a directive fails (as detailed below), the function returns.
15342 Failures are described as input failures (due to the occurrence of an encoding error or the
15343 unavailability of input characters), or matching failures (due to inappropriate input).
15345 A directive composed of white-space character(s) is executed by reading input up to the
15346 first non-white-space character (which remains unread), or until no more characters can
15349 A directive that is an ordinary multibyte character is executed by reading the next
15350 characters of the stream. If any of those characters differ from the ones composing the
15351 directive, the directive fails and the differing and subsequent characters remain unread.
15352 Similarly, if end-of-file, an encoding error, or a read error prevents a character from being
15353 read, the directive fails.
15355 A directive that is a conversion specification defines a set of matching input sequences, as
15356 described below for each specifier. A conversion specification is executed in the
15357 <!--page 336 indent 5-->
15360 Input white-space characters (as specified by the isspace function) are skipped, unless
15361 the specification includes a [, c, or n specifier.<sup><a href="#note277"><b>277)</b></a></sup>
15363 An input item is read from the stream, unless the specification includes an n specifier. An
15364 input item is defined as the longest sequence of input characters which does not exceed
15365 any specified field width and which is, or is a prefix of, a matching input sequence.<sup><a href="#note278"><b>278)</b></a></sup>
15366 The first character, if any, after the input item remains unread. If the length of the input
15367 item is zero, the execution of the directive fails; this condition is a matching failure unless
15368 end-of-file, an encoding error, or a read error prevented input from the stream, in which
15369 case it is an input failure.
15371 Except in the case of a % specifier, the input item (or, in the case of a %n directive, the
15372 count of input characters) is converted to a type appropriate to the conversion specifier. If
15373 the input item is not a matching sequence, the execution of the directive fails: this
15374 condition is a matching failure. Unless assignment suppression was indicated by a *, the
15375 result of the conversion is placed in the object pointed to by the first argument following
15376 the format argument that has not already received a conversion result. If this object
15377 does not have an appropriate type, or if the result of the conversion cannot be represented
15378 in the object, the behavior is undefined.
15380 The length modifiers and their meanings are:
15381 hh Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15383 to an argument with type pointer to signed char or unsigned char.</pre>
15384 h Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15386 to an argument with type pointer to short int or unsigned short
15388 l (ell) Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15390 to an argument with type pointer to long int or unsigned long
15391 int; that a following a, A, e, E, f, F, g, or G conversion specifier applies to
15392 an argument with type pointer to double; or that a following c, s, or [
15393 conversion specifier applies to an argument with type pointer to wchar_t.</pre>
15394 ll (ell-ell) Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15396 to an argument with type pointer to long long int or unsigned
15397 long long int.</pre>
15401 <!--page 337 indent 5-->
15402 j Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15404 to an argument with type pointer to intmax_t or uintmax_t.</pre>
15405 z Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15407 to an argument with type pointer to size_t or the corresponding signed
15408 integer type.</pre>
15409 t Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
15411 to an argument with type pointer to ptrdiff_t or the corresponding
15412 unsigned integer type.</pre>
15413 L Specifies that a following a, A, e, E, f, F, g, or G conversion specifier
15415 applies to an argument with type pointer to long double.</pre>
15416 If a length modifier appears with any conversion specifier other than as specified above,
15417 the behavior is undefined.
15419 The conversion specifiers and their meanings are:
15420 d Matches an optionally signed decimal integer, whose format is the same as
15422 expected for the subject sequence of the strtol function with the value 10
15423 for the base argument. The corresponding argument shall be a pointer to
15424 signed integer.</pre>
15425 i Matches an optionally signed integer, whose format is the same as expected
15427 for the subject sequence of the strtol function with the value 0 for the
15428 base argument. The corresponding argument shall be a pointer to signed
15430 o Matches an optionally signed octal integer, whose format is the same as
15432 expected for the subject sequence of the strtoul function with the value 8
15433 for the base argument. The corresponding argument shall be a pointer to
15434 unsigned integer.</pre>
15435 u Matches an optionally signed decimal integer, whose format is the same as
15437 expected for the subject sequence of the strtoul function with the value 10
15438 for the base argument. The corresponding argument shall be a pointer to
15439 unsigned integer.</pre>
15440 x Matches an optionally signed hexadecimal integer, whose format is the same
15442 as expected for the subject sequence of the strtoul function with the value
15443 16 for the base argument. The corresponding argument shall be a pointer to
15444 unsigned integer.</pre>
15445 a,e,f,g Matches an optionally signed floating-point number, infinity, or NaN, whose
15446 <!--page 338 indent 0-->
15448 format is the same as expected for the subject sequence of the strtod
15449 function. The corresponding argument shall be a pointer to floating.</pre>
15450 c Matches a sequence of characters of exactly the number specified by the field
15452 width (1 if no field width is present in the directive).<sup><a href="#note279"><b>279)</b></a></sup>
15453 If no l length modifier is present, the corresponding argument shall be a
15454 pointer to the initial element of a character array large enough to accept the
15455 sequence. No null character is added.
15456 If an l length modifier is present, the input shall be a sequence of multibyte
15457 characters that begins in the initial shift state. Each multibyte character in the
15458 sequence is converted to a wide character as if by a call to the mbrtowc
15459 function, with the conversion state described by an mbstate_t object
15460 initialized to zero before the first multibyte character is converted. The
15461 corresponding argument shall be a pointer to the initial element of an array of
15462 wchar_t large enough to accept the resulting sequence of wide characters.
15463 No null wide character is added.</pre>
15464 s Matches a sequence of non-white-space characters.279)
15466 If no l length modifier is present, the corresponding argument shall be a
15467 pointer to the initial element of a character array large enough to accept the
15468 sequence and a terminating null character, which will be added automatically.
15469 If an l length modifier is present, the input shall be a sequence of multibyte
15470 characters that begins in the initial shift state. Each multibyte character is
15471 converted to a wide character as if by a call to the mbrtowc function, with
15472 the conversion state described by an mbstate_t object initialized to zero
15473 before the first multibyte character is converted. The corresponding argument
15474 shall be a pointer to the initial element of an array of wchar_t large enough
15475 to accept the sequence and the terminating null wide character, which will be
15476 added automatically.</pre>
15477 [ Matches a nonempty sequence of characters from a set of expected characters
15480 If no l length modifier is present, the corresponding argument shall be a
15481 pointer to the initial element of a character array large enough to accept the
15482 sequence and a terminating null character, which will be added automatically.
15483 If an l length modifier is present, the input shall be a sequence of multibyte
15484 characters that begins in the initial shift state. Each multibyte character is
15485 converted to a wide character as if by a call to the mbrtowc function, with
15486 the conversion state described by an mbstate_t object initialized to zero</pre>
15488 <!--page 339 indent 5-->
15490 before the first multibyte character is converted. The corresponding argument
15491 shall be a pointer to the initial element of an array of wchar_t large enough
15492 to accept the sequence and the terminating null wide character, which will be
15493 added automatically.
15494 The conversion specifier includes all subsequent characters in the format
15495 string, up to and including the matching right bracket (]). The characters
15496 between the brackets (the scanlist) compose the scanset, unless the character
15497 after the left bracket is a circumflex (^), in which case the scanset contains all
15498 characters that do not appear in the scanlist between the circumflex and the
15499 right bracket. If the conversion specifier begins with [] or [^], the right
15500 bracket character is in the scanlist and the next following right bracket
15501 character is the matching right bracket that ends the specification; otherwise
15502 the first following right bracket character is the one that ends the
15503 specification. If a - character is in the scanlist and is not the first, nor the
15504 second where the first character is a ^, nor the last character, the behavior is
15505 implementation-defined.</pre>
15506 p Matches an implementation-defined set of sequences, which should be the
15508 same as the set of sequences that may be produced by the %p conversion of
15509 the fprintf function. The corresponding argument shall be a pointer to a
15510 pointer to void. The input item is converted to a pointer value in an
15511 implementation-defined manner. If the input item is a value converted earlier
15512 during the same program execution, the pointer that results shall compare
15513 equal to that value; otherwise the behavior of the %p conversion is undefined.</pre>
15514 n No input is consumed. The corresponding argument shall be a pointer to
15516 signed integer into which is to be written the number of characters read from
15517 the input stream so far by this call to the fscanf function. Execution of a
15518 %n directive does not increment the assignment count returned at the
15519 completion of execution of the fscanf function. No argument is converted,
15520 but one is consumed. If the conversion specification includes an assignment-
15521 suppressing character or a field width, the behavior is undefined.</pre>
15522 % Matches a single % character; no conversion or assignment occurs. The
15525 complete conversion specification shall be %%.</pre>
15526 If a conversion specification is invalid, the behavior is undefined.<sup><a href="#note280"><b>280)</b></a></sup>
15528 The conversion specifiers A, E, F, G, and X are also valid and behave the same as,
15529 respectively, a, e, f, g, and x.
15533 <!--page 340 indent 5-->
15535 Trailing white space (including new-line characters) is left unread unless matched by a
15536 directive. The success of literal matches and suppressed assignments is not directly
15537 determinable other than via the %n directive.
15540 The fscanf function returns the value of the macro EOF if an input failure occurs
15541 before the first conversion (if any) has completed. Otherwise, the function returns the
15542 number of input items assigned, which can be fewer than provided for, or even zero, in
15543 the event of an early matching failure.
15545 EXAMPLE 1 The call:
15547 #include <stdio.h>
15549 int n, i; float x; char name[50];
15550 n = fscanf(stdin, "%d%f%s", &i, &x, name);</pre>
15551 with the input line:
15553 25 54.32E-1 thompson</pre>
15554 will assign to n the value 3, to i the value 25, to x the value 5.432, and to name the sequence
15558 EXAMPLE 2 The call:
15560 #include <stdio.h>
15562 int i; float x; char name[50];
15563 fscanf(stdin, "%2d%f%*d %[0123456789]", &i, &x, name);</pre>
15566 56789 0123 56a72</pre>
15567 will assign to i the value 56 and to x the value 789.0, will skip 0123, and will assign to name the
15568 sequence 56\0. The next character read from the input stream will be a.
15571 EXAMPLE 3 To accept repeatedly from stdin a quantity, a unit of measure, and an item name:
15574 #include <stdio.h>
15576 int count; float quant; char units[21], item[21];
15578 count = fscanf(stdin, "%f%20s of %20s", &quant, units, item);
15579 fscanf(stdin,"%*[^\n]");
15580 } while (!feof(stdin) && !ferror(stdin));</pre>
15581 If the stdin stream contains the following lines:
15582 <!--page 341 indent 5-->
15585 -12.8degrees Celsius
15589 100ergs of energy</pre>
15590 the execution of the above example will be analogous to the following assignments:
15592 quant = 2; strcpy(units, "quarts"); strcpy(item, "oil");
15594 quant = -12.8; strcpy(units, "degrees");
15595 count = 2; // "C" fails to match "o"
15596 count = 0; // "l" fails to match "%f"
15597 quant = 10.0; strcpy(units, "LBS"); strcpy(item, "dirt");
15599 count = 0; // "100e" fails to match "%f"
15605 #include <stdio.h>
15607 int d1, d2, n1, n2, i;
15608 i = sscanf("123", "%d%n%n%d", &d1, &n1, &n2, &d2);</pre>
15609 the value 123 is assigned to d1 and the value 3 to n1. Because %n can never get an input failure the value
15610 of 3 is also assigned to n2. The value of d2 is not affected. The value 1 is assigned to i.
15613 EXAMPLE 5 In these examples, multibyte characters do have a state-dependent encoding, and the
15614 members of the extended character set that consist of more than one byte each consist of exactly two bytes,
15615 the first of which is denoted here by a and the second by an uppercase letter, but are only recognized as
15616 such when in the alternate shift state. The shift sequences are denoted by (uparrow) and (downarrow), in which the first causes
15617 entry into the alternate shift state.
15621 #include <stdio.h>
15624 fscanf(stdin, "a%s", str);</pre>
15625 with the input line:
15627 a(uparrow) X Y(downarrow) bc</pre>
15628 str will contain (uparrow) X Y(downarrow)\0 assuming that none of the bytes of the shift sequences (or of the multibyte
15629 characters, in the more general case) appears to be a single-byte white-space character.
15631 In contrast, after the call:
15633 #include <stdio.h>
15634 #include <stddef.h>
15637 fscanf(stdin, "a%ls", wstr);</pre>
15638 with the same input line, wstr will contain the two wide characters that correspond to X and Y and a
15639 terminating null wide character.
15642 <!--page 342 indent 5-->
15644 #include <stdio.h>
15645 #include <stddef.h>
15648 fscanf(stdin, "a(uparrow) X(downarrow)%ls", wstr);</pre>
15649 with the same input line will return zero due to a matching failure against the (downarrow) sequence in the format
15652 Assuming that the first byte of the multibyte character X is the same as the first byte of the multibyte
15653 character Y, after the call:
15655 #include <stdio.h>
15656 #include <stddef.h>
15659 fscanf(stdin, "a(uparrow) Y(downarrow)%ls", wstr);</pre>
15660 with the same input line, zero will again be returned, but stdin will be left with a partially consumed
15661 multibyte character.
15663 Forward references: the strtod, strtof, and strtold functions (<a href="#7.22.1.3">7.22.1.3</a>), the
15664 strtol, strtoll, strtoul, and strtoull functions (<a href="#7.22.1.4">7.22.1.4</a>), conversion state
15665 (<a href="#7.28.6">7.28.6</a>), the wcrtomb function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
15668 <p><a name="note277">277)</a> These white-space characters are not counted against a specified field width.
15670 <p><a name="note278">278)</a> fscanf pushes back at most one input character onto the input stream. Therefore, some sequences
15671 that are acceptable to strtod, strtol, etc., are unacceptable to fscanf.
15673 <p><a name="note279">279)</a> No special provisions are made for multibyte characters in the matching rules used by the c, s, and [
15674 conversion specifiers -- the extent of the input field is determined on a byte-by-byte basis. The
15675 resulting field is nevertheless a sequence of multibyte characters that begins in the initial shift state.
15677 <p><a name="note280">280)</a> See ''future library directions'' (<a href="#7.30.9">7.30.9</a>).
15680 <a name="7.21.6.3" href="#7.21.6.3"><h5>7.21.6.3 The printf function</h5></a>
15684 #include <stdio.h>
15685 int printf(const char * restrict format, ...);</pre>
15686 <h6>Description</h6>
15688 The printf function is equivalent to fprintf with the argument stdout interposed
15689 before the arguments to printf.
15692 The printf function returns the number of characters transmitted, or a negative value if
15693 an output or encoding error occurred.
15695 <a name="7.21.6.4" href="#7.21.6.4"><h5>7.21.6.4 The scanf function</h5></a>
15699 #include <stdio.h>
15700 int scanf(const char * restrict format, ...);</pre>
15701 <h6>Description</h6>
15703 The scanf function is equivalent to fscanf with the argument stdin interposed
15704 before the arguments to scanf.
15705 <!--page 343 indent 4-->
15708 The scanf function returns the value of the macro EOF if an input failure occurs before
15709 the first conversion (if any) has completed. Otherwise, the scanf function returns the
15710 number of input items assigned, which can be fewer than provided for, or even zero, in
15711 the event of an early matching failure.
15713 <a name="7.21.6.5" href="#7.21.6.5"><h5>7.21.6.5 The snprintf function</h5></a>
15717 #include <stdio.h>
15718 int snprintf(char * restrict s, size_t n,
15719 const char * restrict format, ...);</pre>
15720 <h6>Description</h6>
15722 The snprintf function is equivalent to fprintf, except that the output is written into
15723 an array (specified by argument s) rather than to a stream. If n is zero, nothing is written,
15724 and s may be a null pointer. Otherwise, output characters beyond the n-1st are
15725 discarded rather than being written to the array, and a null character is written at the end
15726 of the characters actually written into the array. If copying takes place between objects
15727 that overlap, the behavior is undefined.
15730 The snprintf function returns the number of characters that would have been written
15731 had n been sufficiently large, not counting the terminating null character, or a negative
15732 value if an encoding error occurred. Thus, the null-terminated output has been
15733 completely written if and only if the returned value is nonnegative and less than n.
15735 <a name="7.21.6.6" href="#7.21.6.6"><h5>7.21.6.6 The sprintf function</h5></a>
15739 #include <stdio.h>
15740 int sprintf(char * restrict s,
15741 const char * restrict format, ...);</pre>
15742 <h6>Description</h6>
15744 The sprintf function is equivalent to fprintf, except that the output is written into
15745 an array (specified by the argument s) rather than to a stream. A null character is written
15746 at the end of the characters written; it is not counted as part of the returned value. If
15747 copying takes place between objects that overlap, the behavior is undefined.
15750 The sprintf function returns the number of characters written in the array, not
15751 counting the terminating null character, or a negative value if an encoding error occurred.
15752 <!--page 344 indent 4-->
15754 <a name="7.21.6.7" href="#7.21.6.7"><h5>7.21.6.7 The sscanf function</h5></a>
15758 #include <stdio.h>
15759 int sscanf(const char * restrict s,
15760 const char * restrict format, ...);</pre>
15761 <h6>Description</h6>
15763 The sscanf function is equivalent to fscanf, except that input is obtained from a
15764 string (specified by the argument s) rather than from a stream. Reaching the end of the
15765 string is equivalent to encountering end-of-file for the fscanf function. If copying
15766 takes place between objects that overlap, the behavior is undefined.
15769 The sscanf function returns the value of the macro EOF if an input failure occurs
15770 before the first conversion (if any) has completed. Otherwise, the sscanf function
15771 returns the number of input items assigned, which can be fewer than provided for, or even
15772 zero, in the event of an early matching failure.
15774 <a name="7.21.6.8" href="#7.21.6.8"><h5>7.21.6.8 The vfprintf function</h5></a>
15778 #include <stdarg.h>
15779 #include <stdio.h>
15780 int vfprintf(FILE * restrict stream,
15781 const char * restrict format,
15782 va_list arg);</pre>
15783 <h6>Description</h6>
15785 The vfprintf function is equivalent to fprintf, with the variable argument list
15786 replaced by arg, which shall have been initialized by the va_start macro (and
15787 possibly subsequent va_arg calls). The vfprintf function does not invoke the
15788 va_end macro.<sup><a href="#note281"><b>281)</b></a></sup>
15791 The vfprintf function returns the number of characters transmitted, or a negative
15792 value if an output or encoding error occurred.
15794 EXAMPLE The following shows the use of the vfprintf function in a general error-reporting routine.
15799 <!--page 345 indent 4-->
15801 #include <stdarg.h>
15802 #include <stdio.h>
15803 void error(char *function_name, char *format, ...)
15806 va_start(args, format);
15807 // print out name of function causing error
15808 fprintf(stderr, "ERROR in %s: ", function_name);
15809 // print out remainder of message
15810 vfprintf(stderr, format, args);
15816 <p><a name="note281">281)</a> As the functions vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf, and
15817 vsscanf invoke the va_arg macro, the value of arg after the return is indeterminate.
15820 <a name="7.21.6.9" href="#7.21.6.9"><h5>7.21.6.9 The vfscanf function</h5></a>
15824 #include <stdarg.h>
15825 #include <stdio.h>
15826 int vfscanf(FILE * restrict stream,
15827 const char * restrict format,
15828 va_list arg);</pre>
15829 <h6>Description</h6>
15831 The vfscanf function is equivalent to fscanf, with the variable argument list
15832 replaced by arg, which shall have been initialized by the va_start macro (and
15833 possibly subsequent va_arg calls). The vfscanf function does not invoke the
15837 The vfscanf function returns the value of the macro EOF if an input failure occurs
15838 before the first conversion (if any) has completed. Otherwise, the vfscanf function
15839 returns the number of input items assigned, which can be fewer than provided for, or even
15840 zero, in the event of an early matching failure.
15842 <a name="7.21.6.10" href="#7.21.6.10"><h5>7.21.6.10 The vprintf function</h5></a>
15846 #include <stdarg.h>
15847 #include <stdio.h>
15848 int vprintf(const char * restrict format,
15849 va_list arg);</pre>
15850 <h6>Description</h6>
15852 The vprintf function is equivalent to printf, with the variable argument list
15853 replaced by arg, which shall have been initialized by the va_start macro (and
15854 <!--page 346 indent 4-->
15855 possibly subsequent va_arg calls). The vprintf function does not invoke the
15859 The vprintf function returns the number of characters transmitted, or a negative value
15860 if an output or encoding error occurred.
15862 <a name="7.21.6.11" href="#7.21.6.11"><h5>7.21.6.11 The vscanf function</h5></a>
15866 #include <stdarg.h>
15867 #include <stdio.h>
15868 int vscanf(const char * restrict format,
15869 va_list arg);</pre>
15870 <h6>Description</h6>
15872 The vscanf function is equivalent to scanf, with the variable argument list replaced
15873 by arg, which shall have been initialized by the va_start macro (and possibly
15874 subsequent va_arg calls). The vscanf function does not invoke the va_end
15878 The vscanf function returns the value of the macro EOF if an input failure occurs
15879 before the first conversion (if any) has completed. Otherwise, the vscanf function
15880 returns the number of input items assigned, which can be fewer than provided for, or even
15881 zero, in the event of an early matching failure.
15883 <a name="7.21.6.12" href="#7.21.6.12"><h5>7.21.6.12 The vsnprintf function</h5></a>
15887 #include <stdarg.h>
15888 #include <stdio.h>
15889 int vsnprintf(char * restrict s, size_t n,
15890 const char * restrict format,
15891 va_list arg);</pre>
15892 <h6>Description</h6>
15894 The vsnprintf function is equivalent to snprintf, with the variable argument list
15895 replaced by arg, which shall have been initialized by the va_start macro (and
15896 possibly subsequent va_arg calls). The vsnprintf function does not invoke the
15897 va_end macro.281) If copying takes place between objects that overlap, the behavior is
15899 <!--page 347 indent 4-->
15902 The vsnprintf function returns the number of characters that would have been written
15903 had n been sufficiently large, not counting the terminating null character, or a negative
15904 value if an encoding error occurred. Thus, the null-terminated output has been
15905 completely written if and only if the returned value is nonnegative and less than n.
15907 <a name="7.21.6.13" href="#7.21.6.13"><h5>7.21.6.13 The vsprintf function</h5></a>
15911 #include <stdarg.h>
15912 #include <stdio.h>
15913 int vsprintf(char * restrict s,
15914 const char * restrict format,
15915 va_list arg);</pre>
15916 <h6>Description</h6>
15918 The vsprintf function is equivalent to sprintf, with the variable argument list
15919 replaced by arg, which shall have been initialized by the va_start macro (and
15920 possibly subsequent va_arg calls). The vsprintf function does not invoke the
15921 va_end macro.281) If copying takes place between objects that overlap, the behavior is
15925 The vsprintf function returns the number of characters written in the array, not
15926 counting the terminating null character, or a negative value if an encoding error occurred.
15928 <a name="7.21.6.14" href="#7.21.6.14"><h5>7.21.6.14 The vsscanf function</h5></a>
15932 #include <stdarg.h>
15933 #include <stdio.h>
15934 int vsscanf(const char * restrict s,
15935 const char * restrict format,
15936 va_list arg);</pre>
15937 <h6>Description</h6>
15939 The vsscanf function is equivalent to sscanf, with the variable argument list
15940 replaced by arg, which shall have been initialized by the va_start macro (and
15941 possibly subsequent va_arg calls). The vsscanf function does not invoke the
15945 The vsscanf function returns the value of the macro EOF if an input failure occurs
15946 before the first conversion (if any) has completed. Otherwise, the vsscanf function
15947 <!--page 348 indent 4-->
15948 returns the number of input items assigned, which can be fewer than provided for, or even
15949 zero, in the event of an early matching failure.
15951 <a name="7.21.7" href="#7.21.7"><h4>7.21.7 Character input/output functions</h4></a>
15953 <a name="7.21.7.1" href="#7.21.7.1"><h5>7.21.7.1 The fgetc function</h5></a>
15957 #include <stdio.h>
15958 int fgetc(FILE *stream);</pre>
15959 <h6>Description</h6>
15961 If the end-of-file indicator for the input stream pointed to by stream is not set and a
15962 next character is present, the fgetc function obtains that character as an unsigned
15963 char converted to an int and advances the associated file position indicator for the
15964 stream (if defined).
15967 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
15968 of-file indicator for the stream is set and the fgetc function returns EOF. Otherwise, the
15969 fgetc function returns the next character from the input stream pointed to by stream.
15970 If a read error occurs, the error indicator for the stream is set and the fgetc function
15971 returns EOF.<sup><a href="#note282"><b>282)</b></a></sup>
15974 <p><a name="note282">282)</a> An end-of-file and a read error can be distinguished by use of the feof and ferror functions.
15977 <a name="7.21.7.2" href="#7.21.7.2"><h5>7.21.7.2 The fgets function</h5></a>
15981 #include <stdio.h>
15982 char *fgets(char * restrict s, int n,
15983 FILE * restrict stream);</pre>
15984 <h6>Description</h6>
15986 The fgets function reads at most one less than the number of characters specified by n
15987 from the stream pointed to by stream into the array pointed to by s. No additional
15988 characters are read after a new-line character (which is retained) or after end-of-file. A
15989 null character is written immediately after the last character read into the array.
15992 The fgets function returns s if successful. If end-of-file is encountered and no
15993 characters have been read into the array, the contents of the array remain unchanged and a
15994 null pointer is returned. If a read error occurs during the operation, the array contents are
15995 indeterminate and a null pointer is returned.
15997 <!--page 349 indent 4-->
15999 <a name="7.21.7.3" href="#7.21.7.3"><h5>7.21.7.3 The fputc function</h5></a>
16003 #include <stdio.h>
16004 int fputc(int c, FILE *stream);</pre>
16005 <h6>Description</h6>
16007 The fputc function writes the character specified by c (converted to an unsigned
16008 char) to the output stream pointed to by stream, at the position indicated by the
16009 associated file position indicator for the stream (if defined), and advances the indicator
16010 appropriately. If the file cannot support positioning requests, or if the stream was opened
16011 with append mode, the character is appended to the output stream.
16014 The fputc function returns the character written. If a write error occurs, the error
16015 indicator for the stream is set and fputc returns EOF.
16017 <a name="7.21.7.4" href="#7.21.7.4"><h5>7.21.7.4 The fputs function</h5></a>
16021 #include <stdio.h>
16022 int fputs(const char * restrict s,
16023 FILE * restrict stream);</pre>
16024 <h6>Description</h6>
16026 The fputs function writes the string pointed to by s to the stream pointed to by
16027 stream. The terminating null character is not written.
16030 The fputs function returns EOF if a write error occurs; otherwise it returns a
16033 <a name="7.21.7.5" href="#7.21.7.5"><h5>7.21.7.5 The getc function</h5></a>
16037 #include <stdio.h>
16038 int getc(FILE *stream);</pre>
16039 <h6>Description</h6>
16041 The getc function is equivalent to fgetc, except that if it is implemented as a macro, it
16042 may evaluate stream more than once, so the argument should never be an expression
16044 <!--page 350 indent 4-->
16047 The getc function returns the next character from the input stream pointed to by
16048 stream. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
16049 getc returns EOF. If a read error occurs, the error indicator for the stream is set and
16052 <a name="7.21.7.6" href="#7.21.7.6"><h5>7.21.7.6 The getchar function</h5></a>
16056 #include <stdio.h>
16057 int getchar(void);</pre>
16058 <h6>Description</h6>
16060 The getchar function is equivalent to getc with the argument stdin.
16063 The getchar function returns the next character from the input stream pointed to by
16064 stdin. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
16065 getchar returns EOF. If a read error occurs, the error indicator for the stream is set and
16066 getchar returns EOF. *
16068 <a name="7.21.7.7" href="#7.21.7.7"><h5>7.21.7.7 The putc function</h5></a>
16072 #include <stdio.h>
16073 int putc(int c, FILE *stream);</pre>
16074 <h6>Description</h6>
16076 The putc function is equivalent to fputc, except that if it is implemented as a macro, it
16077 may evaluate stream more than once, so that argument should never be an expression
16081 The putc function returns the character written. If a write error occurs, the error
16082 indicator for the stream is set and putc returns EOF.
16084 <a name="7.21.7.8" href="#7.21.7.8"><h5>7.21.7.8 The putchar function</h5></a>
16088 #include <stdio.h>
16089 int putchar(int c);</pre>
16090 <h6>Description</h6>
16092 The putchar function is equivalent to putc with the second argument stdout.
16093 <!--page 351 indent 4-->
16096 The putchar function returns the character written. If a write error occurs, the error
16097 indicator for the stream is set and putchar returns EOF.
16099 <a name="7.21.7.9" href="#7.21.7.9"><h5>7.21.7.9 The puts function</h5></a>
16103 #include <stdio.h>
16104 int puts(const char *s);</pre>
16105 <h6>Description</h6>
16107 The puts function writes the string pointed to by s to the stream pointed to by stdout,
16108 and appends a new-line character to the output. The terminating null character is not
16112 The puts function returns EOF if a write error occurs; otherwise it returns a nonnegative
16115 <a name="7.21.7.10" href="#7.21.7.10"><h5>7.21.7.10 The ungetc function</h5></a>
16119 #include <stdio.h>
16120 int ungetc(int c, FILE *stream);</pre>
16121 <h6>Description</h6>
16123 The ungetc function pushes the character specified by c (converted to an unsigned
16124 char) back onto the input stream pointed to by stream. Pushed-back characters will be
16125 returned by subsequent reads on that stream in the reverse order of their pushing. A
16126 successful intervening call (with the stream pointed to by stream) to a file positioning
16127 function (fseek, fsetpos, or rewind) discards any pushed-back characters for the
16128 stream. The external storage corresponding to the stream is unchanged.
16130 One character of pushback is guaranteed. If the ungetc function is called too many
16131 times on the same stream without an intervening read or file positioning operation on that
16132 stream, the operation may fail.
16134 If the value of c equals that of the macro EOF, the operation fails and the input stream is
16137 A successful call to the ungetc function clears the end-of-file indicator for the stream.
16138 The value of the file position indicator for the stream after reading or discarding all
16139 pushed-back characters shall be the same as it was before the characters were pushed
16140 back. For a text stream, the value of its file position indicator after a successful call to the
16141 ungetc function is unspecified until all pushed-back characters are read or discarded.
16142 <!--page 352 indent 4-->
16143 For a binary stream, its file position indicator is decremented by each successful call to
16144 the ungetc function; if its value was zero before a call, it is indeterminate after the
16145 call.<sup><a href="#note283"><b>283)</b></a></sup>
16148 The ungetc function returns the character pushed back after conversion, or EOF if the
16150 Forward references: file positioning functions (<a href="#7.21.9">7.21.9</a>).
16153 <p><a name="note283">283)</a> See ''future library directions'' (<a href="#7.30.9">7.30.9</a>).
16156 <a name="7.21.8" href="#7.21.8"><h4>7.21.8 Direct input/output functions</h4></a>
16158 <a name="7.21.8.1" href="#7.21.8.1"><h5>7.21.8.1 The fread function</h5></a>
16162 #include <stdio.h>
16163 size_t fread(void * restrict ptr,
16164 size_t size, size_t nmemb,
16165 FILE * restrict stream);</pre>
16166 <h6>Description</h6>
16168 The fread function reads, into the array pointed to by ptr, up to nmemb elements
16169 whose size is specified by size, from the stream pointed to by stream. For each
16170 object, size calls are made to the fgetc function and the results stored, in the order
16171 read, in an array of unsigned char exactly overlaying the object. The file position
16172 indicator for the stream (if defined) is advanced by the number of characters successfully
16173 read. If an error occurs, the resulting value of the file position indicator for the stream is
16174 indeterminate. If a partial element is read, its value is indeterminate.
16177 The fread function returns the number of elements successfully read, which may be
16178 less than nmemb if a read error or end-of-file is encountered. If size or nmemb is zero,
16179 fread returns zero and the contents of the array and the state of the stream remain
16185 <!--page 353 indent 4-->
16187 <a name="7.21.8.2" href="#7.21.8.2"><h5>7.21.8.2 The fwrite function</h5></a>
16191 #include <stdio.h>
16192 size_t fwrite(const void * restrict ptr,
16193 size_t size, size_t nmemb,
16194 FILE * restrict stream);</pre>
16195 <h6>Description</h6>
16197 The fwrite function writes, from the array pointed to by ptr, up to nmemb elements
16198 whose size is specified by size, to the stream pointed to by stream. For each object,
16199 size calls are made to the fputc function, taking the values (in order) from an array of
16200 unsigned char exactly overlaying the object. The file position indicator for the
16201 stream (if defined) is advanced by the number of characters successfully written. If an
16202 error occurs, the resulting value of the file position indicator for the stream is
16206 The fwrite function returns the number of elements successfully written, which will be
16207 less than nmemb only if a write error is encountered. If size or nmemb is zero,
16208 fwrite returns zero and the state of the stream remains unchanged.
16210 <a name="7.21.9" href="#7.21.9"><h4>7.21.9 File positioning functions</h4></a>
16212 <a name="7.21.9.1" href="#7.21.9.1"><h5>7.21.9.1 The fgetpos function</h5></a>
16216 #include <stdio.h>
16217 int fgetpos(FILE * restrict stream,
16218 fpos_t * restrict pos);</pre>
16219 <h6>Description</h6>
16221 The fgetpos function stores the current values of the parse state (if any) and file
16222 position indicator for the stream pointed to by stream in the object pointed to by pos.
16223 The values stored contain unspecified information usable by the fsetpos function for
16224 repositioning the stream to its position at the time of the call to the fgetpos function.
16227 If successful, the fgetpos function returns zero; on failure, the fgetpos function
16228 returns nonzero and stores an implementation-defined positive value in errno.
16229 Forward references: the fsetpos function (<a href="#7.21.9.3">7.21.9.3</a>).
16230 <!--page 354 indent 4-->
16232 <a name="7.21.9.2" href="#7.21.9.2"><h5>7.21.9.2 The fseek function</h5></a>
16236 #include <stdio.h>
16237 int fseek(FILE *stream, long int offset, int whence);</pre>
16238 <h6>Description</h6>
16240 The fseek function sets the file position indicator for the stream pointed to by stream.
16241 If a read or write error occurs, the error indicator for the stream is set and fseek fails.
16243 For a binary stream, the new position, measured in characters from the beginning of the
16244 file, is obtained by adding offset to the position specified by whence. The specified
16245 position is the beginning of the file if whence is SEEK_SET, the current value of the file
16246 position indicator if SEEK_CUR, or end-of-file if SEEK_END. A binary stream need not
16247 meaningfully support fseek calls with a whence value of SEEK_END.
16249 For a text stream, either offset shall be zero, or offset shall be a value returned by
16250 an earlier successful call to the ftell function on a stream associated with the same file
16251 and whence shall be SEEK_SET.
16253 After determining the new position, a successful call to the fseek function undoes any
16254 effects of the ungetc function on the stream, clears the end-of-file indicator for the
16255 stream, and then establishes the new position. After a successful fseek call, the next
16256 operation on an update stream may be either input or output.
16259 The fseek function returns nonzero only for a request that cannot be satisfied.
16260 Forward references: the ftell function (<a href="#7.21.9.4">7.21.9.4</a>).
16262 <a name="7.21.9.3" href="#7.21.9.3"><h5>7.21.9.3 The fsetpos function</h5></a>
16266 #include <stdio.h>
16267 int fsetpos(FILE *stream, const fpos_t *pos);</pre>
16268 <h6>Description</h6>
16270 The fsetpos function sets the mbstate_t object (if any) and file position indicator
16271 for the stream pointed to by stream according to the value of the object pointed to by
16272 pos, which shall be a value obtained from an earlier successful call to the fgetpos
16273 function on a stream associated with the same file. If a read or write error occurs, the
16274 error indicator for the stream is set and fsetpos fails.
16276 A successful call to the fsetpos function undoes any effects of the ungetc function
16277 on the stream, clears the end-of-file indicator for the stream, and then establishes the new
16278 parse state and position. After a successful fsetpos call, the next operation on an
16279 <!--page 355 indent 4-->
16280 update stream may be either input or output.
16283 If successful, the fsetpos function returns zero; on failure, the fsetpos function
16284 returns nonzero and stores an implementation-defined positive value in errno.
16286 <a name="7.21.9.4" href="#7.21.9.4"><h5>7.21.9.4 The ftell function</h5></a>
16290 #include <stdio.h>
16291 long int ftell(FILE *stream);</pre>
16292 <h6>Description</h6>
16294 The ftell function obtains the current value of the file position indicator for the stream
16295 pointed to by stream. For a binary stream, the value is the number of characters from
16296 the beginning of the file. For a text stream, its file position indicator contains unspecified
16297 information, usable by the fseek function for returning the file position indicator for the
16298 stream to its position at the time of the ftell call; the difference between two such
16299 return values is not necessarily a meaningful measure of the number of characters written
16303 If successful, the ftell function returns the current value of the file position indicator
16304 for the stream. On failure, the ftell function returns -1L and stores an
16305 implementation-defined positive value in errno.
16307 <a name="7.21.9.5" href="#7.21.9.5"><h5>7.21.9.5 The rewind function</h5></a>
16311 #include <stdio.h>
16312 void rewind(FILE *stream);</pre>
16313 <h6>Description</h6>
16315 The rewind function sets the file position indicator for the stream pointed to by
16316 stream to the beginning of the file. It is equivalent to
16318 (void)fseek(stream, 0L, SEEK_SET)</pre>
16319 except that the error indicator for the stream is also cleared.
16322 The rewind function returns no value.
16323 <!--page 356 indent 4-->
16325 <a name="7.21.10" href="#7.21.10"><h4>7.21.10 Error-handling functions</h4></a>
16327 <a name="7.21.10.1" href="#7.21.10.1"><h5>7.21.10.1 The clearerr function</h5></a>
16331 #include <stdio.h>
16332 void clearerr(FILE *stream);</pre>
16333 <h6>Description</h6>
16335 The clearerr function clears the end-of-file and error indicators for the stream pointed
16339 The clearerr function returns no value.
16341 <a name="7.21.10.2" href="#7.21.10.2"><h5>7.21.10.2 The feof function</h5></a>
16345 #include <stdio.h>
16346 int feof(FILE *stream);</pre>
16347 <h6>Description</h6>
16349 The feof function tests the end-of-file indicator for the stream pointed to by stream.
16352 The feof function returns nonzero if and only if the end-of-file indicator is set for
16355 <a name="7.21.10.3" href="#7.21.10.3"><h5>7.21.10.3 The ferror function</h5></a>
16359 #include <stdio.h>
16360 int ferror(FILE *stream);</pre>
16361 <h6>Description</h6>
16363 The ferror function tests the error indicator for the stream pointed to by stream.
16366 The ferror function returns nonzero if and only if the error indicator is set for
16368 <!--page 357 indent 4-->
16370 <a name="7.21.10.4" href="#7.21.10.4"><h5>7.21.10.4 The perror function</h5></a>
16374 #include <stdio.h>
16375 void perror(const char *s);</pre>
16376 <h6>Description</h6>
16378 The perror function maps the error number in the integer expression errno to an
16379 error message. It writes a sequence of characters to the standard error stream thus: first
16380 (if s is not a null pointer and the character pointed to by s is not the null character), the
16381 string pointed to by s followed by a colon (:) and a space; then an appropriate error
16382 message string followed by a new-line character. The contents of the error message
16383 strings are the same as those returned by the strerror function with argument errno.
16386 The perror function returns no value.
16387 Forward references: the strerror function (<a href="#7.23.6.2">7.23.6.2</a>).
16388 <!--page 358 indent 4-->
16390 <a name="7.22" href="#7.22"><h3>7.22 General utilities <stdlib.h></h3></a>
16392 The header <stdlib.h> declares five types and several functions of general utility, and
16393 defines several macros.<sup><a href="#note284"><b>284)</b></a></sup>
16395 The types declared are size_t and wchar_t (both described in <a href="#7.19">7.19</a>),
16398 which is a structure type that is the type of the value returned by the div function,
16401 which is a structure type that is the type of the value returned by the ldiv function, and
16404 which is a structure type that is the type of the value returned by the lldiv function.
16406 The macros defined are NULL (described in <a href="#7.19">7.19</a>);
16412 which expand to integer constant expressions that can be used as the argument to the
16413 exit function to return unsuccessful or successful termination status, respectively, to the
16417 which expands to an integer constant expression that is the maximum value returned by
16418 the rand function; and
16421 which expands to a positive integer expression with type size_t that is the maximum
16422 number of bytes in a multibyte character for the extended character set specified by the
16423 current locale (category LC_CTYPE), which is never greater than MB_LEN_MAX.
16428 <!--page 359 indent 4-->
16431 <p><a name="note284">284)</a> See ''future library directions'' (<a href="#7.30.10">7.30.10</a>).
16434 <a name="7.22.1" href="#7.22.1"><h4>7.22.1 Numeric conversion functions</h4></a>
16436 The functions atof, atoi, atol, and atoll need not affect the value of the integer
16437 expression errno on an error. If the value of the result cannot be represented, the
16438 behavior is undefined.
16440 <a name="7.22.1.1" href="#7.22.1.1"><h5>7.22.1.1 The atof function</h5></a>
16444 #include <stdlib.h>
16445 double atof(const char *nptr);</pre>
16446 <h6>Description</h6>
16448 The atof function converts the initial portion of the string pointed to by nptr to
16449 double representation. Except for the behavior on error, it is equivalent to
16451 strtod(nptr, (char **)NULL)</pre>
16454 The atof function returns the converted value.
16455 Forward references: the strtod, strtof, and strtold functions (<a href="#7.22.1.3">7.22.1.3</a>).
16457 <a name="7.22.1.2" href="#7.22.1.2"><h5>7.22.1.2 The atoi, atol, and atoll functions</h5></a>
16461 #include <stdlib.h>
16462 int atoi(const char *nptr);
16463 long int atol(const char *nptr);
16464 long long int atoll(const char *nptr);</pre>
16465 <h6>Description</h6>
16467 The atoi, atol, and atoll functions convert the initial portion of the string pointed
16468 to by nptr to int, long int, and long long int representation, respectively.
16469 Except for the behavior on error, they are equivalent to
16471 atoi: (int)strtol(nptr, (char **)NULL, 10)
16472 atol: strtol(nptr, (char **)NULL, 10)
16473 atoll: strtoll(nptr, (char **)NULL, 10)</pre>
16476 The atoi, atol, and atoll functions return the converted value.
16477 Forward references: the strtol, strtoll, strtoul, and strtoull functions
16478 (<a href="#7.22.1.4">7.22.1.4</a>).
16479 <!--page 360 indent 4-->
16481 <a name="7.22.1.3" href="#7.22.1.3"><h5>7.22.1.3 The strtod, strtof, and strtold functions</h5></a>
16485 #include <stdlib.h>
16486 double strtod(const char * restrict nptr,
16487 char ** restrict endptr);
16488 float strtof(const char * restrict nptr,
16489 char ** restrict endptr);
16490 long double strtold(const char * restrict nptr,
16491 char ** restrict endptr);</pre>
16492 <h6>Description</h6>
16494 The strtod, strtof, and strtold functions convert the initial portion of the string
16495 pointed to by nptr to double, float, and long double representation,
16496 respectively. First, they decompose the input string into three parts: an initial, possibly
16497 empty, sequence of white-space characters (as specified by the isspace function), a
16498 subject sequence resembling a floating-point constant or representing an infinity or NaN;
16499 and a final string of one or more unrecognized characters, including the terminating null
16500 character of the input string. Then, they attempt to convert the subject sequence to a
16501 floating-point number, and return the result.
16503 The expected form of the subject sequence is an optional plus or minus sign, then one of
16506 <li> a nonempty sequence of decimal digits optionally containing a decimal-point
16507 character, then an optional exponent part as defined in <a href="#6.4.4.2">6.4.4.2</a>;
16508 <li> a 0x or 0X, then a nonempty sequence of hexadecimal digits optionally containing a
16509 decimal-point character, then an optional binary exponent part as defined in <a href="#6.4.4.2">6.4.4.2</a>;
16510 <li> INF or INFINITY, ignoring case
16511 <li> NAN or NAN(n-char-sequenceopt), ignoring case in the NAN part, where:
16516 n-char-sequence digit
16517 n-char-sequence nondigit</pre>
16519 The subject sequence is defined as the longest initial subsequence of the input string,
16520 starting with the first non-white-space character, that is of the expected form. The subject
16521 sequence contains no characters if the input string is not of the expected form.
16523 If the subject sequence has the expected form for a floating-point number, the sequence of
16524 characters starting with the first digit or the decimal-point character (whichever occurs
16525 first) is interpreted as a floating constant according to the rules of <a href="#6.4.4.2">6.4.4.2</a>, except that the
16526 <!--page 361 indent 4-->
16527 decimal-point character is used in place of a period, and that if neither an exponent part
16528 nor a decimal-point character appears in a decimal floating point number, or if a binary
16529 exponent part does not appear in a hexadecimal floating point number, an exponent part
16530 of the appropriate type with value zero is assumed to follow the last digit in the string. If
16531 the subject sequence begins with a minus sign, the sequence is interpreted as negated.<sup><a href="#note285"><b>285)</b></a></sup>
16532 A character sequence INF or INFINITY is interpreted as an infinity, if representable in
16533 the return type, else like a floating constant that is too large for the range of the return
16534 type. A character sequence NAN or NAN(n-char-sequenceopt), is interpreted as a quiet
16535 NaN, if supported in the return type, else like a subject sequence part that does not have
16536 the expected form; the meaning of the n-char sequences is implementation-defined.<sup><a href="#note286"><b>286)</b></a></sup> A
16537 pointer to the final string is stored in the object pointed to by endptr, provided that
16538 endptr is not a null pointer.
16540 If the subject sequence has the hexadecimal form and FLT_RADIX is a power of 2, the
16541 value resulting from the conversion is correctly rounded.
16543 In other than the "C" locale, additional locale-specific subject sequence forms may be
16546 If the subject sequence is empty or does not have the expected form, no conversion is
16547 performed; the value of nptr is stored in the object pointed to by endptr, provided
16548 that endptr is not a null pointer.
16549 Recommended practice
16551 If the subject sequence has the hexadecimal form, FLT_RADIX is not a power of 2, and
16552 the result is not exactly representable, the result should be one of the two numbers in the
16553 appropriate internal format that are adjacent to the hexadecimal floating source value,
16554 with the extra stipulation that the error should have a correct sign for the current rounding
16557 If the subject sequence has the decimal form and at most DECIMAL_DIG (defined in
16558 <float.h>) significant digits, the result should be correctly rounded. If the subject
16559 sequence D has the decimal form and more than DECIMAL_DIG significant digits,
16560 consider the two bounding, adjacent decimal strings L and U, both having
16561 DECIMAL_DIG significant digits, such that the values of L, D, and U satisfy L <= D <= U.
16562 The result should be one of the (equal or adjacent) values that would be obtained by
16563 correctly rounding L and U according to the current rounding direction, with the extra
16565 <!--page 362 indent 5-->
16566 stipulation that the error with respect to D should have a correct sign for the current
16567 rounding direction.<sup><a href="#note287"><b>287)</b></a></sup>
16570 The functions return the converted value, if any. If no conversion could be performed,
16571 zero is returned. If the correct value overflows and default rounding is in effect (<a href="#7.12.1">7.12.1</a>),
16572 plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the
16573 return type and sign of the value), and the value of the macro ERANGE is stored in
16574 errno. If the result underflows (<a href="#7.12.1">7.12.1</a>), the functions return a value whose magnitude is
16575 no greater than the smallest normalized positive number in the return type; whether
16576 errno acquires the value ERANGE is implementation-defined.
16579 <p><a name="note285">285)</a> It is unspecified whether a minus-signed sequence is converted to a negative number directly or by
16580 negating the value resulting from converting the corresponding unsigned sequence (see <a href="#F.5">F.5</a>); the two
16581 methods may yield different results if rounding is toward positive or negative infinity. In either case,
16582 the functions honor the sign of zero if floating-point arithmetic supports signed zeros.
16584 <p><a name="note286">286)</a> An implementation may use the n-char sequence to determine extra information to be represented in
16585 the NaN's significand.
16587 <p><a name="note287">287)</a> DECIMAL_DIG, defined in <float.h>, should be sufficiently large that L and U will usually round
16588 to the same internal floating value, but if not will round to adjacent values.
16591 <a name="7.22.1.4" href="#7.22.1.4"><h5>7.22.1.4 The strtol, strtoll, strtoul, and strtoull functions</h5></a>
16595 #include <stdlib.h>
16597 const char * restrict nptr,
16598 char ** restrict endptr,
16600 long long int strtoll(
16601 const char * restrict nptr,
16602 char ** restrict endptr,
16604 unsigned long int strtoul(
16605 const char * restrict nptr,
16606 char ** restrict endptr,
16608 unsigned long long int strtoull(
16609 const char * restrict nptr,
16610 char ** restrict endptr,
16612 <h6>Description</h6>
16614 The strtol, strtoll, strtoul, and strtoull functions convert the initial
16615 portion of the string pointed to by nptr to long int, long long int, unsigned
16616 long int, and unsigned long long int representation, respectively. First,
16617 they decompose the input string into three parts: an initial, possibly empty, sequence of
16618 white-space characters (as specified by the isspace function), a subject sequence
16621 <!--page 363 indent 4-->
16622 resembling an integer represented in some radix determined by the value of base, and a
16623 final string of one or more unrecognized characters, including the terminating null
16624 character of the input string. Then, they attempt to convert the subject sequence to an
16625 integer, and return the result.
16627 If the value of base is zero, the expected form of the subject sequence is that of an
16628 integer constant as described in <a href="#6.4.4.1">6.4.4.1</a>, optionally preceded by a plus or minus sign, but
16629 not including an integer suffix. If the value of base is between 2 and 36 (inclusive), the
16630 expected form of the subject sequence is a sequence of letters and digits representing an
16631 integer with the radix specified by base, optionally preceded by a plus or minus sign,
16632 but not including an integer suffix. The letters from a (or A) through z (or Z) are
16633 ascribed the values 10 through 35; only letters and digits whose ascribed values are less
16634 than that of base are permitted. If the value of base is 16, the characters 0x or 0X may
16635 optionally precede the sequence of letters and digits, following the sign if present.
16637 The subject sequence is defined as the longest initial subsequence of the input string,
16638 starting with the first non-white-space character, that is of the expected form. The subject
16639 sequence contains no characters if the input string is empty or consists entirely of white
16640 space, or if the first non-white-space character is other than a sign or a permissible letter
16643 If the subject sequence has the expected form and the value of base is zero, the sequence
16644 of characters starting with the first digit is interpreted as an integer constant according to
16645 the rules of <a href="#6.4.4.1">6.4.4.1</a>. If the subject sequence has the expected form and the value of base
16646 is between 2 and 36, it is used as the base for conversion, ascribing to each letter its value
16647 as given above. If the subject sequence begins with a minus sign, the value resulting from
16648 the conversion is negated (in the return type). A pointer to the final string is stored in the
16649 object pointed to by endptr, provided that endptr is not a null pointer.
16651 In other than the "C" locale, additional locale-specific subject sequence forms may be
16654 If the subject sequence is empty or does not have the expected form, no conversion is
16655 performed; the value of nptr is stored in the object pointed to by endptr, provided
16656 that endptr is not a null pointer.
16659 The strtol, strtoll, strtoul, and strtoull functions return the converted
16660 value, if any. If no conversion could be performed, zero is returned. If the correct value
16661 is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
16662 LLONG_MAX, ULONG_MAX, or ULLONG_MAX is returned (according to the return type
16663 and sign of the value, if any), and the value of the macro ERANGE is stored in errno.
16664 <!--page 364 indent 4-->
16666 <a name="7.22.2" href="#7.22.2"><h4>7.22.2 Pseudo-random sequence generation functions</h4></a>
16668 <a name="7.22.2.1" href="#7.22.2.1"><h5>7.22.2.1 The rand function</h5></a>
16672 #include <stdlib.h>
16673 int rand(void);</pre>
16674 <h6>Description</h6>
16676 The rand function computes a sequence of pseudo-random integers in the range 0 to
16677 RAND_MAX.<sup><a href="#note288"><b>288)</b></a></sup>
16679 The rand function is not required to avoid data races. The implementation shall behave
16680 as if no library function calls the rand function.
16683 The rand function returns a pseudo-random integer.
16684 Environmental limits
16686 The value of the RAND_MAX macro shall be at least 32767.
16689 <p><a name="note288">288)</a> There are no guarantees as to the quality of the random sequence produced and some implementations
16690 are known to produce sequences with distressingly non-random low-order bits. Applications with
16691 particular requirements should use a generator that is known to be sufficient for their needs.
16694 <a name="7.22.2.2" href="#7.22.2.2"><h5>7.22.2.2 The srand function</h5></a>
16698 #include <stdlib.h>
16699 void srand(unsigned int seed);</pre>
16700 <h6>Description</h6>
16702 The srand function uses the argument as a seed for a new sequence of pseudo-random
16703 numbers to be returned by subsequent calls to rand. If srand is then called with the
16704 same seed value, the sequence of pseudo-random numbers shall be repeated. If rand is
16705 called before any calls to srand have been made, the same sequence shall be generated
16706 as when srand is first called with a seed value of 1.
16708 The implementation shall behave as if no library function calls the srand function.
16711 The srand function returns no value.
16716 <!--page 365 indent 4-->
16718 EXAMPLE The following functions define a portable implementation of rand and srand.
16720 static unsigned long int next = 1;
16721 int rand(void) // RAND_MAX assumed to be 32767
16723 next = next * 1103515245 + 12345;
16724 return (unsigned int)(next/65536) % 32768;
16726 void srand(unsigned int seed)
16732 <a name="7.22.3" href="#7.22.3"><h4>7.22.3 Memory management functions</h4></a>
16734 The order and contiguity of storage allocated by successive calls to the
16735 aligned_alloc, calloc, malloc, and realloc functions is unspecified. The
16736 pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to
16737 a pointer to any type of object with a fundamental alignment requirement and then used
16738 to access such an object or an array of such objects in the space allocated (until the space
16739 is explicitly deallocated). The lifetime of an allocated object extends from the allocation
16740 until the deallocation. Each such allocation shall yield a pointer to an object disjoint from
16741 any other object. The pointer returned points to the start (lowest byte address) of the
16742 allocated space. If the space cannot be allocated, a null pointer is returned. If the size of
16743 the space requested is zero, the behavior is implementation-defined: either a null pointer
16744 is returned, or the behavior is as if the size were some nonzero value, except that the
16745 returned pointer shall not be used to access an object.
16747 <a name="7.22.3.1" href="#7.22.3.1"><h5>7.22.3.1 The aligned_alloc function</h5></a>
16751 #include <stdlib.h>
16752 void *aligned_alloc(size_t alignment, size_t size);</pre>
16753 <h6>Description</h6>
16755 The aligned_alloc function allocates space for an object whose alignment is
16756 specified by alignment, whose size is specified by size, and whose value is
16757 indeterminate. The value of alignment shall be a valid alignment supported by the
16758 implementation and the value of size shall be an integral multiple of alignment.
16761 The aligned_alloc function returns either a null pointer or a pointer to the allocated
16763 <!--page 366 indent 4-->
16765 <a name="7.22.3.2" href="#7.22.3.2"><h5>7.22.3.2 The calloc function</h5></a>
16769 #include <stdlib.h>
16770 void *calloc(size_t nmemb, size_t size);</pre>
16771 <h6>Description</h6>
16773 The calloc function allocates space for an array of nmemb objects, each of whose size
16774 is size. The space is initialized to all bits zero.<sup><a href="#note289"><b>289)</b></a></sup>
16777 The calloc function returns either a null pointer or a pointer to the allocated space.
16780 <p><a name="note289">289)</a> Note that this need not be the same as the representation of floating-point zero or a null pointer
16784 <a name="7.22.3.3" href="#7.22.3.3"><h5>7.22.3.3 The free function</h5></a>
16788 #include <stdlib.h>
16789 void free(void *ptr);</pre>
16790 <h6>Description</h6>
16792 The free function causes the space pointed to by ptr to be deallocated, that is, made
16793 available for further allocation. If ptr is a null pointer, no action occurs. Otherwise, if
16794 the argument does not match a pointer earlier returned by a memory management
16795 function, or if the space has been deallocated by a call to free or realloc, the
16796 behavior is undefined.
16799 The free function returns no value.
16801 <a name="7.22.3.4" href="#7.22.3.4"><h5>7.22.3.4 The malloc function</h5></a>
16805 #include <stdlib.h>
16806 void *malloc(size_t size);</pre>
16807 <h6>Description</h6>
16809 The malloc function allocates space for an object whose size is specified by size and
16810 whose value is indeterminate.
16815 <!--page 367 indent 4-->
16818 The malloc function returns either a null pointer or a pointer to the allocated space.
16820 <a name="7.22.3.5" href="#7.22.3.5"><h5>7.22.3.5 The realloc function</h5></a>
16824 #include <stdlib.h>
16825 void *realloc(void *ptr, size_t size);</pre>
16826 <h6>Description</h6>
16828 The realloc function deallocates the old object pointed to by ptr and returns a
16829 pointer to a new object that has the size specified by size. The contents of the new
16830 object shall be the same as that of the old object prior to deallocation, up to the lesser of
16831 the new and old sizes. Any bytes in the new object beyond the size of the old object have
16832 indeterminate values.
16834 If ptr is a null pointer, the realloc function behaves like the malloc function for the
16835 specified size. Otherwise, if ptr does not match a pointer earlier returned by a memory
16836 management function, or if the space has been deallocated by a call to the free or
16837 realloc function, the behavior is undefined. If memory for the new object cannot be
16838 allocated, the old object is not deallocated and its value is unchanged.
16841 The realloc function returns a pointer to the new object (which may have the same
16842 value as a pointer to the old object), or a null pointer if the new object could not be
16845 <a name="7.22.4" href="#7.22.4"><h4>7.22.4 Communication with the environment</h4></a>
16847 <a name="7.22.4.1" href="#7.22.4.1"><h5>7.22.4.1 The abort function</h5></a>
16851 #include <stdlib.h>
16852 _Noreturn void abort(void);</pre>
16853 <h6>Description</h6>
16855 The abort function causes abnormal program termination to occur, unless the signal
16856 SIGABRT is being caught and the signal handler does not return. Whether open streams
16857 with unwritten buffered data are flushed, open streams are closed, or temporary files are
16858 removed is implementation-defined. An implementation-defined form of the status
16859 unsuccessful termination is returned to the host environment by means of the function
16860 call raise(SIGABRT).
16861 <!--page 368 indent 4-->
16864 The abort function does not return to its caller.
16866 <a name="7.22.4.2" href="#7.22.4.2"><h5>7.22.4.2 The atexit function</h5></a>
16870 #include <stdlib.h>
16871 int atexit(void (*func)(void));</pre>
16872 <h6>Description</h6>
16874 The atexit function registers the function pointed to by func, to be called without
16875 arguments at normal program termination.<sup><a href="#note290"><b>290)</b></a></sup>
16876 Environmental limits
16878 The implementation shall support the registration of at least 32 functions.
16881 The atexit function returns zero if the registration succeeds, nonzero if it fails.
16882 Forward references: the at_quick_exit function (<a href="#7.22.4.3">7.22.4.3</a>), the exit function
16883 (<a href="#7.22.4.4">7.22.4.4</a>).
16886 <p><a name="note290">290)</a> The atexit function registrations are distinct from the at_quick_exit registrations, so
16887 applications may need to call both registration functions with the same argument.
16890 <a name="7.22.4.3" href="#7.22.4.3"><h5>7.22.4.3 The at_quick_exit function</h5></a>
16894 #include <stdlib.h>
16895 int at_quick_exit(void (*func)(void));</pre>
16896 <h6>Description</h6>
16898 The at_quick_exit function registers the function pointed to by func, to be called
16899 without arguments should quick_exit be called.<sup><a href="#note291"><b>291)</b></a></sup>
16900 Environmental limits
16902 The implementation shall support the registration of at least 32 functions.
16905 The at_quick_exit function returns zero if the registration succeeds, nonzero if it
16907 Forward references: the quick_exit function (<a href="#7.22.4.7">7.22.4.7</a>).
16910 <!--page 369 indent 4-->
16913 <p><a name="note291">291)</a> The at_quick_exit function registrations are distinct from the atexit registrations, so
16914 applications may need to call both registration functions with the same argument.
16917 <a name="7.22.4.4" href="#7.22.4.4"><h5>7.22.4.4 The exit function</h5></a>
16921 #include <stdlib.h>
16922 _Noreturn void exit(int status);</pre>
16923 <h6>Description</h6>
16925 The exit function causes normal program termination to occur. No functions registered
16926 by the at_quick_exit function are called. If a program calls the exit function
16927 more than once, or calls the quick_exit function in addition to the exit function, the
16928 behavior is undefined.
16930 First, all functions registered by the atexit function are called, in the reverse order of
16931 their registration,<sup><a href="#note292"><b>292)</b></a></sup> except that a function is called after any previously registered
16932 functions that had already been called at the time it was registered. If, during the call to
16933 any such function, a call to the longjmp function is made that would terminate the call
16934 to the registered function, the behavior is undefined.
16936 Next, all open streams with unwritten buffered data are flushed, all open streams are
16937 closed, and all files created by the tmpfile function are removed.
16939 Finally, control is returned to the host environment. If the value of status is zero or
16940 EXIT_SUCCESS, an implementation-defined form of the status successful termination is
16941 returned. If the value of status is EXIT_FAILURE, an implementation-defined form
16942 of the status unsuccessful termination is returned. Otherwise the status returned is
16943 implementation-defined.
16946 The exit function cannot return to its caller.
16949 <p><a name="note292">292)</a> Each function is called as many times as it was registered, and in the correct order with respect to
16950 other registered functions.
16953 <a name="7.22.4.5" href="#7.22.4.5"><h5>7.22.4.5 The _Exit function</h5></a>
16957 #include <stdlib.h>
16958 _Noreturn void _Exit(int status);</pre>
16959 <h6>Description</h6>
16961 The _Exit function causes normal program termination to occur and control to be
16962 returned to the host environment. No functions registered by the atexit function, the
16963 at_quick_exit function, or signal handlers registered by the signal function are
16964 called. The status returned to the host environment is determined in the same way as for
16967 <!--page 370 indent 4-->
16968 the exit function (<a href="#7.22.4.4">7.22.4.4</a>). Whether open streams with unwritten buffered data are
16969 flushed, open streams are closed, or temporary files are removed is implementation-
16973 The _Exit function cannot return to its caller.
16975 <a name="7.22.4.6" href="#7.22.4.6"><h5>7.22.4.6 The getenv function</h5></a>
16979 #include <stdlib.h>
16980 char *getenv(const char *name);</pre>
16981 <h6>Description</h6>
16983 The getenv function searches an environment list, provided by the host environment,
16984 for a string that matches the string pointed to by name. The set of environment names
16985 and the method for altering the environment list are implementation-defined. The
16986 getenv function need not avoid data races with other threads of execution that modify
16987 the environment list.<sup><a href="#note293"><b>293)</b></a></sup>
16989 The implementation shall behave as if no library function calls the getenv function.
16992 The getenv function returns a pointer to a string associated with the matched list
16993 member. The string pointed to shall not be modified by the program, but may be
16994 overwritten by a subsequent call to the getenv function. If the specified name cannot
16995 be found, a null pointer is returned.
16998 <p><a name="note293">293)</a> Many implementations provide non-standard functions that modify the environment list.
17001 <a name="7.22.4.7" href="#7.22.4.7"><h5>7.22.4.7 The quick_exit function</h5></a>
17005 #include <stdlib.h>
17006 _Noreturn void quick_exit(int status);</pre>
17007 <h6>Description</h6>
17009 The quick_exit function causes normal program termination to occur. No functions
17010 registered by the atexit function or signal handlers registered by the signal function
17011 are called. If a program calls the quick_exit function more than once, or calls the
17012 exit function in addition to the quick_exit function, the behavior is undefined.
17014 The quick_exit function first calls all functions registered by the at_quick_exit
17015 function, in the reverse order of their registration,<sup><a href="#note294"><b>294)</b></a></sup> except that a function is called after
17018 <!--page 371 indent 4-->
17019 any previously registered functions that had already been called at the time it was
17020 registered. If, during the call to any such function, a call to the longjmp function is
17021 made that would terminate the call to the registered function, the behavior is undefined.
17023 Then control is returned to the host environment by means of the function call
17027 The quick_exit function cannot return to its caller.
17030 <p><a name="note294">294)</a> Each function is called as many times as it was registered, and in the correct order with respect to
17031 other registered functions.
17034 <a name="7.22.4.8" href="#7.22.4.8"><h5>7.22.4.8 The system function</h5></a>
17038 #include <stdlib.h>
17039 int system(const char *string);</pre>
17040 <h6>Description</h6>
17042 If string is a null pointer, the system function determines whether the host
17043 environment has a command processor. If string is not a null pointer, the system
17044 function passes the string pointed to by string to that command processor to be
17045 executed in a manner which the implementation shall document; this might then cause the
17046 program calling system to behave in a non-conforming manner or to terminate.
17049 If the argument is a null pointer, the system function returns nonzero only if a
17050 command processor is available. If the argument is not a null pointer, and the system
17051 function does return, it returns an implementation-defined value.
17053 <a name="7.22.5" href="#7.22.5"><h4>7.22.5 Searching and sorting utilities</h4></a>
17055 These utilities make use of a comparison function to search or sort arrays of unspecified
17056 type. Where an argument declared as size_t nmemb specifies the length of the array
17057 for a function, nmemb can have the value zero on a call to that function; the comparison
17058 function is not called, a search finds no matching element, and sorting performs no
17059 rearrangement. Pointer arguments on such a call shall still have valid values, as described
17060 in <a href="#7.1.4">7.1.4</a>.
17062 The implementation shall ensure that the second argument of the comparison function
17063 (when called from bsearch), or both arguments (when called from qsort), are
17064 pointers to elements of the array.<sup><a href="#note295"><b>295)</b></a></sup> The first argument when called from bsearch
17069 <!--page 372 indent 4-->
17071 The comparison function shall not alter the contents of the array. The implementation
17072 may reorder elements of the array between calls to the comparison function, but shall not
17073 alter the contents of any individual element.
17075 When the same objects (consisting of size bytes, irrespective of their current positions
17076 in the array) are passed more than once to the comparison function, the results shall be
17077 consistent with one another. That is, for qsort they shall define a total ordering on the
17078 array, and for bsearch the same object shall always compare the same way with the
17081 A sequence point occurs immediately before and immediately after each call to the
17082 comparison function, and also between any call to the comparison function and any
17083 movement of the objects passed as arguments to that call.
17086 <p><a name="note295">295)</a> That is, if the value passed is p, then the following expressions are always nonzero:
17089 ((char *)p - (char *)base) % size == 0
17090 (char *)p >= (char *)base
17091 (char *)p < (char *)base + nmemb * size</pre>
17095 <a name="7.22.5.1" href="#7.22.5.1"><h5>7.22.5.1 The bsearch function</h5></a>
17099 #include <stdlib.h>
17100 void *bsearch(const void *key, const void *base,
17101 size_t nmemb, size_t size,
17102 int (*compar)(const void *, const void *));</pre>
17103 <h6>Description</h6>
17105 The bsearch function searches an array of nmemb objects, the initial element of which
17106 is pointed to by base, for an element that matches the object pointed to by key. The
17107 size of each element of the array is specified by size.
17109 The comparison function pointed to by compar is called with two arguments that point
17110 to the key object and to an array element, in that order. The function shall return an
17111 integer less than, equal to, or greater than zero if the key object is considered,
17112 respectively, to be less than, to match, or to be greater than the array element. The array
17113 shall consist of: all the elements that compare less than, all the elements that compare
17114 equal to, and all the elements that compare greater than the key object, in that order.<sup><a href="#note296"><b>296)</b></a></sup>
17117 The bsearch function returns a pointer to a matching element of the array, or a null
17118 pointer if no match is found. If two elements compare as equal, which element is
17121 <!--page 373 indent 4-->
17122 matched is unspecified.
17125 <p><a name="note296">296)</a> In practice, the entire array is sorted according to the comparison function.
17128 <a name="7.22.5.2" href="#7.22.5.2"><h5>7.22.5.2 The qsort function</h5></a>
17132 #include <stdlib.h>
17133 void qsort(void *base, size_t nmemb, size_t size,
17134 int (*compar)(const void *, const void *));</pre>
17135 <h6>Description</h6>
17137 The qsort function sorts an array of nmemb objects, the initial element of which is
17138 pointed to by base. The size of each object is specified by size.
17140 The contents of the array are sorted into ascending order according to a comparison
17141 function pointed to by compar, which is called with two arguments that point to the
17142 objects being compared. The function shall return an integer less than, equal to, or
17143 greater than zero if the first argument is considered to be respectively less than, equal to,
17144 or greater than the second.
17146 If two elements compare as equal, their order in the resulting sorted array is unspecified.
17149 The qsort function returns no value.
17151 <a name="7.22.6" href="#7.22.6"><h4>7.22.6 Integer arithmetic functions</h4></a>
17153 <a name="7.22.6.1" href="#7.22.6.1"><h5>7.22.6.1 The abs, labs and llabs functions</h5></a>
17157 #include <stdlib.h>
17159 long int labs(long int j);
17160 long long int llabs(long long int j);</pre>
17161 <h6>Description</h6>
17163 The abs, labs, and llabs functions compute the absolute value of an integer j. If the
17164 result cannot be represented, the behavior is undefined.<sup><a href="#note297"><b>297)</b></a></sup>
17167 The abs, labs, and llabs, functions return the absolute value.
17172 <!--page 374 indent 4-->
17175 <p><a name="note297">297)</a> The absolute value of the most negative number cannot be represented in two's complement.
17178 <a name="7.22.6.2" href="#7.22.6.2"><h5>7.22.6.2 The div, ldiv, and lldiv functions</h5></a>
17182 #include <stdlib.h>
17183 div_t div(int numer, int denom);
17184 ldiv_t ldiv(long int numer, long int denom);
17185 lldiv_t lldiv(long long int numer, long long int denom);</pre>
17186 <h6>Description</h6>
17188 The div, ldiv, and lldiv, functions compute numer / denom and numer %
17189 denom in a single operation.
17192 The div, ldiv, and lldiv functions return a structure of type div_t, ldiv_t, and
17193 lldiv_t, respectively, comprising both the quotient and the remainder. The structures
17194 shall contain (in either order) the members quot (the quotient) and rem (the remainder),
17195 each of which has the same type as the arguments numer and denom. If either part of
17196 the result cannot be represented, the behavior is undefined.
17198 <a name="7.22.7" href="#7.22.7"><h4>7.22.7 Multibyte/wide character conversion functions</h4></a>
17200 The behavior of the multibyte character functions is affected by the LC_CTYPE category
17201 of the current locale. For a state-dependent encoding, each function is placed into its
17202 initial conversion state at program startup and can be returned to that state by a call for
17203 which its character pointer argument, s, is a null pointer. Subsequent calls with s as
17204 other than a null pointer cause the internal conversion state of the function to be altered as
17205 necessary. A call with s as a null pointer causes these functions to return a nonzero value
17206 if encodings have state dependency, and zero otherwise.<sup><a href="#note298"><b>298)</b></a></sup> Changing the LC_CTYPE
17207 category causes the conversion state of these functions to be indeterminate.
17210 <p><a name="note298">298)</a> If the locale employs special bytes to change the shift state, these bytes do not produce separate wide
17211 character codes, but are grouped with an adjacent multibyte character.
17214 <a name="7.22.7.1" href="#7.22.7.1"><h5>7.22.7.1 The mblen function</h5></a>
17218 #include <stdlib.h>
17219 int mblen(const char *s, size_t n);</pre>
17220 <h6>Description</h6>
17222 If s is not a null pointer, the mblen function determines the number of bytes contained
17223 in the multibyte character pointed to by s. Except that the conversion state of the
17224 mbtowc function is not affected, it is equivalent to
17228 <!--page 375 indent 4-->
17231 mbtowc((wchar_t *)0, (const char *)0, 0);
17232 mbtowc((wchar_t *)0, s, n);</pre>
17233 The implementation shall behave as if no library function calls the mblen function.
17236 If s is a null pointer, the mblen function returns a nonzero or zero value, if multibyte
17237 character encodings, respectively, do or do not have state-dependent encodings. If s is
17238 not a null pointer, the mblen function either returns 0 (if s points to the null character),
17239 or returns the number of bytes that are contained in the multibyte character (if the next n
17240 or fewer bytes form a valid multibyte character), or returns -1 (if they do not form a valid
17241 multibyte character).
17242 Forward references: the mbtowc function (<a href="#7.22.7.2">7.22.7.2</a>).
17244 <a name="7.22.7.2" href="#7.22.7.2"><h5>7.22.7.2 The mbtowc function</h5></a>
17248 #include <stdlib.h>
17249 int mbtowc(wchar_t * restrict pwc,
17250 const char * restrict s,
17252 <h6>Description</h6>
17254 If s is not a null pointer, the mbtowc function inspects at most n bytes beginning with
17255 the byte pointed to by s to determine the number of bytes needed to complete the next
17256 multibyte character (including any shift sequences). If the function determines that the
17257 next multibyte character is complete and valid, it determines the value of the
17258 corresponding wide character and then, if pwc is not a null pointer, stores that value in
17259 the object pointed to by pwc. If the corresponding wide character is the null wide
17260 character, the function is left in the initial conversion state.
17262 The implementation shall behave as if no library function calls the mbtowc function.
17265 If s is a null pointer, the mbtowc function returns a nonzero or zero value, if multibyte
17266 character encodings, respectively, do or do not have state-dependent encodings. If s is
17267 not a null pointer, the mbtowc function either returns 0 (if s points to the null character),
17268 or returns the number of bytes that are contained in the converted multibyte character (if
17269 the next n or fewer bytes form a valid multibyte character), or returns -1 (if they do not
17270 form a valid multibyte character).
17272 In no case will the value returned be greater than n or the value of the MB_CUR_MAX
17274 <!--page 376 indent 4-->
17276 <a name="7.22.7.3" href="#7.22.7.3"><h5>7.22.7.3 The wctomb function</h5></a>
17280 #include <stdlib.h>
17281 int wctomb(char *s, wchar_t wc);</pre>
17282 <h6>Description</h6>
17284 The wctomb function determines the number of bytes needed to represent the multibyte
17285 character corresponding to the wide character given by wc (including any shift
17286 sequences), and stores the multibyte character representation in the array whose first
17287 element is pointed to by s (if s is not a null pointer). At most MB_CUR_MAX characters
17288 are stored. If wc is a null wide character, a null byte is stored, preceded by any shift
17289 sequence needed to restore the initial shift state, and the function is left in the initial
17292 The implementation shall behave as if no library function calls the wctomb function.
17295 If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte
17296 character encodings, respectively, do or do not have state-dependent encodings. If s is
17297 not a null pointer, the wctomb function returns -1 if the value of wc does not correspond
17298 to a valid multibyte character, or returns the number of bytes that are contained in the
17299 multibyte character corresponding to the value of wc.
17301 In no case will the value returned be greater than the value of the MB_CUR_MAX macro.
17303 <a name="7.22.8" href="#7.22.8"><h4>7.22.8 Multibyte/wide string conversion functions</h4></a>
17305 The behavior of the multibyte string functions is affected by the LC_CTYPE category of
17306 the current locale.
17308 <a name="7.22.8.1" href="#7.22.8.1"><h5>7.22.8.1 The mbstowcs function</h5></a>
17312 #include <stdlib.h>
17313 size_t mbstowcs(wchar_t * restrict pwcs,
17314 const char * restrict s,
17316 <h6>Description</h6>
17318 The mbstowcs function converts a sequence of multibyte characters that begins in the
17319 initial shift state from the array pointed to by s into a sequence of corresponding wide
17320 characters and stores not more than n wide characters into the array pointed to by pwcs.
17321 No multibyte characters that follow a null character (which is converted into a null wide
17322 character) will be examined or converted. Each multibyte character is converted as if by
17323 a call to the mbtowc function, except that the conversion state of the mbtowc function is
17324 <!--page 377 indent 4-->
17327 No more than n elements will be modified in the array pointed to by pwcs. If copying
17328 takes place between objects that overlap, the behavior is undefined.
17331 If an invalid multibyte character is encountered, the mbstowcs function returns
17332 (size_t)(-1). Otherwise, the mbstowcs function returns the number of array
17333 elements modified, not including a terminating null wide character, if any.<sup><a href="#note299"><b>299)</b></a></sup>
17336 <p><a name="note299">299)</a> The array will not be null-terminated if the value returned is n.
17339 <a name="7.22.8.2" href="#7.22.8.2"><h5>7.22.8.2 The wcstombs function</h5></a>
17343 #include <stdlib.h>
17344 size_t wcstombs(char * restrict s,
17345 const wchar_t * restrict pwcs,
17347 <h6>Description</h6>
17349 The wcstombs function converts a sequence of wide characters from the array pointed
17350 to by pwcs into a sequence of corresponding multibyte characters that begins in the
17351 initial shift state, and stores these multibyte characters into the array pointed to by s,
17352 stopping if a multibyte character would exceed the limit of n total bytes or if a null
17353 character is stored. Each wide character is converted as if by a call to the wctomb
17354 function, except that the conversion state of the wctomb function is not affected.
17356 No more than n bytes will be modified in the array pointed to by s. If copying takes place
17357 between objects that overlap, the behavior is undefined.
17360 If a wide character is encountered that does not correspond to a valid multibyte character,
17361 the wcstombs function returns (size_t)(-1). Otherwise, the wcstombs function
17362 returns the number of bytes modified, not including a terminating null character, if
17368 <!--page 378 indent 4-->
17370 <a name="7.23" href="#7.23"><h3>7.23 String handling <string.h></h3></a>
17372 <a name="7.23.1" href="#7.23.1"><h4>7.23.1 String function conventions</h4></a>
17374 The header <string.h> declares one type and several functions, and defines one
17375 macro useful for manipulating arrays of character type and other objects treated as arrays
17376 of character type.<sup><a href="#note300"><b>300)</b></a></sup> The type is size_t and the macro is NULL (both described in
17377 <a href="#7.19">7.19</a>). Various methods are used for determining the lengths of the arrays, but in all cases
17378 a char * or void * argument points to the initial (lowest addressed) character of the
17379 array. If an array is accessed beyond the end of an object, the behavior is undefined.
17381 Where an argument declared as size_t n specifies the length of the array for a
17382 function, n can have the value zero on a call to that function. Unless explicitly stated
17383 otherwise in the description of a particular function in this subclause, pointer arguments
17384 on such a call shall still have valid values, as described in <a href="#7.1.4">7.1.4</a>. On such a call, a
17385 function that locates a character finds no occurrence, a function that compares two
17386 character sequences returns zero, and a function that copies characters copies zero
17389 For all functions in this subclause, each character shall be interpreted as if it had the type
17390 unsigned char (and therefore every possible object representation is valid and has a
17394 <p><a name="note300">300)</a> See ''future library directions'' (<a href="#7.30.11">7.30.11</a>).
17397 <a name="7.23.2" href="#7.23.2"><h4>7.23.2 Copying functions</h4></a>
17399 <a name="7.23.2.1" href="#7.23.2.1"><h5>7.23.2.1 The memcpy function</h5></a>
17403 #include <string.h>
17404 void *memcpy(void * restrict s1,
17405 const void * restrict s2,
17407 <h6>Description</h6>
17409 The memcpy function copies n characters from the object pointed to by s2 into the
17410 object pointed to by s1. If copying takes place between objects that overlap, the behavior
17414 The memcpy function returns the value of s1.
17419 <!--page 379 indent 4-->
17421 <a name="7.23.2.2" href="#7.23.2.2"><h5>7.23.2.2 The memmove function</h5></a>
17425 #include <string.h>
17426 void *memmove(void *s1, const void *s2, size_t n);</pre>
17427 <h6>Description</h6>
17429 The memmove function copies n characters from the object pointed to by s2 into the
17430 object pointed to by s1. Copying takes place as if the n characters from the object
17431 pointed to by s2 are first copied into a temporary array of n characters that does not
17432 overlap the objects pointed to by s1 and s2, and then the n characters from the
17433 temporary array are copied into the object pointed to by s1.
17436 The memmove function returns the value of s1.
17438 <a name="7.23.2.3" href="#7.23.2.3"><h5>7.23.2.3 The strcpy function</h5></a>
17442 #include <string.h>
17443 char *strcpy(char * restrict s1,
17444 const char * restrict s2);</pre>
17445 <h6>Description</h6>
17447 The strcpy function copies the string pointed to by s2 (including the terminating null
17448 character) into the array pointed to by s1. If copying takes place between objects that
17449 overlap, the behavior is undefined.
17452 The strcpy function returns the value of s1.
17454 <a name="7.23.2.4" href="#7.23.2.4"><h5>7.23.2.4 The strncpy function</h5></a>
17458 #include <string.h>
17459 char *strncpy(char * restrict s1,
17460 const char * restrict s2,
17462 <h6>Description</h6>
17464 The strncpy function copies not more than n characters (characters that follow a null
17465 character are not copied) from the array pointed to by s2 to the array pointed to by
17466 <!--page 380 indent 4-->
17467 s1.<sup><a href="#note301"><b>301)</b></a></sup> If copying takes place between objects that overlap, the behavior is undefined.
17469 If the array pointed to by s2 is a string that is shorter than n characters, null characters
17470 are appended to the copy in the array pointed to by s1, until n characters in all have been
17474 The strncpy function returns the value of s1.
17477 <p><a name="note301">301)</a> Thus, if there is no null character in the first n characters of the array pointed to by s2, the result will
17478 not be null-terminated.
17481 <a name="7.23.3" href="#7.23.3"><h4>7.23.3 Concatenation functions</h4></a>
17483 <a name="7.23.3.1" href="#7.23.3.1"><h5>7.23.3.1 The strcat function</h5></a>
17487 #include <string.h>
17488 char *strcat(char * restrict s1,
17489 const char * restrict s2);</pre>
17490 <h6>Description</h6>
17492 The strcat function appends a copy of the string pointed to by s2 (including the
17493 terminating null character) to the end of the string pointed to by s1. The initial character
17494 of s2 overwrites the null character at the end of s1. If copying takes place between
17495 objects that overlap, the behavior is undefined.
17498 The strcat function returns the value of s1.
17500 <a name="7.23.3.2" href="#7.23.3.2"><h5>7.23.3.2 The strncat function</h5></a>
17504 #include <string.h>
17505 char *strncat(char * restrict s1,
17506 const char * restrict s2,
17508 <h6>Description</h6>
17510 The strncat function appends not more than n characters (a null character and
17511 characters that follow it are not appended) from the array pointed to by s2 to the end of
17512 the string pointed to by s1. The initial character of s2 overwrites the null character at the
17513 end of s1. A terminating null character is always appended to the result.<sup><a href="#note302"><b>302)</b></a></sup> If copying
17515 <!--page 381 indent 4-->
17516 takes place between objects that overlap, the behavior is undefined.
17519 The strncat function returns the value of s1.
17520 Forward references: the strlen function (<a href="#7.23.6.3">7.23.6.3</a>).
17523 <p><a name="note302">302)</a> Thus, the maximum number of characters that can end up in the array pointed to by s1 is
17527 <a name="7.23.4" href="#7.23.4"><h4>7.23.4 Comparison functions</h4></a>
17529 The sign of a nonzero value returned by the comparison functions memcmp, strcmp,
17530 and strncmp is determined by the sign of the difference between the values of the first
17531 pair of characters (both interpreted as unsigned char) that differ in the objects being
17534 <a name="7.23.4.1" href="#7.23.4.1"><h5>7.23.4.1 The memcmp function</h5></a>
17538 #include <string.h>
17539 int memcmp(const void *s1, const void *s2, size_t n);</pre>
17540 <h6>Description</h6>
17542 The memcmp function compares the first n characters of the object pointed to by s1 to
17543 the first n characters of the object pointed to by s2.<sup><a href="#note303"><b>303)</b></a></sup>
17546 The memcmp function returns an integer greater than, equal to, or less than zero,
17547 accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
17551 <p><a name="note303">303)</a> The contents of ''holes'' used as padding for purposes of alignment within structure objects are
17552 indeterminate. Strings shorter than their allocated space and unions may also cause problems in
17556 <a name="7.23.4.2" href="#7.23.4.2"><h5>7.23.4.2 The strcmp function</h5></a>
17560 #include <string.h>
17561 int strcmp(const char *s1, const char *s2);</pre>
17562 <h6>Description</h6>
17564 The strcmp function compares the string pointed to by s1 to the string pointed to by
17568 The strcmp function returns an integer greater than, equal to, or less than zero,
17569 accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
17571 <!--page 382 indent 4-->
17574 <a name="7.23.4.3" href="#7.23.4.3"><h5>7.23.4.3 The strcoll function</h5></a>
17578 #include <string.h>
17579 int strcoll(const char *s1, const char *s2);</pre>
17580 <h6>Description</h6>
17582 The strcoll function compares the string pointed to by s1 to the string pointed to by
17583 s2, both interpreted as appropriate to the LC_COLLATE category of the current locale.
17586 The strcoll function returns an integer greater than, equal to, or less than zero,
17587 accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
17588 pointed to by s2 when both are interpreted as appropriate to the current locale.
17590 <a name="7.23.4.4" href="#7.23.4.4"><h5>7.23.4.4 The strncmp function</h5></a>
17594 #include <string.h>
17595 int strncmp(const char *s1, const char *s2, size_t n);</pre>
17596 <h6>Description</h6>
17598 The strncmp function compares not more than n characters (characters that follow a
17599 null character are not compared) from the array pointed to by s1 to the array pointed to
17603 The strncmp function returns an integer greater than, equal to, or less than zero,
17604 accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
17605 to, or less than the possibly null-terminated array pointed to by s2.
17607 <a name="7.23.4.5" href="#7.23.4.5"><h5>7.23.4.5 The strxfrm function</h5></a>
17611 #include <string.h>
17612 size_t strxfrm(char * restrict s1,
17613 const char * restrict s2,
17615 <h6>Description</h6>
17617 The strxfrm function transforms the string pointed to by s2 and places the resulting
17618 string into the array pointed to by s1. The transformation is such that if the strcmp
17619 function is applied to two transformed strings, it returns a value greater than, equal to, or
17620 <!--page 383 indent 4-->
17621 less than zero, corresponding to the result of the strcoll function applied to the same
17622 two original strings. No more than n characters are placed into the resulting array
17623 pointed to by s1, including the terminating null character. If n is zero, s1 is permitted to
17624 be a null pointer. If copying takes place between objects that overlap, the behavior is
17628 The strxfrm function returns the length of the transformed string (not including the
17629 terminating null character). If the value returned is n or more, the contents of the array
17630 pointed to by s1 are indeterminate.
17632 EXAMPLE The value of the following expression is the size of the array needed to hold the
17633 transformation of the string pointed to by s.
17635 1 + strxfrm(NULL, s, 0)</pre>
17638 <a name="7.23.5" href="#7.23.5"><h4>7.23.5 Search functions</h4></a>
17640 <a name="7.23.5.1" href="#7.23.5.1"><h5>7.23.5.1 The memchr function</h5></a>
17644 #include <string.h>
17645 void *memchr(const void *s, int c, size_t n);</pre>
17646 <h6>Description</h6>
17648 The memchr function locates the first occurrence of c (converted to an unsigned
17649 char) in the initial n characters (each interpreted as unsigned char) of the object
17650 pointed to by s. The implementation shall behave as if it reads the characters sequentially
17651 and stops as soon as a matching character is found.
17654 The memchr function returns a pointer to the located character, or a null pointer if the
17655 character does not occur in the object.
17657 <a name="7.23.5.2" href="#7.23.5.2"><h5>7.23.5.2 The strchr function</h5></a>
17661 #include <string.h>
17662 char *strchr(const char *s, int c);</pre>
17663 <h6>Description</h6>
17665 The strchr function locates the first occurrence of c (converted to a char) in the
17666 string pointed to by s. The terminating null character is considered to be part of the
17668 <!--page 384 indent 4-->
17671 The strchr function returns a pointer to the located character, or a null pointer if the
17672 character does not occur in the string.
17674 <a name="7.23.5.3" href="#7.23.5.3"><h5>7.23.5.3 The strcspn function</h5></a>
17678 #include <string.h>
17679 size_t strcspn(const char *s1, const char *s2);</pre>
17680 <h6>Description</h6>
17682 The strcspn function computes the length of the maximum initial segment of the string
17683 pointed to by s1 which consists entirely of characters not from the string pointed to by
17687 The strcspn function returns the length of the segment.
17689 <a name="7.23.5.4" href="#7.23.5.4"><h5>7.23.5.4 The strpbrk function</h5></a>
17693 #include <string.h>
17694 char *strpbrk(const char *s1, const char *s2);</pre>
17695 <h6>Description</h6>
17697 The strpbrk function locates the first occurrence in the string pointed to by s1 of any
17698 character from the string pointed to by s2.
17701 The strpbrk function returns a pointer to the character, or a null pointer if no character
17702 from s2 occurs in s1.
17704 <a name="7.23.5.5" href="#7.23.5.5"><h5>7.23.5.5 The strrchr function</h5></a>
17708 #include <string.h>
17709 char *strrchr(const char *s, int c);</pre>
17710 <h6>Description</h6>
17712 The strrchr function locates the last occurrence of c (converted to a char) in the
17713 string pointed to by s. The terminating null character is considered to be part of the
17715 <!--page 385 indent 4-->
17718 The strrchr function returns a pointer to the character, or a null pointer if c does not
17719 occur in the string.
17721 <a name="7.23.5.6" href="#7.23.5.6"><h5>7.23.5.6 The strspn function</h5></a>
17725 #include <string.h>
17726 size_t strspn(const char *s1, const char *s2);</pre>
17727 <h6>Description</h6>
17729 The strspn function computes the length of the maximum initial segment of the string
17730 pointed to by s1 which consists entirely of characters from the string pointed to by s2.
17733 The strspn function returns the length of the segment.
17735 <a name="7.23.5.7" href="#7.23.5.7"><h5>7.23.5.7 The strstr function</h5></a>
17739 #include <string.h>
17740 char *strstr(const char *s1, const char *s2);</pre>
17741 <h6>Description</h6>
17743 The strstr function locates the first occurrence in the string pointed to by s1 of the
17744 sequence of characters (excluding the terminating null character) in the string pointed to
17748 The strstr function returns a pointer to the located string, or a null pointer if the string
17749 is not found. If s2 points to a string with zero length, the function returns s1.
17751 <a name="7.23.5.8" href="#7.23.5.8"><h5>7.23.5.8 The strtok function</h5></a>
17755 #include <string.h>
17756 char *strtok(char * restrict s1,
17757 const char * restrict s2);</pre>
17758 <h6>Description</h6>
17760 A sequence of calls to the strtok function breaks the string pointed to by s1 into a
17761 sequence of tokens, each of which is delimited by a character from the string pointed to
17762 by s2. The first call in the sequence has a non-null first argument; subsequent calls in the
17763 sequence have a null first argument. The separator string pointed to by s2 may be
17764 different from call to call.
17765 <!--page 386 indent 4-->
17767 The first call in the sequence searches the string pointed to by s1 for the first character
17768 that is not contained in the current separator string pointed to by s2. If no such character
17769 is found, then there are no tokens in the string pointed to by s1 and the strtok function
17770 returns a null pointer. If such a character is found, it is the start of the first token.
17772 The strtok function then searches from there for a character that is contained in the
17773 current separator string. If no such character is found, the current token extends to the
17774 end of the string pointed to by s1, and subsequent searches for a token will return a null
17775 pointer. If such a character is found, it is overwritten by a null character, which
17776 terminates the current token. The strtok function saves a pointer to the following
17777 character, from which the next search for a token will start.
17779 Each subsequent call, with a null pointer as the value of the first argument, starts
17780 searching from the saved pointer and behaves as described above.
17782 The strtok function is not required to avoid data races. The implementation shall
17783 behave as if no library function calls the strtok function.
17786 The strtok function returns a pointer to the first character of a token, or a null pointer
17787 if there is no token.
17791 #include <string.h>
17792 static char str[] = "?a???b,,,#c";
17794 t = strtok(str, "?"); // t points to the token "a"
17795 t = strtok(NULL, ","); // t points to the token "??b"
17796 t = strtok(NULL, "#,"); // t points to the token "c"
17797 t = strtok(NULL, "?"); // t is a null pointer</pre>
17800 <a name="7.23.6" href="#7.23.6"><h4>7.23.6 Miscellaneous functions</h4></a>
17802 <a name="7.23.6.1" href="#7.23.6.1"><h5>7.23.6.1 The memset function</h5></a>
17806 #include <string.h>
17807 void *memset(void *s, int c, size_t n);</pre>
17808 <h6>Description</h6>
17810 The memset function copies the value of c (converted to an unsigned char) into
17811 each of the first n characters of the object pointed to by s.
17814 The memset function returns the value of s.
17815 <!--page 387 indent 4-->
17817 <a name="7.23.6.2" href="#7.23.6.2"><h5>7.23.6.2 The strerror function</h5></a>
17821 #include <string.h>
17822 char *strerror(int errnum);</pre>
17823 <h6>Description</h6>
17825 The strerror function maps the number in errnum to a message string. Typically,
17826 the values for errnum come from errno, but strerror shall map any value of type
17829 The strerror function is not required to avoid data races. The implementation shall
17830 behave as if no library function calls the strerror function.
17833 The strerror function returns a pointer to the string, the contents of which are locale-
17834 specific. The array pointed to shall not be modified by the program, but may be
17835 overwritten by a subsequent call to the strerror function.
17837 <a name="7.23.6.3" href="#7.23.6.3"><h5>7.23.6.3 The strlen function</h5></a>
17841 #include <string.h>
17842 size_t strlen(const char *s);</pre>
17843 <h6>Description</h6>
17845 The strlen function computes the length of the string pointed to by s.
17848 The strlen function returns the number of characters that precede the terminating null
17850 <!--page 388 indent 4-->
17852 <a name="7.24" href="#7.24"><h3>7.24 Type-generic math <tgmath.h></h3></a>
17854 The header <tgmath.h> includes the headers <math.h> and <complex.h> and
17855 defines several type-generic macros.
17857 Of the <math.h> and <complex.h> functions without an f (float) or l (long
17858 double) suffix, several have one or more parameters whose corresponding real type is
17859 double. For each such function, except modf, there is a corresponding type-generic
17860 macro.<sup><a href="#note304"><b>304)</b></a></sup> The parameters whose corresponding real type is double in the function
17861 synopsis are generic parameters. Use of the macro invokes a function whose
17862 corresponding real type and type domain are determined by the arguments for the generic
17863 parameters.<sup><a href="#note305"><b>305)</b></a></sup>
17865 Use of the macro invokes a function whose generic parameters have the corresponding
17866 real type determined as follows:
17868 <li> First, if any argument for generic parameters has type long double, the type
17869 determined is long double.
17870 <li> Otherwise, if any argument for generic parameters has type double or is of integer
17871 type, the type determined is double.
17872 <li> Otherwise, the type determined is float.
17875 For each unsuffixed function in <math.h> for which there is a function in
17876 <complex.h> with the same name except for a c prefix, the corresponding type-
17877 generic macro (for both functions) has the same name as the function in <math.h>. The
17878 corresponding type-generic macro for fabs and cabs is fabs.
17883 <!--page 389 indent 4-->
17885 <math.h> <complex.h> type-generic
17886 function function macro
17903 fabs cabs fabs</pre>
17904 If at least one argument for a generic parameter is complex, then use of the macro invokes
17905 a complex function; otherwise, use of the macro invokes a real function.
17907 For each unsuffixed function in <math.h> without a c-prefixed counterpart in
17908 <complex.h> (except modf), the corresponding type-generic macro has the same
17909 name as the function. These type-generic macros are:
17911 atan2 fma llround remainder
17912 cbrt fmax log10 remquo
17913 ceil fmin log1p rint
17914 copysign fmod log2 round
17915 erf frexp logb scalbn
17916 erfc hypot lrint scalbln
17917 exp2 ilogb lround tgamma
17918 expm1 ldexp nearbyint trunc
17919 fdim lgamma nextafter
17920 floor llrint nexttoward</pre>
17921 If all arguments for generic parameters are real, then use of the macro invokes a real
17922 function; otherwise, use of the macro results in undefined behavior.
17923 <!--page 390 indent 4-->
17925 For each unsuffixed function in <complex.h> that is not a c-prefixed counterpart to a
17926 function in <math.h>, the corresponding type-generic macro has the same name as the
17927 function. These type-generic macros are:
17931 Use of the macro with any real or complex argument invokes a complex function.
17933 EXAMPLE With the declarations
17935 #include <tgmath.h>
17942 long double complex ldc;</pre>
17943 functions invoked by use of type-generic macros are shown in the following table:
17944 <!--page 391 indent 4-->
17947 exp(n) exp(n), the function
17949 sin(d) sin(d), the function
17953 pow(ldc, f) cpowl(ldc, f)
17954 remainder(n, n) remainder(n, n), the function
17955 nextafter(d, f) nextafter(d, f), the function
17956 nexttoward(f, ld) nexttowardf(f, ld)
17957 copysign(n, ld) copysignl(n, ld)
17958 ceil(fc) undefined behavior
17959 rint(dc) undefined behavior
17960 fmax(ldc, ld) undefined behavior
17961 carg(n) carg(n), the function
17963 creal(d) creal(d), the function
17964 cimag(ld) cimagl(ld)
17966 carg(dc) carg(dc), the function
17967 cproj(ldc) cprojl(ldc)</pre>
17970 <p><a name="note304">304)</a> Like other function-like macros in Standard libraries, each type-generic macro can be suppressed to
17971 make available the corresponding ordinary function.
17973 <p><a name="note305">305)</a> If the type of the argument is not compatible with the type of the parameter for the selected function,
17974 the behavior is undefined.
17977 <a name="7.25" href="#7.25"><h3>7.25 Threads <threads.h></h3></a>
17979 <a name="7.25.1" href="#7.25.1"><h4>7.25.1 Introduction</h4></a>
17981 The header <threads.h> defines macros, and declares types, enumeration constants,
17982 and functions that support multiple threads of execution.
17984 Implementations that define the macro __STDC_NO_THREADS__ need not provide
17985 this header nor support any of its facilities.
17989 ONCE_FLAG_INIT</pre>
17990 which expands to a value that can be used to initialize an object of type once_flag;
17993 TSS_DTOR_ITERATIONS</pre>
17994 which expands to an integer constant expression representing the maximum number of
17995 times that destructors will be called when a thread terminates.
18000 which is a complete object type that holds an identifier for a condition variable;
18003 which is a complete object type that holds an identifier for a thread;
18006 which is a complete object type that holds an identifier for a thread-specific storage
18010 which is a complete object type that holds an identifier for a mutex;
18013 which is the function pointer type void (*)(void*), used for a destructor for a
18014 thread-specific storage pointer;
18017 which is the function pointer type int (*)(void*) that is passed to thrd_create
18018 to create a new thread;
18021 which is a complete object type that holds a flag for use by call_once; and
18022 <!--page 392 indent 4-->
18025 which is a structure type that holds a time specified in seconds and nanoseconds. The
18026 structure shall contain at least the following members, in any order.
18031 The enumeration constants are
18034 which is passed to mtx_init to create a mutex object that supports neither timeout nor
18037 mtx_recursive</pre>
18038 which is passed to mtx_init to create a mutex object that supports recursive locking;
18041 which is passed to mtx_init to create a mutex object that supports timeout;
18044 which is passed to mtx_init to create a mutex object that supports test and return;
18047 which is returned by a timed wait function to indicate that the time specified in the call
18048 was reached without acquiring the requested resource;
18051 which is returned by a function to indicate that the requested operation succeeded;
18054 which is returned by a function to indicate that the requested operation failed because a
18055 resource requested by a test and return function is already in use;
18058 which is returned by a function to indicate that the requested operation failed; and
18061 which is returned by a function to indicate that the requested operation failed because it
18062 was unable to allocate memory.
18063 <!--page 393 indent 4-->
18065 <a name="7.25.2" href="#7.25.2"><h4>7.25.2 Initialization functions</h4></a>
18067 <a name="7.25.2.1" href="#7.25.2.1"><h5>7.25.2.1 The call_once function</h5></a>
18071 #include <threads.h>
18072 void call_once(once_flag *flag, void (*func)(void));</pre>
18073 <h6>Description</h6>
18075 The call_once function uses the once_flag pointed to by flag to ensure that
18076 func is called exactly once, the first time the call_once function is called with that
18077 value of flag. Completion of an effective call to the call_once function synchronizes
18078 with all subsequent calls to the call_once function with the same value of flag.
18081 The call_once function returns no value.
18083 <a name="7.25.3" href="#7.25.3"><h4>7.25.3 Condition variable functions</h4></a>
18085 <a name="7.25.3.1" href="#7.25.3.1"><h5>7.25.3.1 The cnd_broadcast function</h5></a>
18089 #include <threads.h>
18090 int cnd_broadcast(cnd_t *cond);</pre>
18091 <h6>Description</h6>
18093 The cnd_broadcast function unblocks all of the threads that are blocked on the
18094 condition variable pointed to by cond at the time of the call. If no threads are blocked
18095 on the condition variable pointed to by cond at the time of the call, the function does
18099 The cnd_broadcast function returns thrd_success on success, or thrd_error
18100 if the request could not be honored.
18102 <a name="7.25.3.2" href="#7.25.3.2"><h5>7.25.3.2 The cnd_destroy function</h5></a>
18106 #include <threads.h>
18107 void cnd_destroy(cnd_t *cond);</pre>
18108 <h6>Description</h6>
18110 The cnd_destroy function releases all resources used by the condition variable
18111 pointed to by cond. The cnd_destroy function requires that no threads be blocked
18112 waiting for the condition variable pointed to by cond.
18113 <!--page 394 indent 4-->
18116 The cnd_destroy function returns no value.
18118 <a name="7.25.3.3" href="#7.25.3.3"><h5>7.25.3.3 The cnd_init function</h5></a>
18122 #include <threads.h>
18123 int cnd_init(cnd_t *cond);</pre>
18124 <h6>Description</h6>
18126 The cnd_init function creates a condition variable. If it succeeds it sets the variable
18127 pointed to by cond to a value that uniquely identifies the newly created condition
18128 variable. A thread that calls cnd_wait on a newly created condition variable will
18132 The cnd_init function returns thrd_success on success, or thrd_nomem if no
18133 memory could be allocated for the newly created condition, or thrd_error if the
18134 request could not be honored.
18136 <a name="7.25.3.4" href="#7.25.3.4"><h5>7.25.3.4 The cnd_signal function</h5></a>
18140 #include <threads.h>
18141 int cnd_signal(cnd_t *cond);</pre>
18142 <h6>Description</h6>
18144 The cnd_signal function unblocks one of the threads that are blocked on the
18145 condition variable pointed to by cond at the time of the call. If no threads are blocked
18146 on the condition variable at the time of the call, the function does nothing and return
18150 The cnd_signal function returns thrd_success on success or thrd_error if
18151 the request could not be honored.
18153 <a name="7.25.3.5" href="#7.25.3.5"><h5>7.25.3.5 The cnd_timedwait function</h5></a>
18156 <!--page 395 indent 4-->
18158 #include <threads.h>
18159 int cnd_timedwait(cnd_t *cond, mtx_t *mtx,
18160 const xtime *xt);</pre>
18161 <h6>Description</h6>
18163 The cnd_timedwait function atomically unlocks the mutex pointed to by mtx and
18164 endeavors to block until the condition variable pointed to by cond is signaled by a call to
18165 cnd_signal or to cnd_broadcast, or until after the time specified by the xtime
18166 object pointed to by xt. When the calling thread becomes unblocked it locks the variable
18167 pointed to by mtx before it returns. The cnd_timedwait function requires that the
18168 mutex pointed to by mtx be locked by the calling thread.
18171 The cnd_timedwait function returns thrd_success upon success, or
18172 thrd_timeout if the time specified in the call was reached without acquiring the
18173 requested resource, or thrd_error if the request could not be honored.
18175 <a name="7.25.3.6" href="#7.25.3.6"><h5>7.25.3.6 The cnd_wait function</h5></a>
18179 #include <threads.h>
18180 int cnd_wait(cnd_t *cond, mtx_t *mtx);</pre>
18181 <h6>Description</h6>
18183 The cnd_wait function atomically unlocks the mutex pointed to by mtx and endeavors
18184 to block until the condition variable pointed to by cond is signaled by a call to
18185 cnd_signal or to cnd_broadcast. When the calling thread becomes unblocked it
18186 locks the mutex pointed to by mtx before it returns. If the mutex pointed to by mtx is
18187 not locked by the calling thread, the cnd_wait function will act as if the abort
18188 function is called.
18191 The cnd_wait function returns thrd_success on success or thrd_error if the
18192 request could not be honored.
18194 <a name="7.25.4" href="#7.25.4"><h4>7.25.4 Mutex functions</h4></a>
18196 <a name="7.25.4.1" href="#7.25.4.1"><h5>7.25.4.1 The mtx_destroy function</h5></a>
18200 #include <threads.h>
18201 void mtx_destroy(mtx_t *mtx);</pre>
18202 <h6>Description</h6>
18204 The mtx_destroy function releases any resources used by the mutex pointed to by
18205 mtx. No threads can be blocked waiting for the mutex pointed to by mtx.
18206 <!--page 396 indent 4-->
18209 The mtx_destroy function returns no value.
18211 <a name="7.25.4.2" href="#7.25.4.2"><h5>7.25.4.2 The mtx_init function</h5></a>
18215 #include <threads.h>
18216 int mtx_init(mtx_t *mtx, int type);</pre>
18217 <h6>Description</h6>
18219 The mtx_init function creates a mutex object with properties indicated by type,
18220 which must have one of the six values:
18221 mtx_plain for a simple non-recursive mutex,
18222 mtx_timed for a non-recursive mutex that supports timeout,
18223 mtx_try for a non-recursive mutex that supports test and return,
18224 mtx_plain | mtx_recursive for a simple recursive mutex,
18225 mtx_timed | mtx_recursive for a recursive mutex that supports timeout, or
18226 mtx_try | mtx_recursive for a recursive mutex that supports test and return.
18228 If the mtx_init function succeeds, it sets the mutex pointed to by mtx to a value that
18229 uniquely identifies the newly created mutex.
18232 The mtx_init function returns thrd_success on success, or thrd_error if the
18233 request could not be honored.
18235 <a name="7.25.4.3" href="#7.25.4.3"><h5>7.25.4.3 The mtx_lock function</h5></a>
18239 #include <threads.h>
18240 int mtx_lock(mtx_t *mtx);</pre>
18241 <h6>Description</h6>
18243 The mtx_lock function blocks until it locks the mutex pointed to by mtx. If the mutex
18244 is non-recursive, it shall not be locked by the calling thread. Prior calls to mtx_unlock
18245 on the same mutex shall synchronize with this operation.
18248 The mtx_lock function returns thrd_success on success, or thrd_busy if the
18249 resource requested is already in use, or thrd_error if the request could not be
18251 <!--page 397 indent 4-->
18253 <a name="7.25.4.4" href="#7.25.4.4"><h5>7.25.4.4 The mtx_timedlock function</h5></a>
18257 #include <threads.h>
18258 int mtx_timedlock(mtx_t *mtx, const xtime *xt);</pre>
18259 <h6>Description</h6>
18261 The mtx_timedlock function endeavors to block until it locks the mutex pointed to by
18262 mtx or until the time specified by the xtime object xt has passed. The specified mutex
18263 shall support timeout. If the operation succeeds, prior calls to mtx_unlock on the same
18264 mutex shall synchronize with this operation.
18267 The mtx_timedlock function returns thrd_success on success, or thrd_busy
18268 if the resource requested is already in use, or thrd_timeout if the time specified was
18269 reached without acquiring the requested resource, or thrd_error if the request could
18272 <a name="7.25.4.5" href="#7.25.4.5"><h5>7.25.4.5 The mtx_trylock function</h5></a>
18276 #include <threads.h>
18277 int mtx_trylock(mtx_t *mtx);</pre>
18278 <h6>Description</h6>
18280 The mtx_trylock function endeavors to lock the mutex pointed to by mtx. The
18281 specified mutex shall support either test and return or timeout. If the mutex is already
18282 locked, the function returns without blocking. If the operation succeeds, prior calls to
18283 mtx_unlock on the same mutex shall synchronize with this operation.
18286 The mtx_trylock function returns thrd_success on success, or thrd_busy if
18287 the resource requested is already in use, or thrd_error if the request could not be
18290 <a name="7.25.4.6" href="#7.25.4.6"><h5>7.25.4.6 The mtx_unlock function</h5></a>
18294 #include <threads.h>
18295 int mtx_unlock(mtx_t *mtx);</pre>
18296 <h6>Description</h6>
18298 The mtx_unlock function unlocks the mutex pointed to by mtx. The mutex pointed to
18299 by mtx shall be locked by the calling thread.
18300 <!--page 398 indent 4-->
18303 The mtx_unlock function returns thrd_success on success or thrd_error if
18304 the request could not be honored.
18306 <a name="7.25.5" href="#7.25.5"><h4>7.25.5 Thread functions</h4></a>
18308 <a name="7.25.5.1" href="#7.25.5.1"><h5>7.25.5.1 The thrd_create function</h5></a>
18312 #include <threads.h>
18313 int thrd_create(thrd_t *thr, thrd_start_t func,
18315 <h6>Description</h6>
18317 The thrd_create function creates a new thread executing func(arg). If the
18318 thrd_create function succeeds, it sets the object pointed to by thr to the identifier of
18319 the newly created thread. (A thread's identifier may be reused for a different thread once
18320 the original thread has exited and either been detached or joined to another thread.) The
18321 completion of the thrd_create function synchronizes with the beginning of the
18322 execution of the new thread.
18325 The thrd_create function returns thrd_success on success, or thrd_nomem if
18326 no memory could be allocated for the thread requested, or thrd_error if the request
18327 could not be honored.
18329 <a name="7.25.5.2" href="#7.25.5.2"><h5>7.25.5.2 The thrd_current function</h5></a>
18333 #include <threads.h>
18334 thrd_t thrd_current(void);</pre>
18335 <h6>Description</h6>
18337 The thrd_current function identifies the thread that called it.
18340 The thrd_current function returns the identifier of the thread that called it.
18342 <a name="7.25.5.3" href="#7.25.5.3"><h5>7.25.5.3 The thrd_detach function</h5></a>
18345 <!--page 399 indent 4-->
18347 #include <threads.h>
18348 int thrd_detach(thrd_t thr);</pre>
18349 <h6>Description</h6>
18351 The thrd_detach function tells the operating system to dispose of any resources
18352 allocated to the thread identified by thr when that thread terminates. The thread
18353 identified by thr shall not have been previously detached or joined with another thread.
18356 The thrd_detach function returns thrd_success on success or thrd_error if
18357 the request could not be honored.
18359 <a name="7.25.5.4" href="#7.25.5.4"><h5>7.25.5.4 The thrd_equal function</h5></a>
18363 #include <threads.h>
18364 int thrd_equal(thrd_t thr0, thrd_t thr1);</pre>
18365 <h6>Description</h6>
18367 The thrd_equal function will determine whether the thread identified by thr0 refers
18368 to the thread identified by thr1.
18371 The thrd_equal function returns zero if the thread thr0 and the thread thr1 refer to
18372 different threads. Otherwise the thrd_equal function returns a nonzero value.
18374 <a name="7.25.5.5" href="#7.25.5.5"><h5>7.25.5.5 The thrd_exit function</h5></a>
18378 #include <threads.h>
18379 void thrd_exit(int res);</pre>
18380 <h6>Description</h6>
18382 The thrd_exit function terminates execution of the calling thread and sets its result
18386 The thrd_exit function returns no value.
18388 <a name="7.25.5.6" href="#7.25.5.6"><h5>7.25.5.6 The thrd_join function</h5></a>
18392 #include <threads.h>
18393 int thrd_join(thrd_t thr, int *res);</pre>
18394 <h6>Description</h6>
18396 The thrd_join function joins the thread identified by thr with the current thread by
18397 blocking until the other thread has terminated. If the parameter res is not a null pointer,
18398 <!--page 400 indent 4-->
18399 it stores the thread's result code in the integer pointed to by res. The termination of the
18400 other thread synchronizes with the completion of the thrd_join function. The thread
18401 identified by thr shall not have been previously detached or joined with another thread.
18404 The thrd_join function returns thrd_success on success or thrd_error if the
18405 request could not be honored.
18407 <a name="7.25.5.7" href="#7.25.5.7"><h5>7.25.5.7 The thrd_sleep function</h5></a>
18411 #include <threads.h>
18412 void thrd_sleep(const xtime *xt);</pre>
18413 <h6>Description</h6>
18415 The thrd_sleep function suspends execution of the calling thread until after the time
18416 specified by the xtime object pointed to by xt.
18419 The thrd_sleep function returns no value.
18421 <a name="7.25.5.8" href="#7.25.5.8"><h5>7.25.5.8 The thrd_yield function</h5></a>
18425 #include <threads.h>
18426 void thrd_yield(void);</pre>
18427 <h6>Description</h6>
18429 The thrd_yield function endeavors to permit other threads to run, even if the current
18430 thread would ordinarily continue to run.
18433 The thrd_yield function returns no value.
18435 <a name="7.25.6" href="#7.25.6"><h4>7.25.6 Thread-specific storage functions</h4></a>
18437 <a name="7.25.6.1" href="#7.25.6.1"><h5>7.25.6.1 The tss_create function</h5></a>
18441 #include <threads.h>
18442 int tss_create(tss_t *key, tss_dtor_t dtor);</pre>
18443 <h6>Description</h6>
18445 The tss_create function creates a thread-specific storage pointer with destructor
18446 dtor, which may be null.
18447 <!--page 401 indent 4-->
18450 If the tss_create function is successful, it sets the thread-specific storage pointed to
18451 by key to a value that uniquely identifies the newly created pointer and returns
18452 thrd_success; otherwise, thrd_error is returned and the thread-specific storage
18453 pointed to by key is set to an undefined value.
18455 <a name="7.25.6.2" href="#7.25.6.2"><h5>7.25.6.2 The tss_delete function</h5></a>
18459 #include <threads.h>
18460 void tss_delete(tss_t key);</pre>
18461 <h6>Description</h6>
18463 The tss_delete function releases any resources used by the thread-specific storage
18467 The tss_delete function returns no value.
18469 <a name="7.25.6.3" href="#7.25.6.3"><h5>7.25.6.3 The tss_get function</h5></a>
18473 #include <threads.h>
18474 void *tss_get(tss_t key);</pre>
18475 <h6>Description</h6>
18477 The tss_get function returns the value for the current thread held in the thread-specific
18478 storage identified by key.
18481 The tss_get function returns the value for the current thread if successful, or zero if
18484 <a name="7.25.6.4" href="#7.25.6.4"><h5>7.25.6.4 The tss_set function</h5></a>
18488 #include <threads.h>
18489 int tss_set(tss_t key, void *val);</pre>
18490 <h6>Description</h6>
18492 The tss_set function sets the value for the current thread held in the thread-specific
18493 storage identified by key to val.
18494 <!--page 402 indent 4-->
18497 The tss_set function returns thrd_success on success or thrd_error if the
18498 request could not be honored.
18500 <a name="7.25.7" href="#7.25.7"><h4>7.25.7 Time functions</h4></a>
18502 <a name="7.25.7.1" href="#7.25.7.1"><h5>7.25.7.1 The xtime_get function</h5></a>
18506 #include <threads.h>
18507 int xtime_get(xtime *xt, int base);</pre>
18508 <h6>Description</h6>
18510 The xtime_get function sets the xtime object pointed to by xt to hold the current
18511 time based on the time base base.
18514 If the xtime_get function is successful it returns the nonzero value base, which must
18515 be TIME_UTC; otherwise, it returns zero.<sup><a href="#note306"><b>306)</b></a></sup>
18520 <!--page 403 indent 4-->
18523 <p><a name="note306">306)</a> Although an xtime object describes times with nanosecond resolution, the actual resolution in an
18524 xtime object is system dependent.
18527 <a name="7.26" href="#7.26"><h3>7.26 Date and time <time.h></h3></a>
18529 <a name="7.26.1" href="#7.26.1"><h4>7.26.1 Components of time</h4></a>
18531 The header <time.h> defines two macros, and declares several types and functions for
18532 manipulating time. Many functions deal with a calendar time that represents the current
18533 date (according to the Gregorian calendar) and time. Some functions deal with local
18534 time, which is the calendar time expressed for some specific time zone, and with Daylight
18535 Saving Time, which is a temporary change in the algorithm for determining local time.
18536 The local time zone and Daylight Saving Time are implementation-defined.
18538 The macros defined are NULL (described in <a href="#7.19">7.19</a>); and
18540 CLOCKS_PER_SEC</pre>
18541 which expands to an expression with type clock_t (described below) that is the
18542 number per second of the value returned by the clock function.
18544 The types declared are size_t (described in <a href="#7.19">7.19</a>);
18550 which are arithmetic types capable of representing times; and
18553 which holds the components of a calendar time, called the broken-down time.
18555 The range and precision of times representable in clock_t and time_t are
18556 implementation-defined. The tm structure shall contain at least the following members,
18557 in any order. The semantics of the members and their normal ranges are expressed in the
18558 comments.<sup><a href="#note307"><b>307)</b></a></sup>
18560 int tm_sec; // seconds after the minute -- [0, 60]
18561 int tm_min; // minutes after the hour -- [0, 59]
18562 int tm_hour; // hours since midnight -- [0, 23]
18563 int tm_mday; // day of the month -- [1, 31]
18564 int tm_mon; // months since January -- [0, 11]
18565 int tm_year; // years since 1900
18566 int tm_wday; // days since Sunday -- [0, 6]
18567 int tm_yday; // days since January 1 -- [0, 365]
18568 int tm_isdst; // Daylight Saving Time flag</pre>
18572 <!--page 404 indent 4-->
18573 The value of tm_isdst is positive if Daylight Saving Time is in effect, zero if Daylight
18574 Saving Time is not in effect, and negative if the information is not available.
18577 <p><a name="note307">307)</a> The range [0, 60] for tm_sec allows for a positive leap second.
18580 <a name="7.26.2" href="#7.26.2"><h4>7.26.2 Time manipulation functions</h4></a>
18582 <a name="7.26.2.1" href="#7.26.2.1"><h5>7.26.2.1 The clock function</h5></a>
18586 #include <time.h>
18587 clock_t clock(void);</pre>
18588 <h6>Description</h6>
18590 The clock function determines the processor time used.
18593 The clock function returns the implementation's best approximation to the processor
18594 time used by the program since the beginning of an implementation-defined era related
18595 only to the program invocation. To determine the time in seconds, the value returned by
18596 the clock function should be divided by the value of the macro CLOCKS_PER_SEC. If
18597 the processor time used is not available or its value cannot be represented, the function
18598 returns the value (clock_t)(-1).<sup><a href="#note308"><b>308)</b></a></sup>
18601 <p><a name="note308">308)</a> In order to measure the time spent in a program, the clock function should be called at the start of
18602 the program and its return value subtracted from the value returned by subsequent calls.
18605 <a name="7.26.2.2" href="#7.26.2.2"><h5>7.26.2.2 The difftime function</h5></a>
18609 #include <time.h>
18610 double difftime(time_t time1, time_t time0);</pre>
18611 <h6>Description</h6>
18613 The difftime function computes the difference between two calendar times: time1 -
18617 The difftime function returns the difference expressed in seconds as a double.
18622 <!--page 405 indent 4-->
18624 <a name="7.26.2.3" href="#7.26.2.3"><h5>7.26.2.3 The mktime function</h5></a>
18628 #include <time.h>
18629 time_t mktime(struct tm *timeptr);</pre>
18630 <h6>Description</h6>
18632 The mktime function converts the broken-down time, expressed as local time, in the
18633 structure pointed to by timeptr into a calendar time value with the same encoding as
18634 that of the values returned by the time function. The original values of the tm_wday
18635 and tm_yday components of the structure are ignored, and the original values of the
18636 other components are not restricted to the ranges indicated above.<sup><a href="#note309"><b>309)</b></a></sup> On successful
18637 completion, the values of the tm_wday and tm_yday components of the structure are
18638 set appropriately, and the other components are set to represent the specified calendar
18639 time, but with their values forced to the ranges indicated above; the final value of
18640 tm_mday is not set until tm_mon and tm_year are determined.
18643 The mktime function returns the specified calendar time encoded as a value of type
18644 time_t. If the calendar time cannot be represented, the function returns the value
18647 EXAMPLE What day of the week is July 4, 2001?
18649 #include <stdio.h>
18650 #include <time.h>
18651 static const char *const wday[] = {
18652 "Sunday", "Monday", "Tuesday", "Wednesday",
18653 "Thursday", "Friday", "Saturday", "-unknown-"
18655 struct tm time_str;
18661 <!--page 406 indent 4-->
18663 time_str.tm_year = 2001 - 1900;
18664 time_str.tm_mon = 7 - 1;
18665 time_str.tm_mday = 4;
18666 time_str.tm_hour = 0;
18667 time_str.tm_min = 0;
18668 time_str.tm_sec = 1;
18669 time_str.tm_isdst = -1;
18670 if (mktime(&time_str) == (time_t)(-1))
18671 time_str.tm_wday = 7;
18672 printf("%s\n", wday[time_str.tm_wday]);</pre>
18676 <p><a name="note309">309)</a> Thus, a positive or zero value for tm_isdst causes the mktime function to presume initially that
18677 Daylight Saving Time, respectively, is or is not in effect for the specified time. A negative value
18678 causes it to attempt to determine whether Daylight Saving Time is in effect for the specified time.
18681 <a name="7.26.2.4" href="#7.26.2.4"><h5>7.26.2.4 The time function</h5></a>
18685 #include <time.h>
18686 time_t time(time_t *timer);</pre>
18687 <h6>Description</h6>
18689 The time function determines the current calendar time. The encoding of the value is
18693 The time function returns the implementation's best approximation to the current
18694 calendar time. The value (time_t)(-1) is returned if the calendar time is not
18695 available. If timer is not a null pointer, the return value is also assigned to the object it
18698 <a name="7.26.3" href="#7.26.3"><h4>7.26.3 Time conversion functions</h4></a>
18700 Except for the strftime function, these functions each return a pointer to one of two
18701 types of static objects: a broken-down time structure or an array of char. Execution of
18702 any of the functions that return a pointer to one of these object types may overwrite the
18703 information in any object of the same type pointed to by the value returned from any
18704 previous call to any of them and the functions are not required to avoid data races. The
18705 implementation shall behave as if no other library functions call these functions.
18707 <a name="7.26.3.1" href="#7.26.3.1"><h5>7.26.3.1 The asctime function</h5></a>
18711 #include <time.h>
18712 char *asctime(const struct tm *timeptr);</pre>
18713 <h6>Description</h6>
18715 The asctime function converts the broken-down time in the structure pointed to by
18716 timeptr into a string in the form
18717 <!--page 407 indent 4-->
18719 Sun Sep 16 01:03:52 1973\n\0</pre>
18720 using the equivalent of the following algorithm.
18721 char *asctime(const struct tm *timeptr)
18724 static const char wday_name[7][3] = {
18725 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
18727 static const char mon_name[12][3] = {
18728 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
18729 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
18731 static char result[26];
18732 sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
18733 wday_name[timeptr->tm_wday],
18734 mon_name[timeptr->tm_mon],
18735 timeptr->tm_mday, timeptr->tm_hour,
18736 timeptr->tm_min, timeptr->tm_sec,
18737 1900 + timeptr->tm_year);
18738 return result;</pre>
18741 If any of the fields of the broken-down time contain values that are outside their normal
18742 ranges,<sup><a href="#note310"><b>310)</b></a></sup> the behavior of the asctime function is undefined. Likewise, if the
18743 calculated year exceeds four digits or is less than the year 1000, the behavior is
18747 The asctime function returns a pointer to the string.
18750 <p><a name="note310">310)</a> See <a href="#7.26.1">7.26.1</a>.
18753 <a name="7.26.3.2" href="#7.26.3.2"><h5>7.26.3.2 The ctime function</h5></a>
18757 #include <time.h>
18758 char *ctime(const time_t *timer);</pre>
18759 <h6>Description</h6>
18761 The ctime function converts the calendar time pointed to by timer to local time in the
18762 form of a string. It is equivalent to
18764 asctime(localtime(timer))</pre>
18768 <!--page 408 indent 4-->
18771 The ctime function returns the pointer returned by the asctime function with that
18772 broken-down time as argument.
18773 Forward references: the localtime function (<a href="#7.26.3.4">7.26.3.4</a>).
18775 <a name="7.26.3.3" href="#7.26.3.3"><h5>7.26.3.3 The gmtime function</h5></a>
18779 #include <time.h>
18780 struct tm *gmtime(const time_t *timer);</pre>
18781 <h6>Description</h6>
18783 The gmtime function converts the calendar time pointed to by timer into a broken-
18784 down time, expressed as UTC.
18787 The gmtime function returns a pointer to the broken-down time, or a null pointer if the
18788 specified time cannot be converted to UTC.
18790 <a name="7.26.3.4" href="#7.26.3.4"><h5>7.26.3.4 The localtime function</h5></a>
18794 #include <time.h>
18795 struct tm *localtime(const time_t *timer);</pre>
18796 <h6>Description</h6>
18798 The localtime function converts the calendar time pointed to by timer into a
18799 broken-down time, expressed as local time.
18802 The localtime function returns a pointer to the broken-down time, or a null pointer if
18803 the specified time cannot be converted to local time.
18805 <a name="7.26.3.5" href="#7.26.3.5"><h5>7.26.3.5 The strftime function</h5></a>
18808 <!--page 409 indent 4-->
18810 #include <time.h>
18811 size_t strftime(char * restrict s,
18813 const char * restrict format,
18814 const struct tm * restrict timeptr);</pre>
18815 <h6>Description</h6>
18817 The strftime function places characters into the array pointed to by s as controlled by
18818 the string pointed to by format. The format shall be a multibyte character sequence,
18819 beginning and ending in its initial shift state. The format string consists of zero or
18820 more conversion specifiers and ordinary multibyte characters. A conversion specifier
18821 consists of a % character, possibly followed by an E or O modifier character (described
18822 below), followed by a character that determines the behavior of the conversion specifier.
18823 All ordinary multibyte characters (including the terminating null character) are copied
18824 unchanged into the array. If copying takes place between objects that overlap, the
18825 behavior is undefined. No more than maxsize characters are placed into the array.
18827 Each conversion specifier is replaced by appropriate characters as described in the
18828 following list. The appropriate characters are determined using the LC_TIME category
18829 of the current locale and by the values of zero or more members of the broken-down time
18830 structure pointed to by timeptr, as specified in brackets in the description. If any of
18831 the specified values is outside the normal range, the characters stored are unspecified.
18832 %a is replaced by the locale's abbreviated weekday name. [tm_wday]
18833 %A is replaced by the locale's full weekday name. [tm_wday]
18834 %b is replaced by the locale's abbreviated month name. [tm_mon]
18835 %B is replaced by the locale's full month name. [tm_mon]
18836 %c is replaced by the locale's appropriate date and time representation. [all specified
18838 in <a href="#7.26.1">7.26.1</a>]</pre>
18839 %C is replaced by the year divided by 100 and truncated to an integer, as a decimal
18841 number (00-99). [tm_year]</pre>
18842 %d is replaced by the day of the month as a decimal number (01-31). [tm_mday]
18843 %D is equivalent to ''%m/%d/%y''. [tm_mon, tm_mday, tm_year]
18844 %e is replaced by the day of the month as a decimal number (1-31); a single digit is
18846 preceded by a space. [tm_mday]</pre>
18847 %F is equivalent to ''%Y-%m-%d'' (the ISO 8601 date format). [tm_year, tm_mon,
18850 %g is replaced by the last 2 digits of the week-based year (see below) as a decimal
18852 number (00-99). [tm_year, tm_wday, tm_yday]</pre>
18853 %G is replaced by the week-based year (see below) as a decimal number (e.g., 1997).
18855 [tm_year, tm_wday, tm_yday]</pre>
18856 %h is equivalent to ''%b''. [tm_mon]
18857 %H is replaced by the hour (24-hour clock) as a decimal number (00-23). [tm_hour]
18858 %I is replaced by the hour (12-hour clock) as a decimal number (01-12). [tm_hour]
18859 %j is replaced by the day of the year as a decimal number (001-366). [tm_yday]
18860 %m is replaced by the month as a decimal number (01-12). [tm_mon]
18861 %M is replaced by the minute as a decimal number (00-59). [tm_min]
18862 %n is replaced by a new-line character.
18863 <!--page 410 indent 4-->
18864 %p is replaced by the locale's equivalent of the AM/PM designations associated with a
18866 12-hour clock. [tm_hour]</pre>
18867 %r is replaced by the locale's 12-hour clock time. [tm_hour, tm_min, tm_sec]
18868 %R is equivalent to ''%H:%M''. [tm_hour, tm_min]
18869 %S is replaced by the second as a decimal number (00-60). [tm_sec]
18870 %t is replaced by a horizontal-tab character.
18871 %T is equivalent to ''%H:%M:%S'' (the ISO 8601 time format). [tm_hour, tm_min,
18874 %u is replaced by the ISO 8601 weekday as a decimal number (1-7), where Monday
18876 is 1. [tm_wday]</pre>
18877 %U is replaced by the week number of the year (the first Sunday as the first day of week
18879 1) as a decimal number (00-53). [tm_year, tm_wday, tm_yday]</pre>
18880 %V is replaced by the ISO 8601 week number (see below) as a decimal number
18882 (01-53). [tm_year, tm_wday, tm_yday]</pre>
18883 %w is replaced by the weekday as a decimal number (0-6), where Sunday is 0.
18886 %W is replaced by the week number of the year (the first Monday as the first day of
18888 week 1) as a decimal number (00-53). [tm_year, tm_wday, tm_yday]</pre>
18889 %x is replaced by the locale's appropriate date representation. [all specified in <a href="#7.26.1">7.26.1</a>]
18890 %X is replaced by the locale's appropriate time representation. [all specified in <a href="#7.26.1">7.26.1</a>]
18891 %y is replaced by the last 2 digits of the year as a decimal number (00-99).
18894 %Y is replaced by the year as a decimal number (e.g., 1997). [tm_year]
18895 %z is replaced by the offset from UTC in the ISO 8601 format ''-0430'' (meaning 4
18897 hours 30 minutes behind UTC, west of Greenwich), or by no characters if no time
18898 zone is determinable. [tm_isdst]</pre>
18899 %Z is replaced by the locale's time zone name or abbreviation, or by no characters if no
18901 time zone is determinable. [tm_isdst]</pre>
18902 %% is replaced by %.
18904 Some conversion specifiers can be modified by the inclusion of an E or O modifier
18905 character to indicate an alternative format or specification. If the alternative format or
18906 specification does not exist for the current locale, the modifier is ignored.
18907 %Ec is replaced by the locale's alternative date and time representation.
18908 %EC is replaced by the name of the base year (period) in the locale's alternative
18910 representation.</pre>
18911 %Ex is replaced by the locale's alternative date representation.
18912 %EX is replaced by the locale's alternative time representation.
18913 %Ey is replaced by the offset from %EC (year only) in the locale's alternative
18915 representation.</pre>
18916 %EY is replaced by the locale's full alternative year representation.
18917 <!--page 411 indent 4-->
18918 %Od is replaced by the day of the month, using the locale's alternative numeric symbols
18920 (filled as needed with leading zeros, or with leading spaces if there is no alternative
18921 symbol for zero).</pre>
18922 %Oe is replaced by the day of the month, using the locale's alternative numeric symbols
18924 (filled as needed with leading spaces).</pre>
18925 %OH is replaced by the hour (24-hour clock), using the locale's alternative numeric
18928 %OI is replaced by the hour (12-hour clock), using the locale's alternative numeric
18931 %Om is replaced by the month, using the locale's alternative numeric symbols.
18932 %OM is replaced by the minutes, using the locale's alternative numeric symbols.
18933 %OS is replaced by the seconds, using the locale's alternative numeric symbols.
18934 %Ou is replaced by the ISO 8601 weekday as a number in the locale's alternative
18936 representation, where Monday is 1.</pre>
18937 %OU is replaced by the week number, using the locale's alternative numeric symbols.
18938 %OV is replaced by the ISO 8601 week number, using the locale's alternative numeric
18941 %Ow is replaced by the weekday as a number, using the locale's alternative numeric
18944 %OW is replaced by the week number of the year, using the locale's alternative numeric
18947 %Oy is replaced by the last 2 digits of the year, using the locale's alternative numeric
18951 %g, %G, and %V give values according to the ISO 8601 week-based year. In this system,
18952 weeks begin on a Monday and week 1 of the year is the week that includes January 4th,
18953 which is also the week that includes the first Thursday of the year, and is also the first
18954 week that contains at least four days in the year. If the first Monday of January is the
18955 2nd, 3rd, or 4th, the preceding days are part of the last week of the preceding year; thus,
18956 for Saturday 2nd January 1999, %G is replaced by 1998 and %V is replaced by 53. If
18957 December 29th, 30th, or 31st is a Monday, it and any following days are part of week 1 of
18958 the following year. Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and
18959 %V is replaced by 01.
18961 If a conversion specifier is not one of the above, the behavior is undefined.
18963 In the "C" locale, the E and O modifiers are ignored and the replacement strings for the
18964 following specifiers are:
18965 %a the first three characters of %A.
18966 %A one of ''Sunday'', ''Monday'', ... , ''Saturday''.
18967 %b the first three characters of %B.
18968 %B one of ''January'', ''February'', ... , ''December''.
18969 %c equivalent to ''%a %b %e %T %Y''.
18970 <!--page 412 indent 4-->
18971 %p one of ''AM'' or ''PM''.
18972 %r equivalent to ''%I:%M:%S %p''.
18973 %x equivalent to ''%m/%d/%y''.
18974 %X equivalent to %T.
18975 %Z implementation-defined.
18978 If the total number of resulting characters including the terminating null character is not
18979 more than maxsize, the strftime function returns the number of characters placed
18980 into the array pointed to by s not including the terminating null character. Otherwise,
18981 zero is returned and the contents of the array are indeterminate.
18982 <!--page 413 indent 4-->
18984 <a name="7.27" href="#7.27"><h3>7.27 Unicode utilities <uchar.h></h3></a>
18986 The header <uchar.h> declares types and functions for manipulating Unicode
18989 The types declared are mbstate_t (described in <a href="#7.29.1">7.29.1</a>) and size_t (described in
18990 <a href="#7.19">7.19</a>);
18993 which is an unsigned integer type used for 16-bit characters and is the same type as
18994 uint_least16_t (described in <a href="#7.20.1.2">7.20.1.2</a>); and
18997 which is an unsigned integer type used for 32-bit characters and is the same type as
18998 uint_least32_t (also described in <a href="#7.20.1.2">7.20.1.2</a>).
19000 <a name="7.27.1" href="#7.27.1"><h4>7.27.1 Restartable multibyte/wide character conversion functions</h4></a>
19002 These functions have a parameter, ps, of type pointer to mbstate_t that points to an
19003 object that can completely describe the current conversion state of the associated
19004 multibyte character sequence, which the functions alter as necessary. If ps is a null
19005 pointer, each function uses its own internal mbstate_t object instead, which is
19006 initialized at program startup to the initial conversion state; the functions are not required
19007 to avoid data races in this case. The implementation behaves as if no library function
19008 calls these functions with a null pointer for ps.
19010 <a name="7.27.1.1" href="#7.27.1.1"><h5>7.27.1.1 The mbrtoc16 function</h5></a>
19014 #include <uchar.h>
19015 size_t mbrtoc16(char16_t * restrict pc16,
19016 const char * restrict s, size_t n,
19017 mbstate_t * restrict ps);</pre>
19018 <h6>Description</h6>
19020 If s is a null pointer, the mbrtoc16 function is equivalent to the call:
19022 mbrtoc16(NULL, "", 1, ps)</pre>
19023 In this case, the values of the parameters pc16 and n are ignored.
19025 If s is not a null pointer, the mbrtoc16 function inspects at most n bytes beginning with
19026 the byte pointed to by s to determine the number of bytes needed to complete the next
19027 multibyte character (including any shift sequences). If the function determines that the
19028 next multibyte character is complete and valid, it determines the values of the
19029 corresponding wide characters and then, if pc16 is not a null pointer, stores the value of
19030 the first (or only) such character in the object pointed to by pc16. Subsequent calls will
19031 <!--page 414 indent 4-->
19032 store successive wide characters without consuming any additional input until all the
19033 characters have been stored. If the corresponding wide character is the null wide
19034 character, the resulting state described is the initial conversion state.
19037 The mbrtoc16 function returns the first of the following that applies (given the current
19039 0 if the next n or fewer bytes complete the multibyte character that
19041 corresponds to the null wide character (which is the value stored).</pre>
19042 between 1 and n inclusive if the next n or fewer bytes complete a valid multibyte
19044 character (which is the value stored); the value returned is the number
19045 of bytes that complete the multibyte character.</pre>
19046 (size_t)(-3) if the next character resulting from a previous call has been stored (no
19048 bytes from the input have been consumed by this call).</pre>
19049 (size_t)(-2) if the next n bytes contribute to an incomplete (but potentially valid)
19051 multibyte character, and all n bytes have been processed (no value is
19052 stored).<sup><a href="#note311"><b>311)</b></a></sup></pre>
19053 (size_t)(-1) if an encoding error occurs, in which case the next n or fewer bytes
19055 do not contribute to a complete and valid multibyte character (no
19056 value is stored); the value of the macro EILSEQ is stored in errno,
19057 and the conversion state is unspecified.</pre>
19060 <p><a name="note311">311)</a> When n has at least the value of the MB_CUR_MAX macro, this case can only occur if s points at a
19061 sequence of redundant shift sequences (for implementations with state-dependent encodings).
19064 <a name="7.27.1.2" href="#7.27.1.2"><h5>7.27.1.2 The c16rtomb function</h5></a>
19068 #include <uchar.h>
19069 size_t c16rtomb(char * restrict s, char16_t c16,
19070 mbstate_t * restrict ps);</pre>
19071 <h6>Description</h6>
19073 If s is a null pointer, the c16rtomb function is equivalent to the call
19075 c16rtomb(buf, L'\0', ps)</pre>
19076 where buf is an internal buffer.
19078 If s is not a null pointer, the c16rtomb function determines the number of bytes needed
19079 to represent the multibyte character that corresponds to the wide character given by c16
19080 (including any shift sequences), and stores the multibyte character representation in the
19083 <!--page 415 indent 4-->
19084 array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
19085 c16 is a null wide character, a null byte is stored, preceded by any shift sequence needed
19086 to restore the initial shift state; the resulting state described is the initial conversion state.
19089 The c16rtomb function returns the number of bytes stored in the array object (including
19090 any shift sequences). When c16 is not a valid wide character, an encoding error occurs:
19091 the function stores the value of the macro EILSEQ in errno and returns
19092 (size_t)(-1); the conversion state is unspecified.
19094 <a name="7.27.1.3" href="#7.27.1.3"><h5>7.27.1.3 The mbrtoc32 function</h5></a>
19098 #include <uchar.h>
19099 size_t mbrtoc32(char32_t * restrict pc32,
19100 const char * restrict s, size_t n,
19101 mbstate_t * restrict ps);</pre>
19102 <h6>Description</h6>
19104 If s is a null pointer, the mbrtoc32 function is equivalent to the call:
19106 mbrtoc32(NULL, "", 1, ps)</pre>
19107 In this case, the values of the parameters pc32 and n are ignored.
19109 If s is not a null pointer, the mbrtoc32 function inspects at most n bytes beginning with
19110 the byte pointed to by s to determine the number of bytes needed to complete the next
19111 multibyte character (including any shift sequences). If the function determines that the
19112 next multibyte character is complete and valid, it determines the values of the
19113 corresponding wide characters and then, if pc32 is not a null pointer, stores the value of
19114 the first (or only) such character in the object pointed to by pc32. Subsequent calls will
19115 store successive wide characters without consuming any additional input until all the
19116 characters have been stored. If the corresponding wide character is the null wide
19117 character, the resulting state described is the initial conversion state.
19120 The mbrtoc32 function returns the first of the following that applies (given the current
19122 0 if the next n or fewer bytes complete the multibyte character that
19124 corresponds to the null wide character (which is the value stored).</pre>
19125 between 1 and n inclusive if the next n or fewer bytes complete a valid multibyte
19126 <!--page 416 indent 4-->
19128 character (which is the value stored); the value returned is the number
19129 of bytes that complete the multibyte character.</pre>
19130 (size_t)(-3) if the next character resulting from a previous call has been stored (no
19132 bytes from the input have been consumed by this call).</pre>
19133 (size_t)(-2) if the next n bytes contribute to an incomplete (but potentially valid)
19135 multibyte character, and all n bytes have been processed (no value is
19136 stored).<sup><a href="#note312"><b>312)</b></a></sup></pre>
19137 (size_t)(-1) if an encoding error occurs, in which case the next n or fewer bytes
19139 do not contribute to a complete and valid multibyte character (no
19140 value is stored); the value of the macro EILSEQ is stored in errno,
19141 and the conversion state is unspecified.</pre>
19144 <p><a name="note312">312)</a> When n has at least the value of the MB_CUR_MAX macro, this case can only occur if s points at a
19145 sequence of redundant shift sequences (for implementations with state-dependent encodings).
19148 <a name="7.27.1.4" href="#7.27.1.4"><h5>7.27.1.4 The c32rtomb function</h5></a>
19152 #include <uchar.h>
19153 size_t c32rtomb(char * restrict s, char32_t c32,
19154 mbstate_t * restrict ps);</pre>
19155 <h6>Description</h6>
19157 If s is a null pointer, the c32rtomb function is equivalent to the call
19159 c32rtomb(buf, L'\0', ps)</pre>
19160 where buf is an internal buffer.
19162 If s is not a null pointer, the c32rtomb function determines the number of bytes needed
19163 to represent the multibyte character that corresponds to the wide character given by c32
19164 (including any shift sequences), and stores the multibyte character representation in the
19165 array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
19166 c32 is a null wide character, a null byte is stored, preceded by any shift sequence needed
19167 to restore the initial shift state; the resulting state described is the initial conversion state.
19170 The c32rtomb function returns the number of bytes stored in the array object (including
19171 any shift sequences). When c32 is not a valid wide character, an encoding error occurs:
19172 the function stores the value of the macro EILSEQ in errno and returns
19173 (size_t)(-1); the conversion state is unspecified.
19178 <!--page 417 indent 4-->
19180 <a name="7.28" href="#7.28"><h3>7.28 Extended multibyte and wide character utilities <wchar.h></h3></a>
19182 <a name="7.28.1" href="#7.28.1"><h4>7.28.1 Introduction</h4></a>
19184 The header <wchar.h> defines four macros, and declares four data types, one tag, and
19185 many functions.<sup><a href="#note313"><b>313)</b></a></sup>
19187 The types declared are wchar_t and size_t (both described in <a href="#7.19">7.19</a>);
19190 which is a complete object type other than an array type that can hold the conversion state
19191 information necessary to convert between sequences of multibyte characters and wide
19195 which is an integer type unchanged by default argument promotions that can hold any
19196 value corresponding to members of the extended character set, as well as at least one
19197 value that does not correspond to any member of the extended character set (see WEOF
19198 below);<sup><a href="#note314"><b>314)</b></a></sup> and
19201 which is declared as an incomplete structure type (the contents are described in <a href="#7.26.1">7.26.1</a>).
19203 The macros defined are NULL (described in <a href="#7.19">7.19</a>); WCHAR_MIN and WCHAR_MAX
19204 (described in <a href="#7.20.3">7.20.3</a>); and
19207 which expands to a constant expression of type wint_t whose value does not
19208 correspond to any member of the extended character set.<sup><a href="#note315"><b>315)</b></a></sup> It is accepted (and returned)
19209 by several functions in this subclause to indicate end-of-file, that is, no more input from a
19210 stream. It is also used as a wide character value that does not correspond to any member
19211 of the extended character set.
19213 The functions declared are grouped as follows:
19215 <li> Functions that perform input and output of wide characters, or multibyte characters,
19217 <li> Functions that provide wide string numeric conversion;
19218 <li> Functions that perform general wide string manipulation;
19221 <!--page 418 indent 4-->
19222 <li> Functions for wide string date and time conversion; and
19223 <li> Functions that provide extended capabilities for conversion between multibyte and
19224 wide character sequences.
19227 Unless explicitly stated otherwise, if the execution of a function described in this
19228 subclause causes copying to take place between objects that overlap, the behavior is
19232 <p><a name="note313">313)</a> See ''future library directions'' (<a href="#7.30.12">7.30.12</a>).
19234 <p><a name="note314">314)</a> wchar_t and wint_t can be the same integer type.
19236 <p><a name="note315">315)</a> The value of the macro WEOF may differ from that of EOF and need not be negative.
19239 <a name="7.28.2" href="#7.28.2"><h4>7.28.2 Formatted wide character input/output functions</h4></a>
19241 The formatted wide character input/output functions shall behave as if there is a sequence
19242 point after the actions associated with each specifier.<sup><a href="#note316"><b>316)</b></a></sup>
19245 <p><a name="note316">316)</a> The fwprintf functions perform writes to memory for the %n specifier.
19248 <a name="7.28.2.1" href="#7.28.2.1"><h5>7.28.2.1 The fwprintf function</h5></a>
19252 #include <stdio.h>
19253 #include <wchar.h>
19254 int fwprintf(FILE * restrict stream,
19255 const wchar_t * restrict format, ...);</pre>
19256 <h6>Description</h6>
19258 The fwprintf function writes output to the stream pointed to by stream, under
19259 control of the wide string pointed to by format that specifies how subsequent arguments
19260 are converted for output. If there are insufficient arguments for the format, the behavior
19261 is undefined. If the format is exhausted while arguments remain, the excess arguments
19262 are evaluated (as always) but are otherwise ignored. The fwprintf function returns
19263 when the end of the format string is encountered.
19265 The format is composed of zero or more directives: ordinary wide characters (not %),
19266 which are copied unchanged to the output stream; and conversion specifications, each of
19267 which results in fetching zero or more subsequent arguments, converting them, if
19268 applicable, according to the corresponding conversion specifier, and then writing the
19269 result to the output stream.
19271 Each conversion specification is introduced by the wide character %. After the %, the
19272 following appear in sequence:
19274 <li> Zero or more flags (in any order) that modify the meaning of the conversion
19276 <li> An optional minimum field width. If the converted value has fewer wide characters
19277 than the field width, it is padded with spaces (by default) on the left (or right, if the
19280 <!--page 419 indent 4-->
19281 left adjustment flag, described later, has been given) to the field width. The field
19282 width takes the form of an asterisk * (described later) or a nonnegative decimal
19283 integer.<sup><a href="#note317"><b>317)</b></a></sup>
19284 <li> An optional precision that gives the minimum number of digits to appear for the d, i,
19285 o, u, x, and X conversions, the number of digits to appear after the decimal-point
19286 wide character for a, A, e, E, f, and F conversions, the maximum number of
19287 significant digits for the g and G conversions, or the maximum number of wide
19288 characters to be written for s conversions. The precision takes the form of a period
19289 (.) followed either by an asterisk * (described later) or by an optional decimal
19290 integer; if only the period is specified, the precision is taken as zero. If a precision
19291 appears with any other conversion specifier, the behavior is undefined.
19292 <li> An optional length modifier that specifies the size of the argument.
19293 <li> A conversion specifier wide character that specifies the type of conversion to be
19297 As noted above, a field width, or precision, or both, may be indicated by an asterisk. In
19298 this case, an int argument supplies the field width or precision. The arguments
19299 specifying field width, or precision, or both, shall appear (in that order) before the
19300 argument (if any) to be converted. A negative field width argument is taken as a - flag
19301 followed by a positive field width. A negative precision argument is taken as if the
19302 precision were omitted.
19304 The flag wide characters and their meanings are:
19305 - The result of the conversion is left-justified within the field. (It is right-justified if
19307 this flag is not specified.)</pre>
19308 + The result of a signed conversion always begins with a plus or minus sign. (It
19310 begins with a sign only when a negative value is converted if this flag is not
19311 specified.)<sup><a href="#note318"><b>318)</b></a></sup></pre>
19312 space If the first wide character of a signed conversion is not a sign, or if a signed
19314 conversion results in no wide characters, a space is prefixed to the result. If the
19315 space and + flags both appear, the space flag is ignored.</pre>
19316 # The result is converted to an ''alternative form''. For o conversion, it increases
19318 the precision, if and only if necessary, to force the first digit of the result to be a
19319 zero (if the value and precision are both 0, a single 0 is printed). For x (or X)
19320 conversion, a nonzero result has 0x (or 0X) prefixed to it. For a, A, e, E, f, F, g,</pre>
19323 <!--page 420 indent 4-->
19325 and G conversions, the result of converting a floating-point number always
19326 contains a decimal-point wide character, even if no digits follow it. (Normally, a
19327 decimal-point wide character appears in the result of these conversions only if a
19328 digit follows it.) For g and G conversions, trailing zeros are not removed from the
19329 result. For other conversions, the behavior is undefined.</pre>
19330 0 For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions, leading zeros
19333 (following any indication of sign or base) are used to pad to the field width rather
19334 than performing space padding, except when converting an infinity or NaN. If the
19335 0 and - flags both appear, the 0 flag is ignored. For d, i, o, u, x, and X
19336 conversions, if a precision is specified, the 0 flag is ignored. For other
19337 conversions, the behavior is undefined.</pre>
19338 The length modifiers and their meanings are:
19339 hh Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19341 signed char or unsigned char argument (the argument will have
19342 been promoted according to the integer promotions, but its value shall be
19343 converted to signed char or unsigned char before printing); or that
19344 a following n conversion specifier applies to a pointer to a signed char
19346 h Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19348 short int or unsigned short int argument (the argument will
19349 have been promoted according to the integer promotions, but its value shall
19350 be converted to short int or unsigned short int before printing);
19351 or that a following n conversion specifier applies to a pointer to a short
19352 int argument.</pre>
19353 l (ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19355 long int or unsigned long int argument; that a following n
19356 conversion specifier applies to a pointer to a long int argument; that a
19357 following c conversion specifier applies to a wint_t argument; that a
19358 following s conversion specifier applies to a pointer to a wchar_t
19359 argument; or has no effect on a following a, A, e, E, f, F, g, or G conversion
19361 ll (ell-ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19363 long long int or unsigned long long int argument; or that a
19364 following n conversion specifier applies to a pointer to a long long int
19366 j Specifies that a following d, i, o, u, x, or X conversion specifier applies to
19367 <!--page 421 indent 4-->
19369 an intmax_t or uintmax_t argument; or that a following n conversion
19370 specifier applies to a pointer to an intmax_t argument.</pre>
19371 z Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19373 size_t or the corresponding signed integer type argument; or that a
19374 following n conversion specifier applies to a pointer to a signed integer type
19375 corresponding to size_t argument.</pre>
19376 t Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
19378 ptrdiff_t or the corresponding unsigned integer type argument; or that a
19379 following n conversion specifier applies to a pointer to a ptrdiff_t
19381 L Specifies that a following a, A, e, E, f, F, g, or G conversion specifier
19383 applies to a long double argument.</pre>
19384 If a length modifier appears with any conversion specifier other than as specified above,
19385 the behavior is undefined.
19387 The conversion specifiers and their meanings are:
19388 d,i The int argument is converted to signed decimal in the style [-]dddd. The
19390 precision specifies the minimum number of digits to appear; if the value
19391 being converted can be represented in fewer digits, it is expanded with
19392 leading zeros. The default precision is 1. The result of converting a zero
19393 value with a precision of zero is no wide characters.</pre>
19394 o,u,x,X The unsigned int argument is converted to unsigned octal (o), unsigned
19396 decimal (u), or unsigned hexadecimal notation (x or X) in the style dddd; the
19397 letters abcdef are used for x conversion and the letters ABCDEF for X
19398 conversion. The precision specifies the minimum number of digits to appear;
19399 if the value being converted can be represented in fewer digits, it is expanded
19400 with leading zeros. The default precision is 1. The result of converting a
19401 zero value with a precision of zero is no wide characters.</pre>
19402 f,F A double argument representing a floating-point number is converted to
19403 <!--page 422 indent 0-->
19405 decimal notation in the style [-]ddd.ddd, where the number of digits after
19406 the decimal-point wide character is equal to the precision specification. If the
19407 precision is missing, it is taken as 6; if the precision is zero and the # flag is
19408 not specified, no decimal-point wide character appears. If a decimal-point
19409 wide character appears, at least one digit appears before it. The value is
19410 rounded to the appropriate number of digits.
19411 A double argument representing an infinity is converted in one of the styles
19412 [-]inf or [-]infinity -- which style is implementation-defined. A
19413 double argument representing a NaN is converted in one of the styles
19414 [-]nan or [-]nan(n-wchar-sequence) -- which style, and the meaning of
19415 any n-wchar-sequence, is implementation-defined. The F conversion
19416 specifier produces INF, INFINITY, or NAN instead of inf, infinity, or
19417 nan, respectively.<sup><a href="#note319"><b>319)</b></a></sup></pre>
19418 e,E A double argument representing a floating-point number is converted in the
19420 style [-]d.ddd e(+-)dd, where there is one digit (which is nonzero if the
19421 argument is nonzero) before the decimal-point wide character and the number
19422 of digits after it is equal to the precision; if the precision is missing, it is taken
19423 as 6; if the precision is zero and the # flag is not specified, no decimal-point
19424 wide character appears. The value is rounded to the appropriate number of
19425 digits. The E conversion specifier produces a number with E instead of e
19426 introducing the exponent. The exponent always contains at least two digits,
19427 and only as many more digits as necessary to represent the exponent. If the
19428 value is zero, the exponent is zero.
19429 A double argument representing an infinity or NaN is converted in the style
19430 of an f or F conversion specifier.</pre>
19431 g,G A double argument representing a floating-point number is converted in
19433 style f or e (or in style F or E in the case of a G conversion specifier),
19434 depending on the value converted and the precision. Let P equal the
19435 precision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero.
19436 Then, if a conversion with style E would have an exponent of X:
19437 -- if P > X >= -4, the conversion is with style f (or F) and precision
19439 -- otherwise, the conversion is with style e (or E) and precision P - 1.
19440 Finally, unless the # flag is used, any trailing zeros are removed from the
19441 fractional portion of the result and the decimal-point wide character is
19442 removed if there is no fractional portion remaining.
19443 A double argument representing an infinity or NaN is converted in the style
19444 of an f or F conversion specifier.</pre>
19445 a,A A double argument representing a floating-point number is converted in the
19447 style [-]0xh.hhhh p(+-)d, where there is one hexadecimal digit (which is
19448 nonzero if the argument is a normalized floating-point number and is
19449 otherwise unspecified) before the decimal-point wide character<sup><a href="#note320"><b>320)</b></a></sup> and the
19450 number of hexadecimal digits after it is equal to the precision; if the precision
19451 is missing and FLT_RADIX is a power of 2, then the precision is sufficient</pre>
19454 <!--page 423 indent 0-->
19456 for an exact representation of the value; if the precision is missing and
19457 FLT_RADIX is not a power of 2, then the precision is sufficient to
19458 distinguish<sup><a href="#note321"><b>321)</b></a></sup> values of type double, except that trailing zeros may be
19459 omitted; if the precision is zero and the # flag is not specified, no decimal-
19460 point wide character appears. The letters abcdef are used for a conversion
19461 and the letters ABCDEF for A conversion. The A conversion specifier
19462 produces a number with X and P instead of x and p. The exponent always
19463 contains at least one digit, and only as many more digits as necessary to
19464 represent the decimal exponent of 2. If the value is zero, the exponent is
19466 A double argument representing an infinity or NaN is converted in the style
19467 of an f or F conversion specifier.</pre>
19468 c If no l length modifier is present, the int argument is converted to a wide
19470 character as if by calling btowc and the resulting wide character is written.
19471 If an l length modifier is present, the wint_t argument is converted to
19472 wchar_t and written.</pre>
19473 s If no l length modifier is present, the argument shall be a pointer to the initial
19475 element of a character array containing a multibyte character sequence
19476 beginning in the initial shift state. Characters from the array are converted as
19477 if by repeated calls to the mbrtowc function, with the conversion state
19478 described by an mbstate_t object initialized to zero before the first
19479 multibyte character is converted, and written up to (but not including) the
19480 terminating null wide character. If the precision is specified, no more than
19481 that many wide characters are written. If the precision is not specified or is
19482 greater than the size of the converted array, the converted array shall contain a
19483 null wide character.
19484 If an l length modifier is present, the argument shall be a pointer to the initial
19485 element of an array of wchar_t type. Wide characters from the array are
19486 written up to (but not including) a terminating null wide character. If the
19487 precision is specified, no more than that many wide characters are written. If
19488 the precision is not specified or is greater than the size of the array, the array
19489 shall contain a null wide character.</pre>
19490 p The argument shall be a pointer to void. The value of the pointer is
19492 converted to a sequence of printing wide characters, in an implementation-</pre>
19494 <!--page 424 indent 5-->
19496 defined manner.</pre>
19497 n The argument shall be a pointer to signed integer into which is written the
19499 number of wide characters written to the output stream so far by this call to
19500 fwprintf. No argument is converted, but one is consumed. If the
19501 conversion specification includes any flags, a field width, or a precision, the
19502 behavior is undefined.</pre>
19503 % A % wide character is written. No argument is converted. The complete
19506 conversion specification shall be %%.</pre>
19507 If a conversion specification is invalid, the behavior is undefined.<sup><a href="#note322"><b>322)</b></a></sup> If any argument is
19508 not the correct type for the corresponding conversion specification, the behavior is
19511 In no case does a nonexistent or small field width cause truncation of a field; if the result
19512 of a conversion is wider than the field width, the field is expanded to contain the
19515 For a and A conversions, if FLT_RADIX is a power of 2, the value is correctly rounded
19516 to a hexadecimal floating number with the given precision.
19517 Recommended practice
19519 For a and A conversions, if FLT_RADIX is not a power of 2 and the result is not exactly
19520 representable in the given precision, the result should be one of the two adjacent numbers
19521 in hexadecimal floating style with the given precision, with the extra stipulation that the
19522 error should have a correct sign for the current rounding direction.
19524 For e, E, f, F, g, and G conversions, if the number of significant decimal digits is at most
19525 DECIMAL_DIG, then the result should be correctly rounded.<sup><a href="#note323"><b>323)</b></a></sup> If the number of
19526 significant decimal digits is more than DECIMAL_DIG but the source value is exactly
19527 representable with DECIMAL_DIG digits, then the result should be an exact
19528 representation with trailing zeros. Otherwise, the source value is bounded by two
19529 adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value
19530 of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
19531 the error should have a correct sign for the current rounding direction.
19534 The fwprintf function returns the number of wide characters transmitted, or a negative
19535 value if an output or encoding error occurred.
19537 <!--page 425 indent 5-->
19538 Environmental limits
19540 The number of wide characters that can be produced by any single conversion shall be at
19543 EXAMPLE To print a date and time in the form ''Sunday, July 3, 10:02'' followed by pi to five decimal
19546 #include <math.h>
19547 #include <stdio.h>
19548 #include <wchar.h>
19550 wchar_t *weekday, *month; // pointers to wide strings
19551 int day, hour, min;
19552 fwprintf(stdout, L"%ls, %ls %d, %.2d:%.2d\n",
19553 weekday, month, day, hour, min);
19554 fwprintf(stdout, L"pi = %.5f\n", 4 * atan(1.0));</pre>
19556 Forward references: the btowc function (<a href="#7.28.6.1.1">7.28.6.1.1</a>), the mbrtowc function
19557 (<a href="#7.28.6.3.2">7.28.6.3.2</a>).
19560 <p><a name="note317">317)</a> Note that 0 is taken as a flag, not as the beginning of a field width.
19562 <p><a name="note318">318)</a> The results of all floating conversions of a negative zero, and of negative values that round to zero,
19563 include a minus sign.
19565 <p><a name="note319">319)</a> When applied to infinite and NaN values, the -, +, and space flag wide characters have their usual
19566 meaning; the # and 0 flag wide characters have no effect.
19568 <p><a name="note320">320)</a> Binary implementations can choose the hexadecimal digit to the left of the decimal-point wide
19569 character so that subsequent digits align to nibble (4-bit) boundaries.
19571 <p><a name="note321">321)</a> The precision p is sufficient to distinguish values of the source type if 16 p-1 > b n where b is
19572 FLT_RADIX and n is the number of base-b digits in the significand of the source type. A smaller p
19573 might suffice depending on the implementation's scheme for determining the digit to the left of the
19574 decimal-point wide character.
19576 <p><a name="note322">322)</a> See ''future library directions'' (<a href="#7.30.12">7.30.12</a>).
19578 <p><a name="note323">323)</a> For binary-to-decimal conversion, the result format's values are the numbers representable with the
19579 given format specifier. The number of significant digits is determined by the format specifier, and in
19580 the case of fixed-point conversion by the source value as well.
19583 <a name="7.28.2.2" href="#7.28.2.2"><h5>7.28.2.2 The fwscanf function</h5></a>
19587 #include <stdio.h>
19588 #include <wchar.h>
19589 int fwscanf(FILE * restrict stream,
19590 const wchar_t * restrict format, ...);</pre>
19591 <h6>Description</h6>
19593 The fwscanf function reads input from the stream pointed to by stream, under
19594 control of the wide string pointed to by format that specifies the admissible input
19595 sequences and how they are to be converted for assignment, using subsequent arguments
19596 as pointers to the objects to receive the converted input. If there are insufficient
19597 arguments for the format, the behavior is undefined. If the format is exhausted while
19598 arguments remain, the excess arguments are evaluated (as always) but are otherwise
19601 The format is composed of zero or more directives: one or more white-space wide
19602 characters, an ordinary wide character (neither % nor a white-space wide character), or a
19603 conversion specification. Each conversion specification is introduced by the wide
19604 character %. After the %, the following appear in sequence:
19606 <li> An optional assignment-suppressing wide character *.
19607 <li> An optional decimal integer greater than zero that specifies the maximum field width
19608 (in wide characters).
19609 <!--page 426 indent 5-->
19610 <li> An optional length modifier that specifies the size of the receiving object.
19611 <li> A conversion specifier wide character that specifies the type of conversion to be
19615 The fwscanf function executes each directive of the format in turn. When all directives
19616 have been executed, or if a directive fails (as detailed below), the function returns.
19617 Failures are described as input failures (due to the occurrence of an encoding error or the
19618 unavailability of input characters), or matching failures (due to inappropriate input).
19620 A directive composed of white-space wide character(s) is executed by reading input up to
19621 the first non-white-space wide character (which remains unread), or until no more wide
19622 characters can be read.
19624 A directive that is an ordinary wide character is executed by reading the next wide
19625 character of the stream. If that wide character differs from the directive, the directive
19626 fails and the differing and subsequent wide characters remain unread. Similarly, if end-
19627 of-file, an encoding error, or a read error prevents a wide character from being read, the
19630 A directive that is a conversion specification defines a set of matching input sequences, as
19631 described below for each specifier. A conversion specification is executed in the
19634 Input white-space wide characters (as specified by the iswspace function) are skipped,
19635 unless the specification includes a [, c, or n specifier.<sup><a href="#note324"><b>324)</b></a></sup>
19637 An input item is read from the stream, unless the specification includes an n specifier. An
19638 input item is defined as the longest sequence of input wide characters which does not
19639 exceed any specified field width and which is, or is a prefix of, a matching input
19640 sequence.<sup><a href="#note325"><b>325)</b></a></sup> The first wide character, if any, after the input item remains unread. If the
19641 length of the input item is zero, the execution of the directive fails; this condition is a
19642 matching failure unless end-of-file, an encoding error, or a read error prevented input
19643 from the stream, in which case it is an input failure.
19645 Except in the case of a % specifier, the input item (or, in the case of a %n directive, the
19646 count of input wide characters) is converted to a type appropriate to the conversion
19647 specifier. If the input item is not a matching sequence, the execution of the directive fails:
19648 this condition is a matching failure. Unless assignment suppression was indicated by a *,
19649 the result of the conversion is placed in the object pointed to by the first argument
19650 following the format argument that has not already received a conversion result. If this
19653 <!--page 427 indent 5-->
19654 object does not have an appropriate type, or if the result of the conversion cannot be
19655 represented in the object, the behavior is undefined.
19657 The length modifiers and their meanings are:
19658 hh Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19660 to an argument with type pointer to signed char or unsigned char.</pre>
19661 h Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19663 to an argument with type pointer to short int or unsigned short
19665 l (ell) Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19667 to an argument with type pointer to long int or unsigned long
19668 int; that a following a, A, e, E, f, F, g, or G conversion specifier applies to
19669 an argument with type pointer to double; or that a following c, s, or [
19670 conversion specifier applies to an argument with type pointer to wchar_t.</pre>
19671 ll (ell-ell) Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19673 to an argument with type pointer to long long int or unsigned
19674 long long int.</pre>
19675 j Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19677 to an argument with type pointer to intmax_t or uintmax_t.</pre>
19678 z Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19680 to an argument with type pointer to size_t or the corresponding signed
19681 integer type.</pre>
19682 t Specifies that a following d, i, o, u, x, X, or n conversion specifier applies
19684 to an argument with type pointer to ptrdiff_t or the corresponding
19685 unsigned integer type.</pre>
19686 L Specifies that a following a, A, e, E, f, F, g, or G conversion specifier
19688 applies to an argument with type pointer to long double.</pre>
19689 If a length modifier appears with any conversion specifier other than as specified above,
19690 the behavior is undefined.
19692 The conversion specifiers and their meanings are:
19693 d Matches an optionally signed decimal integer, whose format is the same as
19695 expected for the subject sequence of the wcstol function with the value 10
19696 for the base argument. The corresponding argument shall be a pointer to
19697 signed integer.</pre>
19698 i Matches an optionally signed integer, whose format is the same as expected
19699 <!--page 428 indent 0-->
19701 for the subject sequence of the wcstol function with the value 0 for the
19702 base argument. The corresponding argument shall be a pointer to signed
19704 o Matches an optionally signed octal integer, whose format is the same as
19706 expected for the subject sequence of the wcstoul function with the value 8
19707 for the base argument. The corresponding argument shall be a pointer to
19708 unsigned integer.</pre>
19709 u Matches an optionally signed decimal integer, whose format is the same as
19711 expected for the subject sequence of the wcstoul function with the value 10
19712 for the base argument. The corresponding argument shall be a pointer to
19713 unsigned integer.</pre>
19714 x Matches an optionally signed hexadecimal integer, whose format is the same
19716 as expected for the subject sequence of the wcstoul function with the value
19717 16 for the base argument. The corresponding argument shall be a pointer to
19718 unsigned integer.</pre>
19719 a,e,f,g Matches an optionally signed floating-point number, infinity, or NaN, whose
19721 format is the same as expected for the subject sequence of the wcstod
19722 function. The corresponding argument shall be a pointer to floating.</pre>
19723 c Matches a sequence of wide characters of exactly the number specified by the
19725 field width (1 if no field width is present in the directive).
19726 If no l length modifier is present, characters from the input field are
19727 converted as if by repeated calls to the wcrtomb function, with the
19728 conversion state described by an mbstate_t object initialized to zero
19729 before the first wide character is converted. The corresponding argument
19730 shall be a pointer to the initial element of a character array large enough to
19731 accept the sequence. No null character is added.
19732 If an l length modifier is present, the corresponding argument shall be a
19733 pointer to the initial element of an array of wchar_t large enough to accept
19734 the sequence. No null wide character is added.</pre>
19735 s Matches a sequence of non-white-space wide characters.
19736 <!--page 429 indent 0-->
19738 If no l length modifier is present, characters from the input field are
19739 converted as if by repeated calls to the wcrtomb function, with the
19740 conversion state described by an mbstate_t object initialized to zero
19741 before the first wide character is converted. The corresponding argument
19742 shall be a pointer to the initial element of a character array large enough to
19743 accept the sequence and a terminating null character, which will be added
19745 If an l length modifier is present, the corresponding argument shall be a
19746 pointer to the initial element of an array of wchar_t large enough to accept
19747 the sequence and the terminating null wide character, which will be added
19748 automatically.</pre>
19749 [ Matches a nonempty sequence of wide characters from a set of expected
19751 characters (the scanset).
19752 If no l length modifier is present, characters from the input field are
19753 converted as if by repeated calls to the wcrtomb function, with the
19754 conversion state described by an mbstate_t object initialized to zero
19755 before the first wide character is converted. The corresponding argument
19756 shall be a pointer to the initial element of a character array large enough to
19757 accept the sequence and a terminating null character, which will be added
19759 If an l length modifier is present, the corresponding argument shall be a
19760 pointer to the initial element of an array of wchar_t large enough to accept
19761 the sequence and the terminating null wide character, which will be added
19763 The conversion specifier includes all subsequent wide characters in the
19764 format string, up to and including the matching right bracket (]). The wide
19765 characters between the brackets (the scanlist) compose the scanset, unless the
19766 wide character after the left bracket is a circumflex (^), in which case the
19767 scanset contains all wide characters that do not appear in the scanlist between
19768 the circumflex and the right bracket. If the conversion specifier begins with
19769 [] or [^], the right bracket wide character is in the scanlist and the next
19770 following right bracket wide character is the matching right bracket that ends
19771 the specification; otherwise the first following right bracket wide character is
19772 the one that ends the specification. If a - wide character is in the scanlist and
19773 is not the first, nor the second where the first wide character is a ^, nor the
19774 last character, the behavior is implementation-defined.</pre>
19775 p Matches an implementation-defined set of sequences, which should be the
19777 same as the set of sequences that may be produced by the %p conversion of
19778 the fwprintf function. The corresponding argument shall be a pointer to a
19779 pointer to void. The input item is converted to a pointer value in an
19780 implementation-defined manner. If the input item is a value converted earlier
19781 during the same program execution, the pointer that results shall compare
19782 equal to that value; otherwise the behavior of the %p conversion is undefined.</pre>
19783 n No input is consumed. The corresponding argument shall be a pointer to
19784 <!--page 430 indent 5-->
19786 signed integer into which is to be written the number of wide characters read
19787 from the input stream so far by this call to the fwscanf function. Execution
19788 of a %n directive does not increment the assignment count returned at the
19789 completion of execution of the fwscanf function. No argument is
19790 converted, but one is consumed. If the conversion specification includes an
19791 assignment-suppressing wide character or a field width, the behavior is
19793 % Matches a single % wide character; no conversion or assignment occurs. The
19796 complete conversion specification shall be %%.</pre>
19797 If a conversion specification is invalid, the behavior is undefined.<sup><a href="#note326"><b>326)</b></a></sup>
19799 The conversion specifiers A, E, F, G, and X are also valid and behave the same as,
19800 respectively, a, e, f, g, and x.
19802 Trailing white space (including new-line wide characters) is left unread unless matched
19803 by a directive. The success of literal matches and suppressed assignments is not directly
19804 determinable other than via the %n directive.
19807 The fwscanf function returns the value of the macro EOF if an input failure occurs
19808 before the first conversion (if any) has completed. Otherwise, the function returns the
19809 number of input items assigned, which can be fewer than provided for, or even zero, in
19810 the event of an early matching failure.
19812 EXAMPLE 1 The call:
19814 #include <stdio.h>
19815 #include <wchar.h>
19817 int n, i; float x; wchar_t name[50];
19818 n = fwscanf(stdin, L"%d%f%ls", &i, &x, name);</pre>
19819 with the input line:
19821 25 54.32E-1 thompson</pre>
19822 will assign to n the value 3, to i the value 25, to x the value 5.432, and to name the sequence
19826 EXAMPLE 2 The call:
19828 #include <stdio.h>
19829 #include <wchar.h>
19831 int i; float x; double y;
19832 fwscanf(stdin, L"%2d%f%*d %lf", &i, &x, &y);</pre>
19835 56789 0123 56a72</pre>
19836 will assign to i the value 56 and to x the value 789.0, will skip past 0123, and will assign to y the value
19837 56.0. The next wide character read from the input stream will be a.
19840 <!--page 431 indent 4-->
19841 Forward references: the wcstod, wcstof, and wcstold functions (<a href="#7.28.4.1.1">7.28.4.1.1</a>), the
19842 wcstol, wcstoll, wcstoul, and wcstoull functions (<a href="#7.28.4.1.2">7.28.4.1.2</a>), the wcrtomb
19843 function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
19846 <p><a name="note324">324)</a> These white-space wide characters are not counted against a specified field width.
19848 <p><a name="note325">325)</a> fwscanf pushes back at most one input wide character onto the input stream. Therefore, some
19849 sequences that are acceptable to wcstod, wcstol, etc., are unacceptable to fwscanf.
19851 <p><a name="note326">326)</a> See ''future library directions'' (<a href="#7.30.12">7.30.12</a>).
19854 <a name="7.28.2.3" href="#7.28.2.3"><h5>7.28.2.3 The swprintf function</h5></a>
19858 #include <wchar.h>
19859 int swprintf(wchar_t * restrict s,
19861 const wchar_t * restrict format, ...);</pre>
19862 <h6>Description</h6>
19864 The swprintf function is equivalent to fwprintf, except that the argument s
19865 specifies an array of wide characters into which the generated output is to be written,
19866 rather than written to a stream. No more than n wide characters are written, including a
19867 terminating null wide character, which is always added (unless n is zero).
19870 The swprintf function returns the number of wide characters written in the array, not
19871 counting the terminating null wide character, or a negative value if an encoding error
19872 occurred or if n or more wide characters were requested to be written.
19874 <a name="7.28.2.4" href="#7.28.2.4"><h5>7.28.2.4 The swscanf function</h5></a>
19878 #include <wchar.h>
19879 int swscanf(const wchar_t * restrict s,
19880 const wchar_t * restrict format, ...);</pre>
19881 <h6>Description</h6>
19883 The swscanf function is equivalent to fwscanf, except that the argument s specifies a
19884 wide string from which the input is to be obtained, rather than from a stream. Reaching
19885 the end of the wide string is equivalent to encountering end-of-file for the fwscanf
19889 The swscanf function returns the value of the macro EOF if an input failure occurs
19890 before the first conversion (if any) has completed. Otherwise, the swscanf function
19891 returns the number of input items assigned, which can be fewer than provided for, or even
19892 zero, in the event of an early matching failure.
19893 <!--page 432 indent 4-->
19895 <a name="7.28.2.5" href="#7.28.2.5"><h5>7.28.2.5 The vfwprintf function</h5></a>
19899 #include <stdarg.h>
19900 #include <stdio.h>
19901 #include <wchar.h>
19902 int vfwprintf(FILE * restrict stream,
19903 const wchar_t * restrict format,
19904 va_list arg);</pre>
19905 <h6>Description</h6>
19907 The vfwprintf function is equivalent to fwprintf, with the variable argument list
19908 replaced by arg, which shall have been initialized by the va_start macro (and
19909 possibly subsequent va_arg calls). The vfwprintf function does not invoke the
19910 va_end macro.<sup><a href="#note327"><b>327)</b></a></sup>
19913 The vfwprintf function returns the number of wide characters transmitted, or a
19914 negative value if an output or encoding error occurred.
19916 EXAMPLE The following shows the use of the vfwprintf function in a general error-reporting
19919 #include <stdarg.h>
19920 #include <stdio.h>
19921 #include <wchar.h>
19922 void error(char *function_name, wchar_t *format, ...)
19925 va_start(args, format);
19926 // print out name of function causing error
19927 fwprintf(stderr, L"ERROR in %s: ", function_name);
19928 // print out remainder of message
19929 vfwprintf(stderr, format, args);
19936 <!--page 433 indent 4-->
19939 <p><a name="note327">327)</a> As the functions vfwprintf, vswprintf, vfwscanf, vwprintf, vwscanf, and vswscanf
19940 invoke the va_arg macro, the value of arg after the return is indeterminate.
19943 <a name="7.28.2.6" href="#7.28.2.6"><h5>7.28.2.6 The vfwscanf function</h5></a>
19947 #include <stdarg.h>
19948 #include <stdio.h>
19949 #include <wchar.h>
19950 int vfwscanf(FILE * restrict stream,
19951 const wchar_t * restrict format,
19952 va_list arg);</pre>
19953 <h6>Description</h6>
19955 The vfwscanf function is equivalent to fwscanf, with the variable argument list
19956 replaced by arg, which shall have been initialized by the va_start macro (and
19957 possibly subsequent va_arg calls). The vfwscanf function does not invoke the
19961 The vfwscanf function returns the value of the macro EOF if an input failure occurs
19962 before the first conversion (if any) has completed. Otherwise, the vfwscanf function
19963 returns the number of input items assigned, which can be fewer than provided for, or even
19964 zero, in the event of an early matching failure.
19966 <a name="7.28.2.7" href="#7.28.2.7"><h5>7.28.2.7 The vswprintf function</h5></a>
19970 #include <stdarg.h>
19971 #include <wchar.h>
19972 int vswprintf(wchar_t * restrict s,
19974 const wchar_t * restrict format,
19975 va_list arg);</pre>
19976 <h6>Description</h6>
19978 The vswprintf function is equivalent to swprintf, with the variable argument list
19979 replaced by arg, which shall have been initialized by the va_start macro (and
19980 possibly subsequent va_arg calls). The vswprintf function does not invoke the
19984 The vswprintf function returns the number of wide characters written in the array, not
19985 counting the terminating null wide character, or a negative value if an encoding error
19986 occurred or if n or more wide characters were requested to be generated.
19987 <!--page 434 indent 4-->
19989 <a name="7.28.2.8" href="#7.28.2.8"><h5>7.28.2.8 The vswscanf function</h5></a>
19993 #include <stdarg.h>
19994 #include <wchar.h>
19995 int vswscanf(const wchar_t * restrict s,
19996 const wchar_t * restrict format,
19997 va_list arg);</pre>
19998 <h6>Description</h6>
20000 The vswscanf function is equivalent to swscanf, with the variable argument list
20001 replaced by arg, which shall have been initialized by the va_start macro (and
20002 possibly subsequent va_arg calls). The vswscanf function does not invoke the
20006 The vswscanf function returns the value of the macro EOF if an input failure occurs
20007 before the first conversion (if any) has completed. Otherwise, the vswscanf function
20008 returns the number of input items assigned, which can be fewer than provided for, or even
20009 zero, in the event of an early matching failure.
20011 <a name="7.28.2.9" href="#7.28.2.9"><h5>7.28.2.9 The vwprintf function</h5></a>
20015 #include <stdarg.h>
20016 #include <wchar.h>
20017 int vwprintf(const wchar_t * restrict format,
20018 va_list arg);</pre>
20019 <h6>Description</h6>
20021 The vwprintf function is equivalent to wprintf, with the variable argument list
20022 replaced by arg, which shall have been initialized by the va_start macro (and
20023 possibly subsequent va_arg calls). The vwprintf function does not invoke the
20027 The vwprintf function returns the number of wide characters transmitted, or a negative
20028 value if an output or encoding error occurred.
20029 <!--page 435 indent 4-->
20031 <a name="7.28.2.10" href="#7.28.2.10"><h5>7.28.2.10 The vwscanf function</h5></a>
20035 #include <stdarg.h>
20036 #include <wchar.h>
20037 int vwscanf(const wchar_t * restrict format,
20038 va_list arg);</pre>
20039 <h6>Description</h6>
20041 The vwscanf function is equivalent to wscanf, with the variable argument list
20042 replaced by arg, which shall have been initialized by the va_start macro (and
20043 possibly subsequent va_arg calls). The vwscanf function does not invoke the
20047 The vwscanf function returns the value of the macro EOF if an input failure occurs
20048 before the first conversion (if any) has completed. Otherwise, the vwscanf function
20049 returns the number of input items assigned, which can be fewer than provided for, or even
20050 zero, in the event of an early matching failure.
20052 <a name="7.28.2.11" href="#7.28.2.11"><h5>7.28.2.11 The wprintf function</h5></a>
20056 #include <wchar.h>
20057 int wprintf(const wchar_t * restrict format, ...);</pre>
20058 <h6>Description</h6>
20060 The wprintf function is equivalent to fwprintf with the argument stdout
20061 interposed before the arguments to wprintf.
20064 The wprintf function returns the number of wide characters transmitted, or a negative
20065 value if an output or encoding error occurred.
20067 <a name="7.28.2.12" href="#7.28.2.12"><h5>7.28.2.12 The wscanf function</h5></a>
20071 #include <wchar.h>
20072 int wscanf(const wchar_t * restrict format, ...);</pre>
20073 <h6>Description</h6>
20075 The wscanf function is equivalent to fwscanf with the argument stdin interposed
20076 before the arguments to wscanf.
20077 <!--page 436 indent 4-->
20080 The wscanf function returns the value of the macro EOF if an input failure occurs
20081 before the first conversion (if any) has completed. Otherwise, the wscanf function
20082 returns the number of input items assigned, which can be fewer than provided for, or even
20083 zero, in the event of an early matching failure.
20085 <a name="7.28.3" href="#7.28.3"><h4>7.28.3 Wide character input/output functions</h4></a>
20087 <a name="7.28.3.1" href="#7.28.3.1"><h5>7.28.3.1 The fgetwc function</h5></a>
20091 #include <stdio.h>
20092 #include <wchar.h>
20093 wint_t fgetwc(FILE *stream);</pre>
20094 <h6>Description</h6>
20096 If the end-of-file indicator for the input stream pointed to by stream is not set and a
20097 next wide character is present, the fgetwc function obtains that wide character as a
20098 wchar_t converted to a wint_t and advances the associated file position indicator for
20099 the stream (if defined).
20102 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
20103 of-file indicator for the stream is set and the fgetwc function returns WEOF. Otherwise,
20104 the fgetwc function returns the next wide character from the input stream pointed to by
20105 stream. If a read error occurs, the error indicator for the stream is set and the fgetwc
20106 function returns WEOF. If an encoding error occurs (including too few bytes), the value of
20107 the macro EILSEQ is stored in errno and the fgetwc function returns WEOF.<sup><a href="#note328"><b>328)</b></a></sup>
20110 <p><a name="note328">328)</a> An end-of-file and a read error can be distinguished by use of the feof and ferror functions.
20111 Also, errno will be set to EILSEQ by input/output functions only if an encoding error occurs.
20114 <a name="7.28.3.2" href="#7.28.3.2"><h5>7.28.3.2 The fgetws function</h5></a>
20118 #include <stdio.h>
20119 #include <wchar.h>
20120 wchar_t *fgetws(wchar_t * restrict s,
20121 int n, FILE * restrict stream);</pre>
20122 <h6>Description</h6>
20124 The fgetws function reads at most one less than the number of wide characters
20125 specified by n from the stream pointed to by stream into the array pointed to by s. No
20128 <!--page 437 indent 4-->
20129 additional wide characters are read after a new-line wide character (which is retained) or
20130 after end-of-file. A null wide character is written immediately after the last wide
20131 character read into the array.
20134 The fgetws function returns s if successful. If end-of-file is encountered and no
20135 characters have been read into the array, the contents of the array remain unchanged and a
20136 null pointer is returned. If a read or encoding error occurs during the operation, the array
20137 contents are indeterminate and a null pointer is returned.
20139 <a name="7.28.3.3" href="#7.28.3.3"><h5>7.28.3.3 The fputwc function</h5></a>
20143 #include <stdio.h>
20144 #include <wchar.h>
20145 wint_t fputwc(wchar_t c, FILE *stream);</pre>
20146 <h6>Description</h6>
20148 The fputwc function writes the wide character specified by c to the output stream
20149 pointed to by stream, at the position indicated by the associated file position indicator
20150 for the stream (if defined), and advances the indicator appropriately. If the file cannot
20151 support positioning requests, or if the stream was opened with append mode, the
20152 character is appended to the output stream.
20155 The fputwc function returns the wide character written. If a write error occurs, the
20156 error indicator for the stream is set and fputwc returns WEOF. If an encoding error
20157 occurs, the value of the macro EILSEQ is stored in errno and fputwc returns WEOF.
20159 <a name="7.28.3.4" href="#7.28.3.4"><h5>7.28.3.4 The fputws function</h5></a>
20163 #include <stdio.h>
20164 #include <wchar.h>
20165 int fputws(const wchar_t * restrict s,
20166 FILE * restrict stream);</pre>
20167 <h6>Description</h6>
20169 The fputws function writes the wide string pointed to by s to the stream pointed to by
20170 stream. The terminating null wide character is not written.
20173 The fputws function returns EOF if a write or encoding error occurs; otherwise, it
20174 returns a nonnegative value.
20175 <!--page 438 indent 4-->
20177 <a name="7.28.3.5" href="#7.28.3.5"><h5>7.28.3.5 The fwide function</h5></a>
20181 #include <stdio.h>
20182 #include <wchar.h>
20183 int fwide(FILE *stream, int mode);</pre>
20184 <h6>Description</h6>
20186 The fwide function determines the orientation of the stream pointed to by stream. If
20187 mode is greater than zero, the function first attempts to make the stream wide oriented. If
20188 mode is less than zero, the function first attempts to make the stream byte oriented.<sup><a href="#note329"><b>329)</b></a></sup>
20189 Otherwise, mode is zero and the function does not alter the orientation of the stream.
20192 The fwide function returns a value greater than zero if, after the call, the stream has
20193 wide orientation, a value less than zero if the stream has byte orientation, or zero if the
20194 stream has no orientation.
20197 <p><a name="note329">329)</a> If the orientation of the stream has already been determined, fwide does not change it.
20200 <a name="7.28.3.6" href="#7.28.3.6"><h5>7.28.3.6 The getwc function</h5></a>
20204 #include <stdio.h>
20205 #include <wchar.h>
20206 wint_t getwc(FILE *stream);</pre>
20207 <h6>Description</h6>
20209 The getwc function is equivalent to fgetwc, except that if it is implemented as a
20210 macro, it may evaluate stream more than once, so the argument should never be an
20211 expression with side effects.
20214 The getwc function returns the next wide character from the input stream pointed to by
20217 <a name="7.28.3.7" href="#7.28.3.7"><h5>7.28.3.7 The getwchar function</h5></a>
20221 #include <wchar.h>
20222 wint_t getwchar(void);</pre>
20227 <!--page 439 indent 4-->
20228 <h6>Description</h6>
20230 The getwchar function is equivalent to getwc with the argument stdin.
20233 The getwchar function returns the next wide character from the input stream pointed to
20236 <a name="7.28.3.8" href="#7.28.3.8"><h5>7.28.3.8 The putwc function</h5></a>
20240 #include <stdio.h>
20241 #include <wchar.h>
20242 wint_t putwc(wchar_t c, FILE *stream);</pre>
20243 <h6>Description</h6>
20245 The putwc function is equivalent to fputwc, except that if it is implemented as a
20246 macro, it may evaluate stream more than once, so that argument should never be an
20247 expression with side effects.
20250 The putwc function returns the wide character written, or WEOF.
20252 <a name="7.28.3.9" href="#7.28.3.9"><h5>7.28.3.9 The putwchar function</h5></a>
20256 #include <wchar.h>
20257 wint_t putwchar(wchar_t c);</pre>
20258 <h6>Description</h6>
20260 The putwchar function is equivalent to putwc with the second argument stdout.
20263 The putwchar function returns the character written, or WEOF.
20265 <a name="7.28.3.10" href="#7.28.3.10"><h5>7.28.3.10 The ungetwc function</h5></a>
20269 #include <stdio.h>
20270 #include <wchar.h>
20271 wint_t ungetwc(wint_t c, FILE *stream);</pre>
20272 <h6>Description</h6>
20274 The ungetwc function pushes the wide character specified by c back onto the input
20275 stream pointed to by stream. Pushed-back wide characters will be returned by
20276 subsequent reads on that stream in the reverse order of their pushing. A successful
20277 <!--page 440 indent 4-->
20278 intervening call (with the stream pointed to by stream) to a file positioning function
20279 (fseek, fsetpos, or rewind) discards any pushed-back wide characters for the
20280 stream. The external storage corresponding to the stream is unchanged.
20282 One wide character of pushback is guaranteed, even if the call to the ungetwc function
20283 follows just after a call to a formatted wide character input function fwscanf,
20284 vfwscanf, vwscanf, or wscanf. If the ungetwc function is called too many times
20285 on the same stream without an intervening read or file positioning operation on that
20286 stream, the operation may fail.
20288 If the value of c equals that of the macro WEOF, the operation fails and the input stream is
20291 A successful call to the ungetwc function clears the end-of-file indicator for the stream.
20292 The value of the file position indicator for the stream after reading or discarding all
20293 pushed-back wide characters is the same as it was before the wide characters were pushed
20294 back. For a text or binary stream, the value of its file position indicator after a successful
20295 call to the ungetwc function is unspecified until all pushed-back wide characters are
20299 The ungetwc function returns the wide character pushed back, or WEOF if the operation
20302 <a name="7.28.4" href="#7.28.4"><h4>7.28.4 General wide string utilities</h4></a>
20304 The header <wchar.h> declares a number of functions useful for wide string
20305 manipulation. Various methods are used for determining the lengths of the arrays, but in
20306 all cases a wchar_t * argument points to the initial (lowest addressed) element of the
20307 array. If an array is accessed beyond the end of an object, the behavior is undefined.
20309 Where an argument declared as size_t n determines the length of the array for a
20310 function, n can have the value zero on a call to that function. Unless explicitly stated
20311 otherwise in the description of a particular function in this subclause, pointer arguments
20312 on such a call shall still have valid values, as described in <a href="#7.1.4">7.1.4</a>. On such a call, a
20313 function that locates a wide character finds no occurrence, a function that compares two
20314 wide character sequences returns zero, and a function that copies wide characters copies
20315 zero wide characters.
20316 <!--page 441 indent 4-->
20318 <a name="7.28.4.1" href="#7.28.4.1"><h5>7.28.4.1 Wide string numeric conversion functions</h5></a>
20320 <a name="7.28.4.1.1" href="#7.28.4.1.1"><h5>7.28.4.1.1 The wcstod, wcstof, and wcstold functions</h5></a>
20324 #include <wchar.h>
20325 double wcstod(const wchar_t * restrict nptr,
20326 wchar_t ** restrict endptr);
20327 float wcstof(const wchar_t * restrict nptr,
20328 wchar_t ** restrict endptr);
20329 long double wcstold(const wchar_t * restrict nptr,
20330 wchar_t ** restrict endptr);</pre>
20331 <h6>Description</h6>
20333 The wcstod, wcstof, and wcstold functions convert the initial portion of the wide
20334 string pointed to by nptr to double, float, and long double representation,
20335 respectively. First, they decompose the input string into three parts: an initial, possibly
20336 empty, sequence of white-space wide characters (as specified by the iswspace
20337 function), a subject sequence resembling a floating-point constant or representing an
20338 infinity or NaN; and a final wide string of one or more unrecognized wide characters,
20339 including the terminating null wide character of the input wide string. Then, they attempt
20340 to convert the subject sequence to a floating-point number, and return the result.
20342 The expected form of the subject sequence is an optional plus or minus sign, then one of
20345 <li> a nonempty sequence of decimal digits optionally containing a decimal-point wide
20346 character, then an optional exponent part as defined for the corresponding single-byte
20347 characters in <a href="#6.4.4.2">6.4.4.2</a>;
20348 <li> a 0x or 0X, then a nonempty sequence of hexadecimal digits optionally containing a
20349 decimal-point wide character, then an optional binary exponent part as defined in
20350 <a href="#6.4.4.2">6.4.4.2</a>;
20351 <li> INF or INFINITY, or any other wide string equivalent except for case
20352 <li> NAN or NAN(n-wchar-sequenceopt), or any other wide string equivalent except for
20353 case in the NAN part, where:
20358 n-wchar-sequence digit
20359 n-wchar-sequence nondigit</pre>
20361 The subject sequence is defined as the longest initial subsequence of the input wide
20362 string, starting with the first non-white-space wide character, that is of the expected form.
20363 <!--page 442 indent 4-->
20364 The subject sequence contains no wide characters if the input wide string is not of the
20367 If the subject sequence has the expected form for a floating-point number, the sequence of
20368 wide characters starting with the first digit or the decimal-point wide character
20369 (whichever occurs first) is interpreted as a floating constant according to the rules of
20370 <a href="#6.4.4.2">6.4.4.2</a>, except that the decimal-point wide character is used in place of a period, and that
20371 if neither an exponent part nor a decimal-point wide character appears in a decimal
20372 floating point number, or if a binary exponent part does not appear in a hexadecimal
20373 floating point number, an exponent part of the appropriate type with value zero is
20374 assumed to follow the last digit in the string. If the subject sequence begins with a minus
20375 sign, the sequence is interpreted as negated.<sup><a href="#note330"><b>330)</b></a></sup> A wide character sequence INF or
20376 INFINITY is interpreted as an infinity, if representable in the return type, else like a
20377 floating constant that is too large for the range of the return type. A wide character
20378 sequence NAN or NAN(n-wchar-sequenceopt) is interpreted as a quiet NaN, if supported
20379 in the return type, else like a subject sequence part that does not have the expected form;
20380 the meaning of the n-wchar sequences is implementation-defined.<sup><a href="#note331"><b>331)</b></a></sup> A pointer to the
20381 final wide string is stored in the object pointed to by endptr, provided that endptr is
20382 not a null pointer.
20384 If the subject sequence has the hexadecimal form and FLT_RADIX is a power of 2, the
20385 value resulting from the conversion is correctly rounded.
20387 In other than the "C" locale, additional locale-specific subject sequence forms may be
20390 If the subject sequence is empty or does not have the expected form, no conversion is
20391 performed; the value of nptr is stored in the object pointed to by endptr, provided
20392 that endptr is not a null pointer.
20393 Recommended practice
20395 If the subject sequence has the hexadecimal form, FLT_RADIX is not a power of 2, and
20396 the result is not exactly representable, the result should be one of the two numbers in the
20397 appropriate internal format that are adjacent to the hexadecimal floating source value,
20398 with the extra stipulation that the error should have a correct sign for the current rounding
20403 <!--page 443 indent 5-->
20405 If the subject sequence has the decimal form and at most DECIMAL_DIG (defined in
20406 <float.h>) significant digits, the result should be correctly rounded. If the subject
20407 sequence D has the decimal form and more than DECIMAL_DIG significant digits,
20408 consider the two bounding, adjacent decimal strings L and U, both having
20409 DECIMAL_DIG significant digits, such that the values of L, D, and U satisfy L <= D <= U.
20410 The result should be one of the (equal or adjacent) values that would be obtained by
20411 correctly rounding L and U according to the current rounding direction, with the extra
20412 stipulation that the error with respect to D should have a correct sign for the current
20413 rounding direction.<sup><a href="#note332"><b>332)</b></a></sup>
20416 The functions return the converted value, if any. If no conversion could be performed,
20417 zero is returned. If the correct value overflows and default rounding is in effect (<a href="#7.12.1">7.12.1</a>),
20418 plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the
20419 return type and sign of the value), and the value of the macro ERANGE is stored in
20420 errno. If the result underflows (<a href="#7.12.1">7.12.1</a>), the functions return a value whose magnitude is
20421 no greater than the smallest normalized positive number in the return type; whether
20422 errno acquires the value ERANGE is implementation-defined.
20427 <!--page 444 indent 4-->
20430 <p><a name="note330">330)</a> It is unspecified whether a minus-signed sequence is converted to a negative number directly or by
20431 negating the value resulting from converting the corresponding unsigned sequence (see <a href="#F.5">F.5</a>); the two
20432 methods may yield different results if rounding is toward positive or negative infinity. In either case,
20433 the functions honor the sign of zero if floating-point arithmetic supports signed zeros.
20435 <p><a name="note331">331)</a> An implementation may use the n-wchar sequence to determine extra information to be represented in
20436 the NaN's significand.
20438 <p><a name="note332">332)</a> DECIMAL_DIG, defined in <float.h>, should be sufficiently large that L and U will usually round
20439 to the same internal floating value, but if not will round to adjacent values.
20442 <a name="7.28.4.1.2" href="#7.28.4.1.2"><h5>7.28.4.1.2 The wcstol, wcstoll, wcstoul, and wcstoull functions</h5></a>
20446 #include <wchar.h>
20448 const wchar_t * restrict nptr,
20449 wchar_t ** restrict endptr,
20451 long long int wcstoll(
20452 const wchar_t * restrict nptr,
20453 wchar_t ** restrict endptr,
20455 unsigned long int wcstoul(
20456 const wchar_t * restrict nptr,
20457 wchar_t ** restrict endptr,
20459 unsigned long long int wcstoull(
20460 const wchar_t * restrict nptr,
20461 wchar_t ** restrict endptr,
20463 <h6>Description</h6>
20465 The wcstol, wcstoll, wcstoul, and wcstoull functions convert the initial
20466 portion of the wide string pointed to by nptr to long int, long long int,
20467 unsigned long int, and unsigned long long int representation,
20468 respectively. First, they decompose the input string into three parts: an initial, possibly
20469 empty, sequence of white-space wide characters (as specified by the iswspace
20470 function), a subject sequence resembling an integer represented in some radix determined
20471 by the value of base, and a final wide string of one or more unrecognized wide
20472 characters, including the terminating null wide character of the input wide string. Then,
20473 they attempt to convert the subject sequence to an integer, and return the result.
20475 If the value of base is zero, the expected form of the subject sequence is that of an
20476 integer constant as described for the corresponding single-byte characters in <a href="#6.4.4.1">6.4.4.1</a>,
20477 optionally preceded by a plus or minus sign, but not including an integer suffix. If the
20478 value of base is between 2 and 36 (inclusive), the expected form of the subject sequence
20479 is a sequence of letters and digits representing an integer with the radix specified by
20480 base, optionally preceded by a plus or minus sign, but not including an integer suffix.
20481 The letters from a (or A) through z (or Z) are ascribed the values 10 through 35; only
20482 letters and digits whose ascribed values are less than that of base are permitted. If the
20483 value of base is 16, the wide characters 0x or 0X may optionally precede the sequence
20484 of letters and digits, following the sign if present.
20485 <!--page 445 indent 4-->
20487 The subject sequence is defined as the longest initial subsequence of the input wide
20488 string, starting with the first non-white-space wide character, that is of the expected form.
20489 The subject sequence contains no wide characters if the input wide string is empty or
20490 consists entirely of white space, or if the first non-white-space wide character is other
20491 than a sign or a permissible letter or digit.
20493 If the subject sequence has the expected form and the value of base is zero, the sequence
20494 of wide characters starting with the first digit is interpreted as an integer constant
20495 according to the rules of <a href="#6.4.4.1">6.4.4.1</a>. If the subject sequence has the expected form and the
20496 value of base is between 2 and 36, it is used as the base for conversion, ascribing to each
20497 letter its value as given above. If the subject sequence begins with a minus sign, the value
20498 resulting from the conversion is negated (in the return type). A pointer to the final wide
20499 string is stored in the object pointed to by endptr, provided that endptr is not a null
20502 In other than the "C" locale, additional locale-specific subject sequence forms may be
20505 If the subject sequence is empty or does not have the expected form, no conversion is
20506 performed; the value of nptr is stored in the object pointed to by endptr, provided
20507 that endptr is not a null pointer.
20510 The wcstol, wcstoll, wcstoul, and wcstoull functions return the converted
20511 value, if any. If no conversion could be performed, zero is returned. If the correct value
20512 is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
20513 LLONG_MAX, ULONG_MAX, or ULLONG_MAX is returned (according to the return type
20514 sign of the value, if any), and the value of the macro ERANGE is stored in errno.
20516 <a name="7.28.4.2" href="#7.28.4.2"><h5>7.28.4.2 Wide string copying functions</h5></a>
20518 <a name="7.28.4.2.1" href="#7.28.4.2.1"><h5>7.28.4.2.1 The wcscpy function</h5></a>
20522 #include <wchar.h>
20523 wchar_t *wcscpy(wchar_t * restrict s1,
20524 const wchar_t * restrict s2);</pre>
20525 <h6>Description</h6>
20527 The wcscpy function copies the wide string pointed to by s2 (including the terminating
20528 null wide character) into the array pointed to by s1.
20531 The wcscpy function returns the value of s1.
20532 <!--page 446 indent 4-->
20534 <a name="7.28.4.2.2" href="#7.28.4.2.2"><h5>7.28.4.2.2 The wcsncpy function</h5></a>
20538 #include <wchar.h>
20539 wchar_t *wcsncpy(wchar_t * restrict s1,
20540 const wchar_t * restrict s2,
20542 <h6>Description</h6>
20544 The wcsncpy function copies not more than n wide characters (those that follow a null
20545 wide character are not copied) from the array pointed to by s2 to the array pointed to by
20546 s1.<sup><a href="#note333"><b>333)</b></a></sup>
20548 If the array pointed to by s2 is a wide string that is shorter than n wide characters, null
20549 wide characters are appended to the copy in the array pointed to by s1, until n wide
20550 characters in all have been written.
20553 The wcsncpy function returns the value of s1.
20556 <p><a name="note333">333)</a> Thus, if there is no null wide character in the first n wide characters of the array pointed to by s2, the
20557 result will not be null-terminated.
20560 <a name="7.28.4.2.3" href="#7.28.4.2.3"><h5>7.28.4.2.3 The wmemcpy function</h5></a>
20564 #include <wchar.h>
20565 wchar_t *wmemcpy(wchar_t * restrict s1,
20566 const wchar_t * restrict s2,
20568 <h6>Description</h6>
20570 The wmemcpy function copies n wide characters from the object pointed to by s2 to the
20571 object pointed to by s1.
20574 The wmemcpy function returns the value of s1.
20579 <!--page 447 indent 4-->
20581 <a name="7.28.4.2.4" href="#7.28.4.2.4"><h5>7.28.4.2.4 The wmemmove function</h5></a>
20585 #include <wchar.h>
20586 wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2,
20588 <h6>Description</h6>
20590 The wmemmove function copies n wide characters from the object pointed to by s2 to
20591 the object pointed to by s1. Copying takes place as if the n wide characters from the
20592 object pointed to by s2 are first copied into a temporary array of n wide characters that
20593 does not overlap the objects pointed to by s1 or s2, and then the n wide characters from
20594 the temporary array are copied into the object pointed to by s1.
20597 The wmemmove function returns the value of s1.
20599 <a name="7.28.4.3" href="#7.28.4.3"><h5>7.28.4.3 Wide string concatenation functions</h5></a>
20601 <a name="7.28.4.3.1" href="#7.28.4.3.1"><h5>7.28.4.3.1 The wcscat function</h5></a>
20605 #include <wchar.h>
20606 wchar_t *wcscat(wchar_t * restrict s1,
20607 const wchar_t * restrict s2);</pre>
20608 <h6>Description</h6>
20610 The wcscat function appends a copy of the wide string pointed to by s2 (including the
20611 terminating null wide character) to the end of the wide string pointed to by s1. The initial
20612 wide character of s2 overwrites the null wide character at the end of s1.
20615 The wcscat function returns the value of s1.
20617 <a name="7.28.4.3.2" href="#7.28.4.3.2"><h5>7.28.4.3.2 The wcsncat function</h5></a>
20621 #include <wchar.h>
20622 wchar_t *wcsncat(wchar_t * restrict s1,
20623 const wchar_t * restrict s2,
20625 <h6>Description</h6>
20627 The wcsncat function appends not more than n wide characters (a null wide character
20628 and those that follow it are not appended) from the array pointed to by s2 to the end of
20629 <!--page 448 indent 4-->
20630 the wide string pointed to by s1. The initial wide character of s2 overwrites the null
20631 wide character at the end of s1. A terminating null wide character is always appended to
20632 the result.<sup><a href="#note334"><b>334)</b></a></sup>
20635 The wcsncat function returns the value of s1.
20638 <p><a name="note334">334)</a> Thus, the maximum number of wide characters that can end up in the array pointed to by s1 is
20642 <a name="7.28.4.4" href="#7.28.4.4"><h5>7.28.4.4 Wide string comparison functions</h5></a>
20644 Unless explicitly stated otherwise, the functions described in this subclause order two
20645 wide characters the same way as two integers of the underlying integer type designated
20648 <a name="7.28.4.4.1" href="#7.28.4.4.1"><h5>7.28.4.4.1 The wcscmp function</h5></a>
20652 #include <wchar.h>
20653 int wcscmp(const wchar_t *s1, const wchar_t *s2);</pre>
20654 <h6>Description</h6>
20656 The wcscmp function compares the wide string pointed to by s1 to the wide string
20660 The wcscmp function returns an integer greater than, equal to, or less than zero,
20661 accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
20662 wide string pointed to by s2.
20664 <a name="7.28.4.4.2" href="#7.28.4.4.2"><h5>7.28.4.4.2 The wcscoll function</h5></a>
20668 #include <wchar.h>
20669 int wcscoll(const wchar_t *s1, const wchar_t *s2);</pre>
20670 <h6>Description</h6>
20672 The wcscoll function compares the wide string pointed to by s1 to the wide string
20673 pointed to by s2, both interpreted as appropriate to the LC_COLLATE category of the
20677 The wcscoll function returns an integer greater than, equal to, or less than zero,
20678 accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
20681 <!--page 449 indent 4-->
20682 wide string pointed to by s2 when both are interpreted as appropriate to the current
20685 <a name="7.28.4.4.3" href="#7.28.4.4.3"><h5>7.28.4.4.3 The wcsncmp function</h5></a>
20689 #include <wchar.h>
20690 int wcsncmp(const wchar_t *s1, const wchar_t *s2,
20692 <h6>Description</h6>
20694 The wcsncmp function compares not more than n wide characters (those that follow a
20695 null wide character are not compared) from the array pointed to by s1 to the array
20699 The wcsncmp function returns an integer greater than, equal to, or less than zero,
20700 accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
20701 to, or less than the possibly null-terminated array pointed to by s2.
20703 <a name="7.28.4.4.4" href="#7.28.4.4.4"><h5>7.28.4.4.4 The wcsxfrm function</h5></a>
20707 #include <wchar.h>
20708 size_t wcsxfrm(wchar_t * restrict s1,
20709 const wchar_t * restrict s2,
20711 <h6>Description</h6>
20713 The wcsxfrm function transforms the wide string pointed to by s2 and places the
20714 resulting wide string into the array pointed to by s1. The transformation is such that if
20715 the wcscmp function is applied to two transformed wide strings, it returns a value greater
20716 than, equal to, or less than zero, corresponding to the result of the wcscoll function
20717 applied to the same two original wide strings. No more than n wide characters are placed
20718 into the resulting array pointed to by s1, including the terminating null wide character. If
20719 n is zero, s1 is permitted to be a null pointer.
20722 The wcsxfrm function returns the length of the transformed wide string (not including
20723 the terminating null wide character). If the value returned is n or greater, the contents of
20724 the array pointed to by s1 are indeterminate.
20726 EXAMPLE The value of the following expression is the length of the array needed to hold the
20727 transformation of the wide string pointed to by s:
20728 <!--page 450 indent 4-->
20730 1 + wcsxfrm(NULL, s, 0)</pre>
20733 <a name="7.28.4.4.5" href="#7.28.4.4.5"><h5>7.28.4.4.5 The wmemcmp function</h5></a>
20737 #include <wchar.h>
20738 int wmemcmp(const wchar_t *s1, const wchar_t *s2,
20740 <h6>Description</h6>
20742 The wmemcmp function compares the first n wide characters of the object pointed to by
20743 s1 to the first n wide characters of the object pointed to by s2.
20746 The wmemcmp function returns an integer greater than, equal to, or less than zero,
20747 accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
20750 <a name="7.28.4.5" href="#7.28.4.5"><h5>7.28.4.5 Wide string search functions</h5></a>
20752 <a name="7.28.4.5.1" href="#7.28.4.5.1"><h5>7.28.4.5.1 The wcschr function</h5></a>
20756 #include <wchar.h>
20757 wchar_t *wcschr(const wchar_t *s, wchar_t c);</pre>
20758 <h6>Description</h6>
20760 The wcschr function locates the first occurrence of c in the wide string pointed to by s.
20761 The terminating null wide character is considered to be part of the wide string.
20764 The wcschr function returns a pointer to the located wide character, or a null pointer if
20765 the wide character does not occur in the wide string.
20767 <a name="7.28.4.5.2" href="#7.28.4.5.2"><h5>7.28.4.5.2 The wcscspn function</h5></a>
20771 #include <wchar.h>
20772 size_t wcscspn(const wchar_t *s1, const wchar_t *s2);</pre>
20773 <h6>Description</h6>
20775 The wcscspn function computes the length of the maximum initial segment of the wide
20776 string pointed to by s1 which consists entirely of wide characters not from the wide
20777 string pointed to by s2.
20778 <!--page 451 indent 4-->
20781 The wcscspn function returns the length of the segment.
20783 <a name="7.28.4.5.3" href="#7.28.4.5.3"><h5>7.28.4.5.3 The wcspbrk function</h5></a>
20787 #include <wchar.h>
20788 wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);</pre>
20789 <h6>Description</h6>
20791 The wcspbrk function locates the first occurrence in the wide string pointed to by s1 of
20792 any wide character from the wide string pointed to by s2.
20795 The wcspbrk function returns a pointer to the wide character in s1, or a null pointer if
20796 no wide character from s2 occurs in s1.
20798 <a name="7.28.4.5.4" href="#7.28.4.5.4"><h5>7.28.4.5.4 The wcsrchr function</h5></a>
20802 #include <wchar.h>
20803 wchar_t *wcsrchr(const wchar_t *s, wchar_t c);</pre>
20804 <h6>Description</h6>
20806 The wcsrchr function locates the last occurrence of c in the wide string pointed to by
20807 s. The terminating null wide character is considered to be part of the wide string.
20810 The wcsrchr function returns a pointer to the wide character, or a null pointer if c does
20811 not occur in the wide string.
20813 <a name="7.28.4.5.5" href="#7.28.4.5.5"><h5>7.28.4.5.5 The wcsspn function</h5></a>
20817 #include <wchar.h>
20818 size_t wcsspn(const wchar_t *s1, const wchar_t *s2);</pre>
20819 <h6>Description</h6>
20821 The wcsspn function computes the length of the maximum initial segment of the wide
20822 string pointed to by s1 which consists entirely of wide characters from the wide string
20826 The wcsspn function returns the length of the segment.
20827 <!--page 452 indent 4-->
20829 <a name="7.28.4.5.6" href="#7.28.4.5.6"><h5>7.28.4.5.6 The wcsstr function</h5></a>
20833 #include <wchar.h>
20834 wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);</pre>
20835 <h6>Description</h6>
20837 The wcsstr function locates the first occurrence in the wide string pointed to by s1 of
20838 the sequence of wide characters (excluding the terminating null wide character) in the
20839 wide string pointed to by s2.
20842 The wcsstr function returns a pointer to the located wide string, or a null pointer if the
20843 wide string is not found. If s2 points to a wide string with zero length, the function
20846 <a name="7.28.4.5.7" href="#7.28.4.5.7"><h5>7.28.4.5.7 The wcstok function</h5></a>
20850 #include <wchar.h>
20851 wchar_t *wcstok(wchar_t * restrict s1,
20852 const wchar_t * restrict s2,
20853 wchar_t ** restrict ptr);</pre>
20854 <h6>Description</h6>
20856 A sequence of calls to the wcstok function breaks the wide string pointed to by s1 into
20857 a sequence of tokens, each of which is delimited by a wide character from the wide string
20858 pointed to by s2. The third argument points to a caller-provided wchar_t pointer into
20859 which the wcstok function stores information necessary for it to continue scanning the
20862 The first call in a sequence has a non-null first argument and stores an initial value in the
20863 object pointed to by ptr. Subsequent calls in the sequence have a null first argument and
20864 the object pointed to by ptr is required to have the value stored by the previous call in
20865 the sequence, which is then updated. The separator wide string pointed to by s2 may be
20866 different from call to call.
20868 The first call in the sequence searches the wide string pointed to by s1 for the first wide
20869 character that is not contained in the current separator wide string pointed to by s2. If no
20870 such wide character is found, then there are no tokens in the wide string pointed to by s1
20871 and the wcstok function returns a null pointer. If such a wide character is found, it is
20872 the start of the first token.
20874 The wcstok function then searches from there for a wide character that is contained in
20875 the current separator wide string. If no such wide character is found, the current token
20876 <!--page 453 indent 4-->
20877 extends to the end of the wide string pointed to by s1, and subsequent searches in the
20878 same wide string for a token return a null pointer. If such a wide character is found, it is
20879 overwritten by a null wide character, which terminates the current token.
20881 In all cases, the wcstok function stores sufficient information in the pointer pointed to
20882 by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
20883 value for ptr, shall start searching just past the element overwritten by a null wide
20884 character (if any).
20887 The wcstok function returns a pointer to the first wide character of a token, or a null
20888 pointer if there is no token.
20892 #include <wchar.h>
20893 static wchar_t str1[] = L"?a???b,,,#c";
20894 static wchar_t str2[] = L"\t \t";
20895 wchar_t *t, *ptr1, *ptr2;
20896 t = wcstok(str1, L"?", &ptr1); // t points to the token L"a"
20897 t = wcstok(NULL, L",", &ptr1); // t points to the token L"??b"
20898 t = wcstok(str2, L" \t", &ptr2); // t is a null pointer
20899 t = wcstok(NULL, L"#,", &ptr1); // t points to the token L"c"
20900 t = wcstok(NULL, L"?", &ptr1); // t is a null pointer</pre>
20903 <a name="7.28.4.5.8" href="#7.28.4.5.8"><h5>7.28.4.5.8 The wmemchr function</h5></a>
20907 #include <wchar.h>
20908 wchar_t *wmemchr(const wchar_t *s, wchar_t c,
20910 <h6>Description</h6>
20912 The wmemchr function locates the first occurrence of c in the initial n wide characters of
20913 the object pointed to by s.
20916 The wmemchr function returns a pointer to the located wide character, or a null pointer if
20917 the wide character does not occur in the object.
20918 <!--page 454 indent 4-->
20920 <a name="7.28.4.6" href="#7.28.4.6"><h5>7.28.4.6 Miscellaneous functions</h5></a>
20922 <a name="7.28.4.6.1" href="#7.28.4.6.1"><h5>7.28.4.6.1 The wcslen function</h5></a>
20926 #include <wchar.h>
20927 size_t wcslen(const wchar_t *s);</pre>
20928 <h6>Description</h6>
20930 The wcslen function computes the length of the wide string pointed to by s.
20933 The wcslen function returns the number of wide characters that precede the terminating
20934 null wide character.
20936 <a name="7.28.4.6.2" href="#7.28.4.6.2"><h5>7.28.4.6.2 The wmemset function</h5></a>
20940 #include <wchar.h>
20941 wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);</pre>
20942 <h6>Description</h6>
20944 The wmemset function copies the value of c into each of the first n wide characters of
20945 the object pointed to by s.
20948 The wmemset function returns the value of s.
20950 <a name="7.28.5" href="#7.28.5"><h4>7.28.5 Wide character time conversion functions</h4></a>
20952 <a name="7.28.5.1" href="#7.28.5.1"><h5>7.28.5.1 The wcsftime function</h5></a>
20956 #include <time.h>
20957 #include <wchar.h>
20958 size_t wcsftime(wchar_t * restrict s,
20960 const wchar_t * restrict format,
20961 const struct tm * restrict timeptr);</pre>
20962 <h6>Description</h6>
20964 The wcsftime function is equivalent to the strftime function, except that:
20966 <li> The argument s points to the initial element of an array of wide characters into which
20967 the generated output is to be placed.
20968 <!--page 455 indent 4-->
20969 <li> The argument maxsize indicates the limiting number of wide characters.
20970 <li> The argument format is a wide string and the conversion specifiers are replaced by
20971 corresponding sequences of wide characters.
20972 <li> The return value indicates the number of wide characters.
20976 If the total number of resulting wide characters including the terminating null wide
20977 character is not more than maxsize, the wcsftime function returns the number of
20978 wide characters placed into the array pointed to by s not including the terminating null
20979 wide character. Otherwise, zero is returned and the contents of the array are
20982 <a name="7.28.6" href="#7.28.6"><h4>7.28.6 Extended multibyte/wide character conversion utilities</h4></a>
20984 The header <wchar.h> declares an extended set of functions useful for conversion
20985 between multibyte characters and wide characters.
20987 Most of the following functions -- those that are listed as ''restartable'', <a href="#7.28.6.3">7.28.6.3</a> and
20988 <a href="#7.28.6.4">7.28.6.4</a> -- take as a last argument a pointer to an object of type mbstate_t that is used
20989 to describe the current conversion state from a particular multibyte character sequence to
20990 a wide character sequence (or the reverse) under the rules of a particular setting for the
20991 LC_CTYPE category of the current locale.
20993 The initial conversion state corresponds, for a conversion in either direction, to the
20994 beginning of a new multibyte character in the initial shift state. A zero-valued
20995 mbstate_t object is (at least) one way to describe an initial conversion state. A zero-
20996 valued mbstate_t object can be used to initiate conversion involving any multibyte
20997 character sequence, in any LC_CTYPE category setting. If an mbstate_t object has
20998 been altered by any of the functions described in this subclause, and is then used with a
20999 different multibyte character sequence, or in the other conversion direction, or with a
21000 different LC_CTYPE category setting than on earlier function calls, the behavior is
21001 undefined.<sup><a href="#note335"><b>335)</b></a></sup>
21003 On entry, each function takes the described conversion state (either internal or pointed to
21004 by an argument) as current. The conversion state described by the referenced object is
21005 altered as needed to track the shift state, and the position within a multibyte character, for
21006 the associated multibyte character sequence.
21011 <!--page 456 indent 4-->
21014 <p><a name="note335">335)</a> Thus, a particular mbstate_t object can be used, for example, with both the mbrtowc and
21015 mbsrtowcs functions as long as they are used to step sequentially through the same multibyte
21019 <a name="7.28.6.1" href="#7.28.6.1"><h5>7.28.6.1 Single-byte/wide character conversion functions</h5></a>
21021 <a name="7.28.6.1.1" href="#7.28.6.1.1"><h5>7.28.6.1.1 The btowc function</h5></a>
21025 #include <wchar.h> *
21026 wint_t btowc(int c);</pre>
21027 <h6>Description</h6>
21029 The btowc function determines whether c constitutes a valid single-byte character in the
21030 initial shift state.
21033 The btowc function returns WEOF if c has the value EOF or if (unsigned char)c
21034 does not constitute a valid single-byte character in the initial shift state. Otherwise, it
21035 returns the wide character representation of that character.
21037 <a name="7.28.6.1.2" href="#7.28.6.1.2"><h5>7.28.6.1.2 The wctob function</h5></a>
21041 #include <wchar.h> *
21042 int wctob(wint_t c);</pre>
21043 <h6>Description</h6>
21045 The wctob function determines whether c corresponds to a member of the extended
21046 character set whose multibyte character representation is a single byte when in the initial
21050 The wctob function returns EOF if c does not correspond to a multibyte character with
21051 length one in the initial shift state. Otherwise, it returns the single-byte representation of
21052 that character as an unsigned char converted to an int.
21054 <a name="7.28.6.2" href="#7.28.6.2"><h5>7.28.6.2 Conversion state functions</h5></a>
21056 <a name="7.28.6.2.1" href="#7.28.6.2.1"><h5>7.28.6.2.1 The mbsinit function</h5></a>
21060 #include <wchar.h>
21061 int mbsinit(const mbstate_t *ps);</pre>
21062 <h6>Description</h6>
21064 If ps is not a null pointer, the mbsinit function determines whether the referenced
21065 mbstate_t object describes an initial conversion state.
21066 <!--page 457 indent 4-->
21069 The mbsinit function returns nonzero if ps is a null pointer or if the referenced object
21070 describes an initial conversion state; otherwise, it returns zero.
21072 <a name="7.28.6.3" href="#7.28.6.3"><h5>7.28.6.3 Restartable multibyte/wide character conversion functions</h5></a>
21074 These functions differ from the corresponding multibyte character functions of <a href="#7.22.7">7.22.7</a>
21075 (mblen, mbtowc, and wctomb) in that they have an extra parameter, ps, of type
21076 pointer to mbstate_t that points to an object that can completely describe the current
21077 conversion state of the associated multibyte character sequence. If ps is a null pointer,
21078 each function uses its own internal mbstate_t object instead, which is initialized at
21079 program startup to the initial conversion state; the functions are not required to avoid data
21080 races in this case. The implementation behaves as if no library function calls these
21081 functions with a null pointer for ps.
21083 Also unlike their corresponding functions, the return value does not represent whether the
21084 encoding is state-dependent.
21086 <a name="7.28.6.3.1" href="#7.28.6.3.1"><h5>7.28.6.3.1 The mbrlen function</h5></a>
21090 #include <wchar.h>
21091 size_t mbrlen(const char * restrict s,
21093 mbstate_t * restrict ps);</pre>
21094 <h6>Description</h6>
21096 The mbrlen function is equivalent to the call:
21098 mbrtowc(NULL, s, n, ps != NULL ? ps : &internal)</pre>
21099 where internal is the mbstate_t object for the mbrlen function, except that the
21100 expression designated by ps is evaluated only once.
21103 The mbrlen function returns a value between zero and n, inclusive, (size_t)(-2),
21105 Forward references: the mbrtowc function (<a href="#7.28.6.3.2">7.28.6.3.2</a>).
21106 <!--page 458 indent 4-->
21108 <a name="7.28.6.3.2" href="#7.28.6.3.2"><h5>7.28.6.3.2 The mbrtowc function</h5></a>
21112 #include <wchar.h>
21113 size_t mbrtowc(wchar_t * restrict pwc,
21114 const char * restrict s,
21116 mbstate_t * restrict ps);</pre>
21117 <h6>Description</h6>
21119 If s is a null pointer, the mbrtowc function is equivalent to the call:
21121 mbrtowc(NULL, "", 1, ps)</pre>
21122 In this case, the values of the parameters pwc and n are ignored.
21124 If s is not a null pointer, the mbrtowc function inspects at most n bytes beginning with
21125 the byte pointed to by s to determine the number of bytes needed to complete the next
21126 multibyte character (including any shift sequences). If the function determines that the
21127 next multibyte character is complete and valid, it determines the value of the
21128 corresponding wide character and then, if pwc is not a null pointer, stores that value in
21129 the object pointed to by pwc. If the corresponding wide character is the null wide
21130 character, the resulting state described is the initial conversion state.
21133 The mbrtowc function returns the first of the following that applies (given the current
21135 0 if the next n or fewer bytes complete the multibyte character that
21137 corresponds to the null wide character (which is the value stored).</pre>
21138 between 1 and n inclusive if the next n or fewer bytes complete a valid multibyte
21140 character (which is the value stored); the value returned is the number
21141 of bytes that complete the multibyte character.</pre>
21142 (size_t)(-2) if the next n bytes contribute to an incomplete (but potentially valid)
21144 multibyte character, and all n bytes have been processed (no value is
21145 stored).<sup><a href="#note336"><b>336)</b></a></sup></pre>
21146 (size_t)(-1) if an encoding error occurs, in which case the next n or fewer bytes
21148 do not contribute to a complete and valid multibyte character (no
21149 value is stored); the value of the macro EILSEQ is stored in errno,
21150 and the conversion state is unspecified.</pre>
21152 <!--page 459 indent 4-->
21155 <p><a name="note336">336)</a> When n has at least the value of the MB_CUR_MAX macro, this case can only occur if s points at a
21156 sequence of redundant shift sequences (for implementations with state-dependent encodings).
21159 <a name="7.28.6.3.3" href="#7.28.6.3.3"><h5>7.28.6.3.3 The wcrtomb function</h5></a>
21163 #include <wchar.h>
21164 size_t wcrtomb(char * restrict s,
21166 mbstate_t * restrict ps);</pre>
21167 <h6>Description</h6>
21169 If s is a null pointer, the wcrtomb function is equivalent to the call
21171 wcrtomb(buf, L'\0', ps)</pre>
21172 where buf is an internal buffer.
21174 If s is not a null pointer, the wcrtomb function determines the number of bytes needed
21175 to represent the multibyte character that corresponds to the wide character given by wc
21176 (including any shift sequences), and stores the multibyte character representation in the
21177 array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
21178 wc is a null wide character, a null byte is stored, preceded by any shift sequence needed
21179 to restore the initial shift state; the resulting state described is the initial conversion state.
21182 The wcrtomb function returns the number of bytes stored in the array object (including
21183 any shift sequences). When wc is not a valid wide character, an encoding error occurs:
21184 the function stores the value of the macro EILSEQ in errno and returns
21185 (size_t)(-1); the conversion state is unspecified.
21187 <a name="7.28.6.4" href="#7.28.6.4"><h5>7.28.6.4 Restartable multibyte/wide string conversion functions</h5></a>
21189 These functions differ from the corresponding multibyte string functions of <a href="#7.22.8">7.22.8</a>
21190 (mbstowcs and wcstombs) in that they have an extra parameter, ps, of type pointer to
21191 mbstate_t that points to an object that can completely describe the current conversion
21192 state of the associated multibyte character sequence. If ps is a null pointer, each function
21193 uses its own internal mbstate_t object instead, which is initialized at program startup
21194 to the initial conversion state; the functions are not required to avoid data races in this
21195 case. The implementation behaves as if no library function calls these functions with a
21196 null pointer for ps.
21198 Also unlike their corresponding functions, the conversion source parameter, src, has a
21199 pointer-to-pointer type. When the function is storing the results of conversions (that is,
21200 when dst is not a null pointer), the pointer object pointed to by this parameter is updated
21201 to reflect the amount of the source processed by that invocation.
21202 <!--page 460 indent 4-->
21204 <a name="7.28.6.4.1" href="#7.28.6.4.1"><h5>7.28.6.4.1 The mbsrtowcs function</h5></a>
21208 #include <wchar.h>
21209 size_t mbsrtowcs(wchar_t * restrict dst,
21210 const char ** restrict src,
21212 mbstate_t * restrict ps);</pre>
21213 <h6>Description</h6>
21215 The mbsrtowcs function converts a sequence of multibyte characters that begins in the
21216 conversion state described by the object pointed to by ps, from the array indirectly
21217 pointed to by src into a sequence of corresponding wide characters. If dst is not a null
21218 pointer, the converted characters are stored into the array pointed to by dst. Conversion
21219 continues up to and including a terminating null character, which is also stored.
21220 Conversion stops earlier in two cases: when a sequence of bytes is encountered that does
21221 not form a valid multibyte character, or (if dst is not a null pointer) when len wide
21222 characters have been stored into the array pointed to by dst.<sup><a href="#note337"><b>337)</b></a></sup> Each conversion takes
21223 place as if by a call to the mbrtowc function.
21225 If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
21226 pointer (if conversion stopped due to reaching a terminating null character) or the address
21227 just past the last multibyte character converted (if any). If conversion stopped due to
21228 reaching a terminating null character and if dst is not a null pointer, the resulting state
21229 described is the initial conversion state.
21232 If the input conversion encounters a sequence of bytes that do not form a valid multibyte
21233 character, an encoding error occurs: the mbsrtowcs function stores the value of the
21234 macro EILSEQ in errno and returns (size_t)(-1); the conversion state is
21235 unspecified. Otherwise, it returns the number of multibyte characters successfully
21236 converted, not including the terminating null character (if any).
21241 <!--page 461 indent 4-->
21244 <p><a name="note337">337)</a> Thus, the value of len is ignored if dst is a null pointer.
21247 <a name="7.28.6.4.2" href="#7.28.6.4.2"><h5>7.28.6.4.2 The wcsrtombs function</h5></a>
21251 #include <wchar.h>
21252 size_t wcsrtombs(char * restrict dst,
21253 const wchar_t ** restrict src,
21255 mbstate_t * restrict ps);</pre>
21256 <h6>Description</h6>
21258 The wcsrtombs function converts a sequence of wide characters from the array
21259 indirectly pointed to by src into a sequence of corresponding multibyte characters that
21260 begins in the conversion state described by the object pointed to by ps. If dst is not a
21261 null pointer, the converted characters are then stored into the array pointed to by dst.
21262 Conversion continues up to and including a terminating null wide character, which is also
21263 stored. Conversion stops earlier in two cases: when a wide character is reached that does
21264 not correspond to a valid multibyte character, or (if dst is not a null pointer) when the
21265 next multibyte character would exceed the limit of len total bytes to be stored into the
21266 array pointed to by dst. Each conversion takes place as if by a call to the wcrtomb
21267 function.<sup><a href="#note338"><b>338)</b></a></sup>
21269 If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
21270 pointer (if conversion stopped due to reaching a terminating null wide character) or the
21271 address just past the last wide character converted (if any). If conversion stopped due to
21272 reaching a terminating null wide character, the resulting state described is the initial
21276 If conversion stops because a wide character is reached that does not correspond to a
21277 valid multibyte character, an encoding error occurs: the wcsrtombs function stores the
21278 value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion
21279 state is unspecified. Otherwise, it returns the number of bytes in the resulting multibyte
21280 character sequence, not including the terminating null character (if any).
21285 <!--page 462 indent 4-->
21288 <p><a name="note338">338)</a> If conversion stops because a terminating null wide character has been reached, the bytes stored
21289 include those necessary to reach the initial shift state immediately before the null byte.
21292 <a name="7.29" href="#7.29"><h3>7.29 Wide character classification and mapping utilities <wctype.h></h3></a>
21294 <a name="7.29.1" href="#7.29.1"><h4>7.29.1 Introduction</h4></a>
21296 The header <wctype.h> defines one macro, and declares three data types and many
21297 functions.<sup><a href="#note339"><b>339)</b></a></sup>
21299 The types declared are
21302 described in <a href="#7.28.1">7.28.1</a>;
21305 which is a scalar type that can hold values which represent locale-specific character
21309 which is a scalar type that can hold values which represent locale-specific character
21312 The macro defined is WEOF (described in <a href="#7.28.1">7.28.1</a>).
21314 The functions declared are grouped as follows:
21316 <li> Functions that provide wide character classification;
21317 <li> Extensible functions that provide wide character classification;
21318 <li> Functions that provide wide character case mapping;
21319 <li> Extensible functions that provide wide character mapping.
21322 For all functions described in this subclause that accept an argument of type wint_t, the
21323 value shall be representable as a wchar_t or shall equal the value of the macro WEOF. If
21324 this argument has any other value, the behavior is undefined.
21326 The behavior of these functions is affected by the LC_CTYPE category of the current
21332 <!--page 463 indent 4-->
21335 <p><a name="note339">339)</a> See ''future library directions'' (<a href="#7.30.13">7.30.13</a>).
21338 <a name="7.29.2" href="#7.29.2"><h4>7.29.2 Wide character classification utilities</h4></a>
21340 The header <wctype.h> declares several functions useful for classifying wide
21343 The term printing wide character refers to a member of a locale-specific set of wide
21344 characters, each of which occupies at least one printing position on a display device. The
21345 term control wide character refers to a member of a locale-specific set of wide characters
21346 that are not printing wide characters.
21348 <a name="7.29.2.1" href="#7.29.2.1"><h5>7.29.2.1 Wide character classification functions</h5></a>
21350 The functions in this subclause return nonzero (true) if and only if the value of the
21351 argument wc conforms to that in the description of the function.
21353 Each of the following functions returns true for each wide character that corresponds (as
21354 if by a call to the wctob function) to a single-byte character for which the corresponding
21355 character classification function from <a href="#7.4.1">7.4.1</a> returns true, except that the iswgraph and
21356 iswpunct functions may differ with respect to wide characters other than L' ' that are
21357 both printing and white-space wide characters.<sup><a href="#note340"><b>340)</b></a></sup>
21358 Forward references: the wctob function (<a href="#7.28.6.1.2">7.28.6.1.2</a>).
21361 <p><a name="note340">340)</a> For example, if the expression isalpha(wctob(wc)) evaluates to true, then the call
21362 iswalpha(wc) also returns true. But, if the expression isgraph(wctob(wc)) evaluates to true
21363 (which cannot occur for wc == L' ' of course), then either iswgraph(wc) or iswprint(wc)
21364 && iswspace(wc) is true, but not both.
21367 <a name="7.29.2.1.1" href="#7.29.2.1.1"><h5>7.29.2.1.1 The iswalnum function</h5></a>
21371 #include <wctype.h>
21372 int iswalnum(wint_t wc);</pre>
21373 <h6>Description</h6>
21375 The iswalnum function tests for any wide character for which iswalpha or
21378 <a name="7.29.2.1.2" href="#7.29.2.1.2"><h5>7.29.2.1.2 The iswalpha function</h5></a>
21382 #include <wctype.h>
21383 int iswalpha(wint_t wc);</pre>
21384 <h6>Description</h6>
21386 The iswalpha function tests for any wide character for which iswupper or
21387 iswlower is true, or any wide character that is one of a locale-specific set of alphabetic
21389 <!--page 464 indent 4-->
21390 wide characters for which none of iswcntrl, iswdigit, iswpunct, or iswspace
21391 is true.<sup><a href="#note341"><b>341)</b></a></sup>
21394 <p><a name="note341">341)</a> The functions iswlower and iswupper test true or false separately for each of these additional
21395 wide characters; all four combinations are possible.
21398 <a name="7.29.2.1.3" href="#7.29.2.1.3"><h5>7.29.2.1.3 The iswblank function</h5></a>
21402 #include <wctype.h>
21403 int iswblank(wint_t wc);</pre>
21404 <h6>Description</h6>
21406 The iswblank function tests for any wide character that is a standard blank wide
21407 character or is one of a locale-specific set of wide characters for which iswspace is true
21408 and that is used to separate words within a line of text. The standard blank wide
21409 characters are the following: space (L' '), and horizontal tab (L'\t'). In the "C"
21410 locale, iswblank returns true only for the standard blank characters.
21412 <a name="7.29.2.1.4" href="#7.29.2.1.4"><h5>7.29.2.1.4 The iswcntrl function</h5></a>
21416 #include <wctype.h>
21417 int iswcntrl(wint_t wc);</pre>
21418 <h6>Description</h6>
21420 The iswcntrl function tests for any control wide character.
21422 <a name="7.29.2.1.5" href="#7.29.2.1.5"><h5>7.29.2.1.5 The iswdigit function</h5></a>
21426 #include <wctype.h>
21427 int iswdigit(wint_t wc);</pre>
21428 <h6>Description</h6>
21430 The iswdigit function tests for any wide character that corresponds to a decimal-digit
21431 character (as defined in <a href="#5.2.1">5.2.1</a>).
21433 <a name="7.29.2.1.6" href="#7.29.2.1.6"><h5>7.29.2.1.6 The iswgraph function</h5></a>
21437 #include <wctype.h>
21438 int iswgraph(wint_t wc);</pre>
21443 <!--page 465 indent 4-->
21444 <h6>Description</h6>
21446 The iswgraph function tests for any wide character for which iswprint is true and
21447 iswspace is false.<sup><a href="#note342"><b>342)</b></a></sup>
21450 <p><a name="note342">342)</a> Note that the behavior of the iswgraph and iswpunct functions may differ from their
21451 corresponding functions in <a href="#7.4.1">7.4.1</a> with respect to printing, white-space, single-byte execution
21452 characters other than ' '.
21455 <a name="7.29.2.1.7" href="#7.29.2.1.7"><h5>7.29.2.1.7 The iswlower function</h5></a>
21459 #include <wctype.h>
21460 int iswlower(wint_t wc);</pre>
21461 <h6>Description</h6>
21463 The iswlower function tests for any wide character that corresponds to a lowercase
21464 letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
21465 iswdigit, iswpunct, or iswspace is true.
21467 <a name="7.29.2.1.8" href="#7.29.2.1.8"><h5>7.29.2.1.8 The iswprint function</h5></a>
21471 #include <wctype.h>
21472 int iswprint(wint_t wc);</pre>
21473 <h6>Description</h6>
21475 The iswprint function tests for any printing wide character.
21477 <a name="7.29.2.1.9" href="#7.29.2.1.9"><h5>7.29.2.1.9 The iswpunct function</h5></a>
21481 #include <wctype.h>
21482 int iswpunct(wint_t wc);</pre>
21483 <h6>Description</h6>
21485 The iswpunct function tests for any printing wide character that is one of a locale-
21486 specific set of punctuation wide characters for which neither iswspace nor iswalnum
21489 <a name="7.29.2.1.10" href="#7.29.2.1.10"><h5>7.29.2.1.10 The iswspace function</h5></a>
21493 #include <wctype.h>
21494 int iswspace(wint_t wc);</pre>
21498 <!--page 466 indent 4-->
21499 <h6>Description</h6>
21501 The iswspace function tests for any wide character that corresponds to a locale-specific
21502 set of white-space wide characters for which none of iswalnum, iswgraph, or
21505 <a name="7.29.2.1.11" href="#7.29.2.1.11"><h5>7.29.2.1.11 The iswupper function</h5></a>
21509 #include <wctype.h>
21510 int iswupper(wint_t wc);</pre>
21511 <h6>Description</h6>
21513 The iswupper function tests for any wide character that corresponds to an uppercase
21514 letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
21515 iswdigit, iswpunct, or iswspace is true.
21517 <a name="7.29.2.1.12" href="#7.29.2.1.12"><h5>7.29.2.1.12 The iswxdigit function</h5></a>
21521 #include <wctype.h>
21522 int iswxdigit(wint_t wc);</pre>
21523 <h6>Description</h6>
21525 The iswxdigit function tests for any wide character that corresponds to a
21526 hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
21528 <a name="7.29.2.2" href="#7.29.2.2"><h5>7.29.2.2 Extensible wide character classification functions</h5></a>
21530 The functions wctype and iswctype provide extensible wide character classification
21531 as well as testing equivalent to that performed by the functions described in the previous
21532 subclause (<a href="#7.29.2.1">7.29.2.1</a>).
21534 <a name="7.29.2.2.1" href="#7.29.2.2.1"><h5>7.29.2.2.1 The iswctype function</h5></a>
21538 #include <wctype.h>
21539 int iswctype(wint_t wc, wctype_t desc);</pre>
21540 <h6>Description</h6>
21542 The iswctype function determines whether the wide character wc has the property
21543 described by desc. The current setting of the LC_CTYPE category shall be the same as
21544 during the call to wctype that returned the value desc.
21546 Each of the following expressions has a truth-value equivalent to the call to the wide
21547 character classification function (<a href="#7.29.2.1">7.29.2.1</a>) in the comment that follows the expression:
21548 <!--page 467 indent 4-->
21550 iswctype(wc, wctype("alnum")) // iswalnum(wc)
21551 iswctype(wc, wctype("alpha")) // iswalpha(wc)
21552 iswctype(wc, wctype("blank")) // iswblank(wc)
21553 iswctype(wc, wctype("cntrl")) // iswcntrl(wc)
21554 iswctype(wc, wctype("digit")) // iswdigit(wc)
21555 iswctype(wc, wctype("graph")) // iswgraph(wc)
21556 iswctype(wc, wctype("lower")) // iswlower(wc)
21557 iswctype(wc, wctype("print")) // iswprint(wc)
21558 iswctype(wc, wctype("punct")) // iswpunct(wc)
21559 iswctype(wc, wctype("space")) // iswspace(wc)
21560 iswctype(wc, wctype("upper")) // iswupper(wc)
21561 iswctype(wc, wctype("xdigit")) // iswxdigit(wc)</pre>
21564 The iswctype function returns nonzero (true) if and only if the value of the wide
21565 character wc has the property described by desc. If desc is zero, the iswctype
21566 function returns zero (false).
21567 Forward references: the wctype function (<a href="#7.29.2.2.2">7.29.2.2.2</a>).
21569 <a name="7.29.2.2.2" href="#7.29.2.2.2"><h5>7.29.2.2.2 The wctype function</h5></a>
21573 #include <wctype.h>
21574 wctype_t wctype(const char *property);</pre>
21575 <h6>Description</h6>
21577 The wctype function constructs a value with type wctype_t that describes a class of
21578 wide characters identified by the string argument property.
21580 The strings listed in the description of the iswctype function shall be valid in all
21581 locales as property arguments to the wctype function.
21584 If property identifies a valid class of wide characters according to the LC_CTYPE
21585 category of the current locale, the wctype function returns a nonzero value that is valid
21586 as the second argument to the iswctype function; otherwise, it returns zero.
21587 <!--page 468 indent 4-->
21589 <a name="7.29.3" href="#7.29.3"><h4>7.29.3 Wide character case mapping utilities</h4></a>
21591 The header <wctype.h> declares several functions useful for mapping wide characters.
21593 <a name="7.29.3.1" href="#7.29.3.1"><h5>7.29.3.1 Wide character case mapping functions</h5></a>
21595 <a name="7.29.3.1.1" href="#7.29.3.1.1"><h5>7.29.3.1.1 The towlower function</h5></a>
21599 #include <wctype.h>
21600 wint_t towlower(wint_t wc);</pre>
21601 <h6>Description</h6>
21603 The towlower function converts an uppercase letter to a corresponding lowercase letter.
21606 If the argument is a wide character for which iswupper is true and there are one or
21607 more corresponding wide characters, as specified by the current locale, for which
21608 iswlower is true, the towlower function returns one of the corresponding wide
21609 characters (always the same one for any given locale); otherwise, the argument is
21610 returned unchanged.
21612 <a name="7.29.3.1.2" href="#7.29.3.1.2"><h5>7.29.3.1.2 The towupper function</h5></a>
21616 #include <wctype.h>
21617 wint_t towupper(wint_t wc);</pre>
21618 <h6>Description</h6>
21620 The towupper function converts a lowercase letter to a corresponding uppercase letter.
21623 If the argument is a wide character for which iswlower is true and there are one or
21624 more corresponding wide characters, as specified by the current locale, for which
21625 iswupper is true, the towupper function returns one of the corresponding wide
21626 characters (always the same one for any given locale); otherwise, the argument is
21627 returned unchanged.
21629 <a name="7.29.3.2" href="#7.29.3.2"><h5>7.29.3.2 Extensible wide character case mapping functions</h5></a>
21631 The functions wctrans and towctrans provide extensible wide character mapping as
21632 well as case mapping equivalent to that performed by the functions described in the
21633 previous subclause (<a href="#7.29.3.1">7.29.3.1</a>).
21634 <!--page 469 indent 4-->
21636 <a name="7.29.3.2.1" href="#7.29.3.2.1"><h5>7.29.3.2.1 The towctrans function</h5></a>
21640 #include <wctype.h>
21641 wint_t towctrans(wint_t wc, wctrans_t desc);</pre>
21642 <h6>Description</h6>
21644 The towctrans function maps the wide character wc using the mapping described by
21645 desc. The current setting of the LC_CTYPE category shall be the same as during the call
21646 to wctrans that returned the value desc.
21648 Each of the following expressions behaves the same as the call to the wide character case
21649 mapping function (<a href="#7.29.3.1">7.29.3.1</a>) in the comment that follows the expression:
21651 towctrans(wc, wctrans("tolower")) // towlower(wc)
21652 towctrans(wc, wctrans("toupper")) // towupper(wc)</pre>
21655 The towctrans function returns the mapped value of wc using the mapping described
21656 by desc. If desc is zero, the towctrans function returns the value of wc.
21658 <a name="7.29.3.2.2" href="#7.29.3.2.2"><h5>7.29.3.2.2 The wctrans function</h5></a>
21662 #include <wctype.h>
21663 wctrans_t wctrans(const char *property);</pre>
21664 <h6>Description</h6>
21666 The wctrans function constructs a value with type wctrans_t that describes a
21667 mapping between wide characters identified by the string argument property.
21669 The strings listed in the description of the towctrans function shall be valid in all
21670 locales as property arguments to the wctrans function.
21673 If property identifies a valid mapping of wide characters according to the LC_CTYPE
21674 category of the current locale, the wctrans function returns a nonzero value that is valid
21675 as the second argument to the towctrans function; otherwise, it returns zero.
21676 <!--page 470 indent 4-->
21678 <a name="7.30" href="#7.30"><h3>7.30 Future library directions</h3></a>
21680 The following names are grouped under individual headers for convenience. All external
21681 names described below are reserved no matter what headers are included by the program.
21683 <a name="7.30.1" href="#7.30.1"><h4>7.30.1 Complex arithmetic <complex.h></h4></a>
21688 cerfc clog10 clgamma
21689 cexp2 clog1p ctgamma</pre>
21690 and the same names suffixed with f or l may be added to the declarations in the
21691 <complex.h> header.
21693 <a name="7.30.2" href="#7.30.2"><h4>7.30.2 Character handling <ctype.h></h4></a>
21695 Function names that begin with either is or to, and a lowercase letter may be added to
21696 the declarations in the <ctype.h> header.
21698 <a name="7.30.3" href="#7.30.3"><h4>7.30.3 Errors <errno.h></h4></a>
21700 Macros that begin with E and a digit or E and an uppercase letter may be added to the
21701 declarations in the <errno.h> header.
21703 <a name="7.30.4" href="#7.30.4"><h4>7.30.4 Format conversion of integer types <inttypes.h></h4></a>
21705 Macro names beginning with PRI or SCN followed by any lowercase letter or X may be
21706 added to the macros defined in the <inttypes.h> header.
21708 <a name="7.30.5" href="#7.30.5"><h4>7.30.5 Localization <locale.h></h4></a>
21710 Macros that begin with LC_ and an uppercase letter may be added to the definitions in
21711 the <locale.h> header.
21713 <a name="7.30.6" href="#7.30.6"><h4>7.30.6 Signal handling <signal.h></h4></a>
21715 Macros that begin with either SIG and an uppercase letter or SIG_ and an uppercase
21716 letter may be added to the definitions in the <signal.h> header.
21718 <a name="7.30.7" href="#7.30.7"><h4>7.30.7 Boolean type and values <stdbool.h></h4></a>
21720 The ability to undefine and perhaps then redefine the macros bool, true, and false is
21721 an obsolescent feature.
21723 <a name="7.30.8" href="#7.30.8"><h4>7.30.8 Integer types <stdint.h></h4></a>
21725 Typedef names beginning with int or uint and ending with _t may be added to the
21726 types defined in the <stdint.h> header. Macro names beginning with INT or UINT
21727 and ending with _MAX, _MIN, or _C may be added to the macros defined in the
21728 <stdint.h> header.
21729 <!--page 471 indent 4-->
21731 <a name="7.30.9" href="#7.30.9"><h4>7.30.9 Input/output <stdio.h></h4></a>
21733 Lowercase letters may be added to the conversion specifiers and length modifiers in
21734 fprintf and fscanf. Other characters may be used in extensions.
21736 The use of ungetc on a binary stream where the file position indicator is zero prior to *
21737 the call is an obsolescent feature.
21739 <a name="7.30.10" href="#7.30.10"><h4>7.30.10 General utilities <stdlib.h></h4></a>
21741 Function names that begin with str and a lowercase letter may be added to the
21742 declarations in the <stdlib.h> header.
21744 <a name="7.30.11" href="#7.30.11"><h4>7.30.11 String handling <string.h></h4></a>
21746 Function names that begin with str, mem, or wcs and a lowercase letter may be added
21747 to the declarations in the <string.h> header.
21749 <a name="7.30.12" href="#7.30.12"><h4>7.30.12 Extended multibyte and wide character utilities <wchar.h></h4></a>
21751 Function names that begin with wcs and a lowercase letter may be added to the
21752 declarations in the <wchar.h> header.
21754 Lowercase letters may be added to the conversion specifiers and length modifiers in
21755 fwprintf and fwscanf. Other characters may be used in extensions.
21757 <a name="7.30.13" href="#7.30.13"><h4>7.30.13 Wide character classification and mapping utilities</h4></a>
21760 Function names that begin with is or to and a lowercase letter may be added to the
21761 declarations in the <wctype.h> header.
21762 <!--page 472 indent 4-->
21764 <a name="A" href="#A"><h2>Annex A</h2></a>
21768 Language syntax summary</pre>
21769 NOTE The notation is described in <a href="#6.1">6.1</a>.
21772 <a name="A.1" href="#A.1"><h3>A.1 Lexical grammar</h3></a>
21774 <a name="A.1.1" href="#A.1.1"><h4>A.1.1 Lexical elements</h4></a>
21775 (<a href="#6.4">6.4</a>) token:
21782 (<a href="#6.4">6.4</a>) preprocessing-token:
21783 <!--page 473 indent 0-->
21791 each non-white-space character that cannot be one of the above</pre>
21793 <a name="A.1.2" href="#A.1.2"><h4>A.1.2 Keywords</h4></a>
21794 (<a href="#6.4.1">6.4.1</a>) keyword: one of
21801 const register _Alignas
21802 continue restrict _Atomic
21803 default return _Bool
21805 double signed _Generic
21806 else sizeof _Imaginary
21807 enum static _Noreturn
21808 extern struct _Static_assert
21809 float switch _Thread_local
21812 <a name="A.1.3" href="#A.1.3"><h4>A.1.3 Identifiers</h4></a>
21813 (<a href="#6.4.2.1">6.4.2.1</a>) identifier:
21815 identifier-nondigit
21816 identifier identifier-nondigit
21817 identifier digit</pre>
21818 (<a href="#6.4.2.1">6.4.2.1</a>) identifier-nondigit:
21821 universal-character-name
21822 other implementation-defined characters</pre>
21823 (<a href="#6.4.2.1">6.4.2.1</a>) nondigit: one of
21825 _ a b c d e f g h i j k l m
21826 n o p q r s t u v w x y z
21827 A B C D E F G H I J K L M
21828 N O P Q R S T U V W X Y Z</pre>
21829 (<a href="#6.4.2.1">6.4.2.1</a>) digit: one of
21830 <!--page 474 indent 0-->
21832 0 1 2 3 4 5 6 7 8 9</pre>
21834 <a name="A.1.4" href="#A.1.4"><h4>A.1.4 Universal character names</h4></a>
21835 (<a href="#6.4.3">6.4.3</a>) universal-character-name:
21838 \U hex-quad hex-quad</pre>
21839 (<a href="#6.4.3">6.4.3</a>) hex-quad:
21841 hexadecimal-digit hexadecimal-digit
21842 hexadecimal-digit hexadecimal-digit</pre>
21844 <a name="A.1.5" href="#A.1.5"><h4>A.1.5 Constants</h4></a>
21845 (<a href="#6.4.4">6.4.4</a>) constant:
21849 enumeration-constant
21850 character-constant</pre>
21851 (<a href="#6.4.4.1">6.4.4.1</a>) integer-constant:
21853 decimal-constant integer-suffixopt
21854 octal-constant integer-suffixopt
21855 hexadecimal-constant integer-suffixopt</pre>
21856 (<a href="#6.4.4.1">6.4.4.1</a>) decimal-constant:
21859 decimal-constant digit</pre>
21860 (<a href="#6.4.4.1">6.4.4.1</a>) octal-constant:
21863 octal-constant octal-digit</pre>
21864 (<a href="#6.4.4.1">6.4.4.1</a>) hexadecimal-constant:
21866 hexadecimal-prefix hexadecimal-digit
21867 hexadecimal-constant hexadecimal-digit</pre>
21868 (<a href="#6.4.4.1">6.4.4.1</a>) hexadecimal-prefix: one of
21871 (<a href="#6.4.4.1">6.4.4.1</a>) nonzero-digit: one of
21873 1 2 3 4 5 6 7 8 9</pre>
21874 (<a href="#6.4.4.1">6.4.4.1</a>) octal-digit: one of
21875 <!--page 475 indent 0-->
21877 0 1 2 3 4 5 6 7</pre>
21878 (<a href="#6.4.4.1">6.4.4.1</a>) hexadecimal-digit: one of
21880 0 1 2 3 4 5 6 7 8 9
21883 (<a href="#6.4.4.1">6.4.4.1</a>) integer-suffix:
21885 unsigned-suffix long-suffixopt
21886 unsigned-suffix long-long-suffix
21887 long-suffix unsigned-suffixopt
21888 long-long-suffix unsigned-suffixopt</pre>
21889 (<a href="#6.4.4.1">6.4.4.1</a>) unsigned-suffix: one of
21892 (<a href="#6.4.4.1">6.4.4.1</a>) long-suffix: one of
21895 (<a href="#6.4.4.1">6.4.4.1</a>) long-long-suffix: one of
21898 (<a href="#6.4.4.2">6.4.4.2</a>) floating-constant:
21900 decimal-floating-constant
21901 hexadecimal-floating-constant</pre>
21902 (<a href="#6.4.4.2">6.4.4.2</a>) decimal-floating-constant:
21904 fractional-constant exponent-partopt floating-suffixopt
21905 digit-sequence exponent-part floating-suffixopt</pre>
21906 (<a href="#6.4.4.2">6.4.4.2</a>) hexadecimal-floating-constant:
21908 hexadecimal-prefix hexadecimal-fractional-constant
21909 binary-exponent-part floating-suffixopt
21910 hexadecimal-prefix hexadecimal-digit-sequence
21911 binary-exponent-part floating-suffixopt</pre>
21912 (<a href="#6.4.4.2">6.4.4.2</a>) fractional-constant:
21914 digit-sequenceopt . digit-sequence
21915 digit-sequence .</pre>
21916 (<a href="#6.4.4.2">6.4.4.2</a>) exponent-part:
21918 e signopt digit-sequence
21919 E signopt digit-sequence</pre>
21920 (<a href="#6.4.4.2">6.4.4.2</a>) sign: one of
21921 <!--page 476 indent 0-->
21924 (<a href="#6.4.4.2">6.4.4.2</a>) digit-sequence:
21927 digit-sequence digit</pre>
21928 (<a href="#6.4.4.2">6.4.4.2</a>) hexadecimal-fractional-constant:
21930 hexadecimal-digit-sequenceopt .
21931 hexadecimal-digit-sequence
21932 hexadecimal-digit-sequence .</pre>
21933 (<a href="#6.4.4.2">6.4.4.2</a>) binary-exponent-part:
21935 p signopt digit-sequence
21936 P signopt digit-sequence</pre>
21937 (<a href="#6.4.4.2">6.4.4.2</a>) hexadecimal-digit-sequence:
21940 hexadecimal-digit-sequence hexadecimal-digit</pre>
21941 (<a href="#6.4.4.2">6.4.4.2</a>) floating-suffix: one of
21944 (<a href="#6.4.4.3">6.4.4.3</a>) enumeration-constant:
21947 (<a href="#6.4.4.4">6.4.4.4</a>) character-constant:
21949 ' c-char-sequence '
21950 L' c-char-sequence '
21951 u' c-char-sequence '
21952 U' c-char-sequence '</pre>
21953 (<a href="#6.4.4.4">6.4.4.4</a>) c-char-sequence:
21956 c-char-sequence c-char</pre>
21957 (<a href="#6.4.4.4">6.4.4.4</a>) c-char:
21959 any member of the source character set except
21960 the single-quote ', backslash \, or new-line character
21961 escape-sequence</pre>
21962 (<a href="#6.4.4.4">6.4.4.4</a>) escape-sequence:
21963 <!--page 477 indent 0-->
21965 simple-escape-sequence
21966 octal-escape-sequence
21967 hexadecimal-escape-sequence
21968 universal-character-name</pre>
21969 (<a href="#6.4.4.4">6.4.4.4</a>) simple-escape-sequence: one of
21972 \a \b \f \n \r \t \v</pre>
21973 (<a href="#6.4.4.4">6.4.4.4</a>) octal-escape-sequence:
21976 \ octal-digit octal-digit
21977 \ octal-digit octal-digit octal-digit</pre>
21978 (<a href="#6.4.4.4">6.4.4.4</a>) hexadecimal-escape-sequence:
21980 \x hexadecimal-digit
21981 hexadecimal-escape-sequence hexadecimal-digit</pre>
21983 <a name="A.1.6" href="#A.1.6"><h4>A.1.6 String literals</h4></a>
21984 (<a href="#6.4.5">6.4.5</a>) string-literal:
21986 encoding-prefixopt " s-char-sequenceopt "</pre>
21987 (<a href="#6.4.5">6.4.5</a>) encoding-prefix:
21993 (<a href="#6.4.5">6.4.5</a>) s-char-sequence:
21996 s-char-sequence s-char</pre>
21997 (<a href="#6.4.5">6.4.5</a>) s-char:
21999 any member of the source character set except
22000 the double-quote ", backslash \, or new-line character
22001 escape-sequence</pre>
22003 <a name="A.1.7" href="#A.1.7"><h4>A.1.7 Punctuators</h4></a>
22004 (<a href="#6.4.6">6.4.6</a>) punctuator: one of
22005 <!--page 478 indent 0-->
22007 [ ] ( ) { } . ->
22008 ++ -- & * + - ~ !
22009 / % << >> < > <= >= == != ^ | && ||
22011 = *= /= %= += -= <<= >>= &= ^= |=
22013 <: :> <% %> %: %:%:</pre>
22015 <a name="A.1.8" href="#A.1.8"><h4>A.1.8 Header names</h4></a>
22016 (<a href="#6.4.7">6.4.7</a>) header-name:
22018 < h-char-sequence >
22019 " q-char-sequence "</pre>
22020 (<a href="#6.4.7">6.4.7</a>) h-char-sequence:
22023 h-char-sequence h-char</pre>
22024 (<a href="#6.4.7">6.4.7</a>) h-char:
22026 any member of the source character set except
22027 the new-line character and ></pre>
22028 (<a href="#6.4.7">6.4.7</a>) q-char-sequence:
22031 q-char-sequence q-char</pre>
22032 (<a href="#6.4.7">6.4.7</a>) q-char:
22034 any member of the source character set except
22035 the new-line character and "</pre>
22037 <a name="A.1.9" href="#A.1.9"><h4>A.1.9 Preprocessing numbers</h4></a>
22038 (<a href="#6.4.8">6.4.8</a>) pp-number:
22039 <!--page 479 indent 0-->
22044 pp-number identifier-nondigit
22051 <a name="A.2" href="#A.2"><h3>A.2 Phrase structure grammar</h3></a>
22053 <a name="A.2.1" href="#A.2.1"><h4>A.2.1 Expressions</h4></a>
22054 (<a href="#6.5.1">6.5.1</a>) primary-expression:
22060 generic-selection</pre>
22061 (<a href="#6.5.1.1">6.5.1.1</a>) generic-selection:
22063 _Generic ( assignment-expression , generic-assoc-list )</pre>
22064 (<a href="#6.5.1.1">6.5.1.1</a>) generic-assoc-list:
22066 generic-association
22067 generic-assoc-list , generic-association</pre>
22068 (<a href="#6.5.1.1">6.5.1.1</a>) generic-association:
22070 type-name : assignment-expression
22071 default : assignment-expression</pre>
22072 (<a href="#6.5.2">6.5.2</a>) postfix-expression:
22075 postfix-expression [ expression ]
22076 postfix-expression ( argument-expression-listopt )
22077 postfix-expression . identifier
22078 postfix-expression -> identifier
22079 postfix-expression ++
22080 postfix-expression --
22081 ( type-name ) { initializer-list }
22082 ( type-name ) { initializer-list , }</pre>
22083 (<a href="#6.5.2">6.5.2</a>) argument-expression-list:
22085 assignment-expression
22086 argument-expression-list , assignment-expression</pre>
22087 (<a href="#6.5.3">6.5.3</a>) unary-expression:
22088 <!--page 480 indent 0-->
22091 ++ unary-expression
22092 -- unary-expression
22093 unary-operator cast-expression
22094 sizeof unary-expression
22095 sizeof ( type-name )
22096 alignof ( type-name )</pre>
22097 (<a href="#6.5.3">6.5.3</a>) unary-operator: one of
22099 & * + - ~ !</pre>
22100 (<a href="#6.5.4">6.5.4</a>) cast-expression:
22103 ( type-name ) cast-expression</pre>
22104 (<a href="#6.5.5">6.5.5</a>) multiplicative-expression:
22107 multiplicative-expression * cast-expression
22108 multiplicative-expression / cast-expression
22109 multiplicative-expression % cast-expression</pre>
22110 (<a href="#6.5.6">6.5.6</a>) additive-expression:
22112 multiplicative-expression
22113 additive-expression + multiplicative-expression
22114 additive-expression - multiplicative-expression</pre>
22115 (<a href="#6.5.7">6.5.7</a>) shift-expression:
22117 additive-expression
22118 shift-expression << additive-expression
22119 shift-expression >> additive-expression</pre>
22120 (<a href="#6.5.8">6.5.8</a>) relational-expression:
22123 relational-expression < shift-expression
22124 relational-expression > shift-expression
22125 relational-expression <= shift-expression
22126 relational-expression >= shift-expression</pre>
22127 (<a href="#6.5.9">6.5.9</a>) equality-expression:
22129 relational-expression
22130 equality-expression == relational-expression
22131 equality-expression != relational-expression</pre>
22132 (<a href="#6.5.10">6.5.10</a>) AND-expression:
22134 equality-expression
22135 AND-expression & equality-expression</pre>
22136 (<a href="#6.5.11">6.5.11</a>) exclusive-OR-expression:
22137 <!--page 481 indent 0-->
22140 exclusive-OR-expression ^ AND-expression</pre>
22141 (<a href="#6.5.12">6.5.12</a>) inclusive-OR-expression:
22143 exclusive-OR-expression
22144 inclusive-OR-expression | exclusive-OR-expression</pre>
22145 (<a href="#6.5.13">6.5.13</a>) logical-AND-expression:
22147 inclusive-OR-expression
22148 logical-AND-expression && inclusive-OR-expression</pre>
22149 (<a href="#6.5.14">6.5.14</a>) logical-OR-expression:
22151 logical-AND-expression
22152 logical-OR-expression || logical-AND-expression</pre>
22153 (<a href="#6.5.15">6.5.15</a>) conditional-expression:
22155 logical-OR-expression
22156 logical-OR-expression ? expression : conditional-expression</pre>
22157 (<a href="#6.5.16">6.5.16</a>) assignment-expression:
22159 conditional-expression
22160 unary-expression assignment-operator assignment-expression</pre>
22161 (<a href="#6.5.16">6.5.16</a>) assignment-operator: one of
22163 = *= /= %= += -= <<= >>= &= ^= |=</pre>
22164 (<a href="#6.5.17">6.5.17</a>) expression:
22166 assignment-expression
22167 expression , assignment-expression</pre>
22168 (<a href="#6.6">6.6</a>) constant-expression:
22170 conditional-expression</pre>
22172 <a name="A.2.2" href="#A.2.2"><h4>A.2.2 Declarations</h4></a>
22173 (<a href="#6.7">6.7</a>) declaration:
22175 declaration-specifiers init-declarator-listopt ;
22176 static_assert-declaration</pre>
22177 (<a href="#6.7">6.7</a>) declaration-specifiers:
22179 storage-class-specifier declaration-specifiersopt
22180 type-specifier declaration-specifiersopt
22181 type-qualifier declaration-specifiersopt
22182 function-specifier declaration-specifiersopt
22183 alignment-specifier declaration-specifiersopt</pre>
22184 (<a href="#6.7">6.7</a>) init-declarator-list:
22185 <!--page 482 indent 0-->
22188 init-declarator-list , init-declarator</pre>
22189 (<a href="#6.7">6.7</a>) init-declarator:
22192 declarator = initializer</pre>
22193 (<a href="#6.7.1">6.7.1</a>) storage-class-specifier:
22201 (<a href="#6.7.2">6.7.2</a>) type-specifier:
22214 atomic-type-specifier
22215 struct-or-union-specifier
22218 (<a href="#6.7.2.1">6.7.2.1</a>) struct-or-union-specifier:
22220 struct-or-union identifieropt { struct-declaration-list }
22221 struct-or-union identifier</pre>
22222 (<a href="#6.7.2.1">6.7.2.1</a>) struct-or-union:
22226 (<a href="#6.7.2.1">6.7.2.1</a>) struct-declaration-list:
22229 struct-declaration-list struct-declaration</pre>
22230 (<a href="#6.7.2.1">6.7.2.1</a>) struct-declaration:
22231 <!--page 483 indent 0-->
22233 specifier-qualifier-list struct-declarator-listopt ;
22234 static_assert-declaration</pre>
22235 (<a href="#6.7.2.1">6.7.2.1</a>) specifier-qualifier-list:
22237 type-specifier specifier-qualifier-listopt
22238 type-qualifier specifier-qualifier-listopt</pre>
22239 (<a href="#6.7.2.1">6.7.2.1</a>) struct-declarator-list:
22242 struct-declarator-list , struct-declarator</pre>
22243 (<a href="#6.7.2.1">6.7.2.1</a>) struct-declarator:
22246 declaratoropt : constant-expression</pre>
22247 (<a href="#6.7.2.2">6.7.2.2</a>) enum-specifier:
22249 enum identifieropt { enumerator-list }
22250 enum identifieropt { enumerator-list , }
22251 enum identifier</pre>
22252 (<a href="#6.7.2.2">6.7.2.2</a>) enumerator-list:
22255 enumerator-list , enumerator</pre>
22256 (<a href="#6.7.2.2">6.7.2.2</a>) enumerator:
22258 enumeration-constant
22259 enumeration-constant = constant-expression</pre>
22260 (<a href="#6.7.2.4">6.7.2.4</a>) atomic-type-specifier:
22262 _Atomic ( type-name )</pre>
22263 (<a href="#6.7.3">6.7.3</a>) type-qualifier:
22269 (<a href="#6.7.4">6.7.4</a>) function-specifier:
22273 (<a href="#6.7.5">6.7.5</a>) alignment-specifier:
22275 _Alignas ( type-name )
22276 _Alignas ( constant-expression )</pre>
22277 (<a href="#6.7.6">6.7.6</a>) declarator:
22278 <!--page 484 indent 0-->
22280 pointeropt direct-declarator</pre>
22281 (<a href="#6.7.6">6.7.6</a>) direct-declarator:
22285 direct-declarator [ type-qualifier-listopt assignment-expressionopt ]
22286 direct-declarator [ static type-qualifier-listopt assignment-expression ]
22287 direct-declarator [ type-qualifier-list static assignment-expression ]
22288 direct-declarator [ type-qualifier-listopt * ]
22289 direct-declarator ( parameter-type-list )
22290 direct-declarator ( identifier-listopt )</pre>
22291 (<a href="#6.7.6">6.7.6</a>) pointer:
22293 * type-qualifier-listopt
22294 * type-qualifier-listopt pointer</pre>
22295 (<a href="#6.7.6">6.7.6</a>) type-qualifier-list:
22298 type-qualifier-list type-qualifier</pre>
22299 (<a href="#6.7.6">6.7.6</a>) parameter-type-list:
22302 parameter-list , ...</pre>
22303 (<a href="#6.7.6">6.7.6</a>) parameter-list:
22305 parameter-declaration
22306 parameter-list , parameter-declaration</pre>
22307 (<a href="#6.7.6">6.7.6</a>) parameter-declaration:
22309 declaration-specifiers declarator
22310 declaration-specifiers abstract-declaratoropt</pre>
22311 (<a href="#6.7.6">6.7.6</a>) identifier-list:
22314 identifier-list , identifier</pre>
22315 (<a href="#6.7.7">6.7.7</a>) type-name:
22317 specifier-qualifier-list abstract-declaratoropt</pre>
22318 (<a href="#6.7.7">6.7.7</a>) abstract-declarator:
22319 <!--page 485 indent 0-->
22322 pointeropt direct-abstract-declarator</pre>
22323 (<a href="#6.7.7">6.7.7</a>) direct-abstract-declarator:
22325 ( abstract-declarator )
22326 direct-abstract-declaratoropt [ type-qualifier-listopt
22327 assignment-expressionopt ]
22328 direct-abstract-declaratoropt [ static type-qualifier-listopt
22329 assignment-expression ]
22330 direct-abstract-declaratoropt [ type-qualifier-list static
22331 assignment-expression ]
22332 direct-abstract-declaratoropt [ * ]
22333 direct-abstract-declaratoropt ( parameter-type-listopt )</pre>
22334 (<a href="#6.7.8">6.7.8</a>) typedef-name:
22337 (<a href="#6.7.9">6.7.9</a>) initializer:
22339 assignment-expression
22340 { initializer-list }
22341 { initializer-list , }</pre>
22342 (<a href="#6.7.9">6.7.9</a>) initializer-list:
22344 designationopt initializer
22345 initializer-list , designationopt initializer</pre>
22346 (<a href="#6.7.9">6.7.9</a>) designation:
22348 designator-list =</pre>
22349 (<a href="#6.7.9">6.7.9</a>) designator-list:
22352 designator-list designator</pre>
22353 (<a href="#6.7.9">6.7.9</a>) designator:
22355 [ constant-expression ]
22357 (<a href="#6.7.10">6.7.10</a>) static_assert-declaration:
22358 <!--page 486 indent 0-->
22360 _Static_assert ( constant-expression , string-literal ) ;</pre>
22362 <a name="A.2.3" href="#A.2.3"><h4>A.2.3 Statements</h4></a>
22363 (<a href="#6.8">6.8</a>) statement:
22367 expression-statement
22368 selection-statement
22369 iteration-statement
22370 jump-statement</pre>
22371 (<a href="#6.8.1">6.8.1</a>) labeled-statement:
22373 identifier : statement
22374 case constant-expression : statement
22375 default : statement</pre>
22376 (<a href="#6.8.2">6.8.2</a>) compound-statement:
22378 { block-item-listopt }</pre>
22379 (<a href="#6.8.2">6.8.2</a>) block-item-list:
22382 block-item-list block-item</pre>
22383 (<a href="#6.8.2">6.8.2</a>) block-item:
22387 (<a href="#6.8.3">6.8.3</a>) expression-statement:
22389 expressionopt ;</pre>
22390 (<a href="#6.8.4">6.8.4</a>) selection-statement:
22392 if ( expression ) statement
22393 if ( expression ) statement else statement
22394 switch ( expression ) statement</pre>
22395 (<a href="#6.8.5">6.8.5</a>) iteration-statement:
22397 while ( expression ) statement
22398 do statement while ( expression ) ;
22399 for ( expressionopt ; expressionopt ; expressionopt ) statement
22400 for ( declaration expressionopt ; expressionopt ) statement</pre>
22401 (<a href="#6.8.6">6.8.6</a>) jump-statement:
22402 <!--page 487 indent 0-->
22407 return expressionopt ;</pre>
22409 <a name="A.2.4" href="#A.2.4"><h4>A.2.4 External definitions</h4></a>
22410 (<a href="#6.9">6.9</a>) translation-unit:
22412 external-declaration
22413 translation-unit external-declaration</pre>
22414 (<a href="#6.9">6.9</a>) external-declaration:
22416 function-definition
22418 (<a href="#6.9.1">6.9.1</a>) function-definition:
22420 declaration-specifiers declarator declaration-listopt compound-statement</pre>
22421 (<a href="#6.9.1">6.9.1</a>) declaration-list:
22424 declaration-list declaration</pre>
22426 <a name="A.3" href="#A.3"><h3>A.3 Preprocessing directives</h3></a>
22427 (<a href="#6.10">6.10</a>) preprocessing-file:
22430 (<a href="#6.10">6.10</a>) group:
22433 group group-part</pre>
22434 (<a href="#6.10">6.10</a>) group-part:
22439 # non-directive</pre>
22440 (<a href="#6.10">6.10</a>) if-section:
22442 if-group elif-groupsopt else-groupopt endif-line</pre>
22443 (<a href="#6.10">6.10</a>) if-group:
22445 # if constant-expression new-line groupopt
22446 # ifdef identifier new-line groupopt
22447 # ifndef identifier new-line groupopt</pre>
22448 (<a href="#6.10">6.10</a>) elif-groups:
22451 elif-groups elif-group</pre>
22452 (<a href="#6.10">6.10</a>) elif-group:
22453 <!--page 488 indent 0-->
22455 # elif constant-expression new-line groupopt</pre>
22456 (<a href="#6.10">6.10</a>) else-group:
22458 # else new-line groupopt</pre>
22459 (<a href="#6.10">6.10</a>) endif-line:
22461 # endif new-line</pre>
22462 (<a href="#6.10">6.10</a>) control-line:
22464 # include pp-tokens new-line
22465 # define identifier replacement-list new-line
22466 # define identifier lparen identifier-listopt )
22467 replacement-list new-line
22468 # define identifier lparen ... ) replacement-list new-line
22469 # define identifier lparen identifier-list , ... )
22470 replacement-list new-line
22471 # undef identifier new-line
22472 # line pp-tokens new-line
22473 # error pp-tokensopt new-line
22474 # pragma pp-tokensopt new-line
22476 (<a href="#6.10">6.10</a>) text-line:
22478 pp-tokensopt new-line</pre>
22479 (<a href="#6.10">6.10</a>) non-directive:
22481 pp-tokens new-line</pre>
22482 (<a href="#6.10">6.10</a>) lparen:
22484 a ( character not immediately preceded by white-space</pre>
22485 (<a href="#6.10">6.10</a>) replacement-list:
22488 (<a href="#6.10">6.10</a>) pp-tokens:
22490 preprocessing-token
22491 pp-tokens preprocessing-token</pre>
22492 (<a href="#6.10">6.10</a>) new-line:
22493 <!--page 489 indent 0-->
22495 the new-line character</pre>
22497 <a name="B" href="#B"><h2>Annex B</h2></a>
22500 Library summary</pre>
22502 <a name="B.1" href="#B.1"><h3>B.1 Diagnostics <assert.h></h3></a>
22506 void assert(scalar expression);</pre>
22508 <a name="B.2" href="#B.2"><h3>B.2 Complex <complex.h></h3></a>
22509 <!--page 490 indent -1-->
22510 <!--page 491 indent 0-->
22512 __STDC_NO_COMPLEX__ imaginary
22513 complex _Imaginary_I
22515 #pragma STDC CX_LIMITED_RANGE on-off-switch
22516 double complex cacos(double complex z);
22517 float complex cacosf(float complex z);
22518 long double complex cacosl(long double complex z);
22519 double complex casin(double complex z);
22520 float complex casinf(float complex z);
22521 long double complex casinl(long double complex z);
22522 double complex catan(double complex z);
22523 float complex catanf(float complex z);
22524 long double complex catanl(long double complex z);
22525 double complex ccos(double complex z);
22526 float complex ccosf(float complex z);
22527 long double complex ccosl(long double complex z);
22528 double complex csin(double complex z);
22529 float complex csinf(float complex z);
22530 long double complex csinl(long double complex z);
22531 double complex ctan(double complex z);
22532 float complex ctanf(float complex z);
22533 long double complex ctanl(long double complex z);
22534 double complex cacosh(double complex z);
22535 float complex cacoshf(float complex z);
22536 long double complex cacoshl(long double complex z);
22537 double complex casinh(double complex z);
22538 float complex casinhf(float complex z);
22539 long double complex casinhl(long double complex z);
22540 double complex catanh(double complex z);
22541 float complex catanhf(float complex z);
22542 long double complex catanhl(long double complex z);
22543 double complex ccosh(double complex z);
22544 float complex ccoshf(float complex z);
22545 long double complex ccoshl(long double complex z);
22546 double complex csinh(double complex z);
22547 float complex csinhf(float complex z);
22548 long double complex csinhl(long double complex z);
22549 double complex ctanh(double complex z);
22550 float complex ctanhf(float complex z);
22551 long double complex ctanhl(long double complex z);
22552 double complex cexp(double complex z);
22553 float complex cexpf(float complex z);
22554 long double complex cexpl(long double complex z);
22555 double complex clog(double complex z);
22556 float complex clogf(float complex z);
22557 long double complex clogl(long double complex z);
22558 double cabs(double complex z);
22559 float cabsf(float complex z);
22560 long double cabsl(long double complex z);
22561 double complex cpow(double complex x, double complex y);
22562 float complex cpowf(float complex x, float complex y);
22563 long double complex cpowl(long double complex x,
22564 long double complex y);
22565 double complex csqrt(double complex z);
22566 float complex csqrtf(float complex z);
22567 long double complex csqrtl(long double complex z);
22568 double carg(double complex z);
22569 float cargf(float complex z);
22570 long double cargl(long double complex z);
22571 double cimag(double complex z);
22572 float cimagf(float complex z);
22573 long double cimagl(long double complex z);
22574 double complex CMPLX(double x, double y);
22575 float complex CMPLXF(float x, float y);
22576 long double complex CMPLXL(long double x, long double y);
22577 double complex conj(double complex z);
22578 float complex conjf(float complex z);
22579 long double complex conjl(long double complex z);
22580 double complex cproj(double complex z);
22581 float complex cprojf(float complex z);
22582 long double complex cprojl(long double complex z);
22583 double creal(double complex z);
22584 float crealf(float complex z);
22585 long double creall(long double complex z);</pre>
22587 <a name="B.3" href="#B.3"><h3>B.3 Character handling <ctype.h></h3></a>
22589 int isalnum(int c);
22590 int isalpha(int c);
22591 int isblank(int c);
22592 int iscntrl(int c);
22593 int isdigit(int c);
22594 int isgraph(int c);
22595 int islower(int c);
22596 int isprint(int c);
22597 int ispunct(int c);
22598 int isspace(int c);
22599 int isupper(int c);
22600 int isxdigit(int c);
22601 int tolower(int c);
22602 int toupper(int c);</pre>
22604 <a name="B.4" href="#B.4"><h3>B.4 Errors <errno.h></h3></a>
22606 EDOM EILSEQ ERANGE errno
22607 __STDC_WANT_LIB_EXT1__
22610 <a name="B.5" href="#B.5"><h3>B.5 Floating-point environment <fenv.h></h3></a>
22611 <!--page 492 indent 0-->
22613 fenv_t FE_OVERFLOW FE_TOWARDZERO
22614 fexcept_t FE_UNDERFLOW FE_UPWARD
22615 FE_DIVBYZERO FE_ALL_EXCEPT FE_DFL_ENV
22616 FE_INEXACT FE_DOWNWARD
22617 FE_INVALID FE_TONEAREST
22618 #pragma STDC FENV_ACCESS on-off-switch
22619 int feclearexcept(int excepts);
22620 int fegetexceptflag(fexcept_t *flagp, int excepts);
22621 int feraiseexcept(int excepts);
22622 int fesetexceptflag(const fexcept_t *flagp,
22624 int fetestexcept(int excepts);
22625 int fegetround(void);
22626 int fesetround(int round);
22627 int fegetenv(fenv_t *envp);
22628 int feholdexcept(fenv_t *envp);
22629 int fesetenv(const fenv_t *envp);
22630 int feupdateenv(const fenv_t *envp);</pre>
22632 <a name="B.6" href="#B.6"><h3>B.6 Characteristics of floating types <float.h></h3></a>
22634 FLT_ROUNDS DBL_DIG FLT_MAX
22635 FLT_EVAL_METHOD LDBL_DIG DBL_MAX
22636 FLT_HAS_SUBNORM FLT_MIN_EXP LDBL_MAX
22637 DBL_HAS_SUBNORM DBL_MIN_EXP FLT_EPSILON
22638 LDBL_HAS_SUBNORM LDBL_MIN_EXP DBL_EPSILON
22639 FLT_RADIX FLT_MIN_10_EXP LDBL_EPSILON
22640 FLT_MANT_DIG DBL_MIN_10_EXP FLT_MIN
22641 DBL_MANT_DIG LDBL_MIN_10_EXP DBL_MIN
22642 LDBL_MANT_DIG FLT_MAX_EXP LDBL_MIN
22643 FLT_DECIMAL_DIG DBL_MAX_EXP FLT_TRUE_MIN
22644 DBL_DECIMAL_DIG LDBL_MAX_EXP DBL_TRUE_MIN
22645 LDBL_DECIMAL_DIG FLT_MAX_10_EXP LDBL_TRUE_MIN
22646 DECIMAL_DIG DBL_MAX_10_EXP
22647 FLT_DIG LDBL_MAX_10_EXP</pre>
22649 <a name="B.7" href="#B.7"><h3>B.7 Format conversion of integer types <inttypes.h></h3></a>
22650 <!--page 493 indent 0-->
22653 PRIdN PRIdLEASTN PRIdFASTN PRIdMAX PRIdPTR
22654 PRIiN PRIiLEASTN PRIiFASTN PRIiMAX PRIiPTR
22655 PRIoN PRIoLEASTN PRIoFASTN PRIoMAX PRIoPTR
22656 PRIuN PRIuLEASTN PRIuFASTN PRIuMAX PRIuPTR
22657 PRIxN PRIxLEASTN PRIxFASTN PRIxMAX PRIxPTR
22658 PRIXN PRIXLEASTN PRIXFASTN PRIXMAX PRIXPTR
22659 SCNdN SCNdLEASTN SCNdFASTN SCNdMAX SCNdPTR
22660 SCNiN SCNiLEASTN SCNiFASTN SCNiMAX SCNiPTR
22661 SCNoN SCNoLEASTN SCNoFASTN SCNoMAX SCNoPTR
22662 SCNuN SCNuLEASTN SCNuFASTN SCNuMAX SCNuPTR
22663 SCNxN SCNxLEASTN SCNxFASTN SCNxMAX SCNxPTR
22664 intmax_t imaxabs(intmax_t j);
22665 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
22666 intmax_t strtoimax(const char * restrict nptr,
22667 char ** restrict endptr, int base);
22668 uintmax_t strtoumax(const char * restrict nptr,
22669 char ** restrict endptr, int base);
22670 intmax_t wcstoimax(const wchar_t * restrict nptr,
22671 wchar_t ** restrict endptr, int base);
22672 uintmax_t wcstoumax(const wchar_t * restrict nptr,
22673 wchar_t ** restrict endptr, int base);</pre>
22675 <a name="B.8" href="#B.8"><h3>B.8 Alternative spellings <iso646.h></h3></a>
22677 and bitor not_eq xor
22678 and_eq compl or xor_eq
22679 bitand not or_eq</pre>
22681 <a name="B.9" href="#B.9"><h3>B.9 Sizes of integer types <limits.h></h3></a>
22683 CHAR_BIT CHAR_MAX INT_MIN ULONG_MAX
22684 SCHAR_MIN MB_LEN_MAX INT_MAX LLONG_MIN
22685 SCHAR_MAX SHRT_MIN UINT_MAX LLONG_MAX
22686 UCHAR_MAX SHRT_MAX LONG_MIN ULLONG_MAX
22687 CHAR_MIN USHRT_MAX LONG_MAX</pre>
22689 <a name="B.10" href="#B.10"><h3>B.10 Localization <locale.h></h3></a>
22691 struct lconv LC_ALL LC_CTYPE LC_NUMERIC
22692 NULL LC_COLLATE LC_MONETARY LC_TIME
22693 char *setlocale(int category, const char *locale);
22694 struct lconv *localeconv(void);</pre>
22696 <a name="B.11" href="#B.11"><h3>B.11 Mathematics <math.h></h3></a>
22697 <!--page 494 indent -1-->
22698 <!--page 495 indent -1-->
22699 <!--page 496 indent -1-->
22700 <!--page 497 indent -1-->
22701 <!--page 498 indent 0-->
22703 float_t FP_INFINITE FP_FAST_FMAL
22704 double_t FP_NAN FP_ILOGB0
22705 HUGE_VAL FP_NORMAL FP_ILOGBNAN
22706 HUGE_VALF FP_SUBNORMAL MATH_ERRNO
22707 HUGE_VALL FP_ZERO MATH_ERREXCEPT
22708 INFINITY FP_FAST_FMA math_errhandling
22710 #pragma STDC FP_CONTRACT on-off-switch
22711 int fpclassify(real-floating x);
22712 int isfinite(real-floating x);
22713 int isinf(real-floating x);
22714 int isnan(real-floating x);
22715 int isnormal(real-floating x);
22716 int signbit(real-floating x);
22717 double acos(double x);
22718 float acosf(float x);
22719 long double acosl(long double x);
22720 double asin(double x);
22721 float asinf(float x);
22722 long double asinl(long double x);
22723 double atan(double x);
22724 float atanf(float x);
22725 long double atanl(long double x);
22726 double atan2(double y, double x);
22727 float atan2f(float y, float x);
22728 long double atan2l(long double y, long double x);
22729 double cos(double x);
22730 float cosf(float x);
22731 long double cosl(long double x);
22732 double sin(double x);
22733 float sinf(float x);
22734 long double sinl(long double x);
22735 double tan(double x);
22736 float tanf(float x);
22737 long double tanl(long double x);
22738 double acosh(double x);
22739 float acoshf(float x);
22740 long double acoshl(long double x);
22741 double asinh(double x);
22742 float asinhf(float x);
22743 long double asinhl(long double x);
22744 double atanh(double x);
22745 float atanhf(float x);
22746 long double atanhl(long double x);
22747 double cosh(double x);
22748 float coshf(float x);
22749 long double coshl(long double x);
22750 double sinh(double x);
22751 float sinhf(float x);
22752 long double sinhl(long double x);
22753 double tanh(double x);
22754 float tanhf(float x);
22755 long double tanhl(long double x);
22756 double exp(double x);
22757 float expf(float x);
22758 long double expl(long double x);
22759 double exp2(double x);
22760 float exp2f(float x);
22761 long double exp2l(long double x);
22762 double expm1(double x);
22763 float expm1f(float x);
22764 long double expm1l(long double x);
22765 double frexp(double value, int *exp);
22766 float frexpf(float value, int *exp);
22767 long double frexpl(long double value, int *exp);
22768 int ilogb(double x);
22769 int ilogbf(float x);
22770 int ilogbl(long double x);
22771 double ldexp(double x, int exp);
22772 float ldexpf(float x, int exp);
22773 long double ldexpl(long double x, int exp);
22774 double log(double x);
22775 float logf(float x);
22776 long double logl(long double x);
22777 double log10(double x);
22778 float log10f(float x);
22779 long double log10l(long double x);
22780 double log1p(double x);
22781 float log1pf(float x);
22782 long double log1pl(long double x);
22783 double log2(double x);
22784 float log2f(float x);
22785 long double log2l(long double x);
22786 double logb(double x);
22787 float logbf(float x);
22788 long double logbl(long double x);
22789 double modf(double value, double *iptr);
22790 float modff(float value, float *iptr);
22791 long double modfl(long double value, long double *iptr);
22792 double scalbn(double x, int n);
22793 float scalbnf(float x, int n);
22794 long double scalbnl(long double x, int n);
22795 double scalbln(double x, long int n);
22796 float scalblnf(float x, long int n);
22797 long double scalblnl(long double x, long int n);
22798 double cbrt(double x);
22799 float cbrtf(float x);
22800 long double cbrtl(long double x);
22801 double fabs(double x);
22802 float fabsf(float x);
22803 long double fabsl(long double x);
22804 double hypot(double x, double y);
22805 float hypotf(float x, float y);
22806 long double hypotl(long double x, long double y);
22807 double pow(double x, double y);
22808 float powf(float x, float y);
22809 long double powl(long double x, long double y);
22810 double sqrt(double x);
22811 float sqrtf(float x);
22812 long double sqrtl(long double x);
22813 double erf(double x);
22814 float erff(float x);
22815 long double erfl(long double x);
22816 double erfc(double x);
22817 float erfcf(float x);
22818 long double erfcl(long double x);
22819 double lgamma(double x);
22820 float lgammaf(float x);
22821 long double lgammal(long double x);
22822 double tgamma(double x);
22823 float tgammaf(float x);
22824 long double tgammal(long double x);
22825 double ceil(double x);
22826 float ceilf(float x);
22827 long double ceill(long double x);
22828 double floor(double x);
22829 float floorf(float x);
22830 long double floorl(long double x);
22831 double nearbyint(double x);
22832 float nearbyintf(float x);
22833 long double nearbyintl(long double x);
22834 double rint(double x);
22835 float rintf(float x);
22836 long double rintl(long double x);
22837 long int lrint(double x);
22838 long int lrintf(float x);
22839 long int lrintl(long double x);
22840 long long int llrint(double x);
22841 long long int llrintf(float x);
22842 long long int llrintl(long double x);
22843 double round(double x);
22844 float roundf(float x);
22845 long double roundl(long double x);
22846 long int lround(double x);
22847 long int lroundf(float x);
22848 long int lroundl(long double x);
22849 long long int llround(double x);
22850 long long int llroundf(float x);
22851 long long int llroundl(long double x);
22852 double trunc(double x);
22853 float truncf(float x);
22854 long double truncl(long double x);
22855 double fmod(double x, double y);
22856 float fmodf(float x, float y);
22857 long double fmodl(long double x, long double y);
22858 double remainder(double x, double y);
22859 float remainderf(float x, float y);
22860 long double remainderl(long double x, long double y);
22861 double remquo(double x, double y, int *quo);
22862 float remquof(float x, float y, int *quo);
22863 long double remquol(long double x, long double y,
22865 double copysign(double x, double y);
22866 float copysignf(float x, float y);
22867 long double copysignl(long double x, long double y);
22868 double nan(const char *tagp);
22869 float nanf(const char *tagp);
22870 long double nanl(const char *tagp);
22871 double nextafter(double x, double y);
22872 float nextafterf(float x, float y);
22873 long double nextafterl(long double x, long double y);
22874 double nexttoward(double x, long double y);
22875 float nexttowardf(float x, long double y);
22876 long double nexttowardl(long double x, long double y);
22877 double fdim(double x, double y);
22878 float fdimf(float x, float y);
22879 long double fdiml(long double x, long double y);
22880 double fmax(double x, double y);
22881 float fmaxf(float x, float y);
22882 long double fmaxl(long double x, long double y);
22883 double fmin(double x, double y);
22884 float fminf(float x, float y);
22885 long double fminl(long double x, long double y);
22886 double fma(double x, double y, double z);
22887 float fmaf(float x, float y, float z);
22888 long double fmal(long double x, long double y,
22890 int isgreater(real-floating x, real-floating y);
22891 int isgreaterequal(real-floating x, real-floating y);
22892 int isless(real-floating x, real-floating y);
22893 int islessequal(real-floating x, real-floating y);
22894 int islessgreater(real-floating x, real-floating y);
22895 int isunordered(real-floating x, real-floating y);</pre>
22897 <a name="B.12" href="#B.12"><h3>B.12 Nonlocal jumps <setjmp.h></h3></a>
22900 int setjmp(jmp_buf env);
22901 _Noreturn void longjmp(jmp_buf env, int val);</pre>
22903 <a name="B.13" href="#B.13"><h3>B.13 Signal handling <signal.h></h3></a>
22904 <!--page 499 indent 0-->
22906 sig_atomic_t SIG_IGN SIGILL SIGTERM
22907 SIG_DFL SIGABRT SIGINT
22908 SIG_ERR SIGFPE SIGSEGV
22909 void (*signal(int sig, void (*func)(int)))(int);
22910 int raise(int sig);</pre>
22912 <a name="B.14" href="#B.14"><h3>B.14 Alignment <stdalign.h></h3></a>
22915 __alignas_is_defined</pre>
22917 <a name="B.15" href="#B.15"><h3>B.15 Variable arguments <stdarg.h></h3></a>
22920 type va_arg(va_list ap, type);
22921 void va_copy(va_list dest, va_list src);
22922 void va_end(va_list ap);
22923 void va_start(va_list ap, parmN);</pre>
22925 <a name="B.16" href="#B.16"><h3>B.16 Atomics <stdatomic.h></h3></a>
22926 <!--page 500 indent -1-->
22927 <!--page 501 indent 0-->
22929 ATOMIC_CHAR_LOCK_FREE atomic_uint
22930 ATOMIC_CHAR16_T_LOCK_FREE atomic_long
22931 ATOMIC_CHAR32_T_LOCK_FREE atomic_ulong
22932 ATOMIC_WCHAR_T_LOCK_FREE atomic_llong
22933 ATOMIC_SHORT_LOCK_FREE atomic_ullong
22934 ATOMIC_INT_LOCK_FREE atomic_char16_t
22935 ATOMIC_LONG_LOCK_FREE atomic_char32_t
22936 ATOMIC_LLONG_LOCK_FREE atomic_wchar_t
22937 ATOMIC_ADDRESS_LOCK_FREE atomic_int_least8_t
22938 ATOMIC_FLAG_INIT atomic_uint_least8_t
22939 memory_order atomic_int_least16_t
22940 atomic_flag atomic_uint_least16_t
22941 atomic_bool atomic_int_least32_t
22942 atomic_address atomic_uint_least32_t
22943 memory_order_relaxed atomic_int_least64_t
22944 memory_order_consume atomic_uint_least64_t
22945 memory_order_acquire atomic_int_fast8_t
22946 memory_order_release atomic_uint_fast8_t
22947 memory_order_acq_rel atomic_int_fast16_t
22948 memory_order_seq_cst atomic_uint_fast16_t
22949 atomic_char atomic_int_fast32_t
22950 atomic_schar atomic_uint_fast32_t
22951 atomic_uchar atomic_int_fast64_t
22952 atomic_short atomic_uint_fast64_t
22953 atomic_ushort atomic_intptr_t
22954 atomic_int atomic_uintptr_t
22955 atomic_size_t atomic_intmax_t
22956 atomic_ptrdiff_t atomic_uintmax_t
22957 #define ATOMIC_VAR_INIT(C value)
22958 void atomic_init(volatile A *obj, C value);
22959 type kill_dependency(type y);
22960 void atomic_thread_fence(memory_order order);
22961 void atomic_signal_fence(memory_order order);
22962 _Bool atomic_is_lock_free(atomic_type const volatile *obj);
22963 void atomic_store(volatile A *object, C desired);
22964 void atomic_store_explicit(volatile A *object,
22965 C desired, memory_order order);
22966 C atomic_load(volatile A *object);
22967 C atomic_load_explicit(volatile A *object,
22968 memory_order order);
22969 C atomic_exchange(volatile A *object, C desired);
22970 C atomic_exchange_explicit(volatile A *object,
22971 C desired, memory_order order);
22972 _Bool atomic_compare_exchange_strong(volatile A *object,
22973 C *expected, C desired);
22974 _Bool atomic_compare_exchange_strong_explicit(
22975 volatile A *object, C *expected, C desired,
22976 memory_order success, memory_order failure);
22977 _Bool atomic_compare_exchange_weak(volatile A *object,
22978 C *expected, C desired);
22979 _Bool atomic_compare_exchange_weak_explicit(
22980 volatile A *object, C *expected, C desired,
22981 memory_order success, memory_order failure);
22982 C atomic_fetch_key(volatile A *object, M operand);
22983 C atomic_fetch_key_explicit(volatile A *object,
22984 M operand, memory_order order);
22985 bool atomic_flag_test_and_set(
22986 volatile atomic_flag *object);
22987 bool atomic_flag_test_and_set_explicit(
22988 volatile atomic_flag *object, memory_order order);
22989 void atomic_flag_clear(volatile atomic_flag *object);
22990 void atomic_flag_clear_explicit(
22991 volatile atomic_flag *object, memory_order order);</pre>
22993 <a name="B.17" href="#B.17"><h3>B.17 Boolean type and values <stdbool.h></h3></a>
22998 __bool_true_false_are_defined</pre>
23000 <a name="B.18" href="#B.18"><h3>B.18 Common definitions <stddef.h></h3></a>
23002 ptrdiff_t max_align_t NULL
23004 offsetof(type, member-designator)
23005 __STDC_WANT_LIB_EXT1__
23008 <a name="B.19" href="#B.19"><h3>B.19 Integer types <stdint.h></h3></a>
23009 <!--page 502 indent 0-->
23011 intN_t INT_LEASTN_MIN PTRDIFF_MAX
23012 uintN_t INT_LEASTN_MAX SIG_ATOMIC_MIN
23013 int_leastN_t UINT_LEASTN_MAX SIG_ATOMIC_MAX
23014 uint_leastN_t INT_FASTN_MIN SIZE_MAX
23015 int_fastN_t INT_FASTN_MAX WCHAR_MIN
23016 uint_fastN_t UINT_FASTN_MAX WCHAR_MAX
23017 intptr_t INTPTR_MIN WINT_MIN
23018 uintptr_t INTPTR_MAX WINT_MAX
23019 intmax_t UINTPTR_MAX INTN_C(value)
23020 uintmax_t INTMAX_MIN UINTN_C(value)
23021 INTN_MIN INTMAX_MAX INTMAX_C(value)
23022 INTN_MAX UINTMAX_MAX UINTMAX_C(value)
23023 UINTN_MAX PTRDIFF_MIN
23024 __STDC_WANT_LIB_EXT1__
23027 <a name="B.20" href="#B.20"><h3>B.20 Input/output <stdio.h></h3></a>
23028 <!--page 503 indent -1-->
23029 <!--page 504 indent -1-->
23030 <!--page 505 indent 0-->
23032 size_t _IOLBF FILENAME_MAX TMP_MAX
23033 FILE _IONBF L_tmpnam stderr
23034 fpos_t BUFSIZ SEEK_CUR stdin
23035 NULL EOF SEEK_END stdout
23036 _IOFBF FOPEN_MAX SEEK_SET
23037 int remove(const char *filename);
23038 int rename(const char *old, const char *new);
23039 FILE *tmpfile(void);
23040 char *tmpnam(char *s);
23041 int fclose(FILE *stream);
23042 int fflush(FILE *stream);
23043 FILE *fopen(const char * restrict filename,
23044 const char * restrict mode);
23045 FILE *freopen(const char * restrict filename,
23046 const char * restrict mode,
23047 FILE * restrict stream);
23048 void setbuf(FILE * restrict stream,
23049 char * restrict buf);
23050 int setvbuf(FILE * restrict stream,
23051 char * restrict buf,
23052 int mode, size_t size);
23053 int fprintf(FILE * restrict stream,
23054 const char * restrict format, ...);
23055 int fscanf(FILE * restrict stream,
23056 const char * restrict format, ...);
23057 int printf(const char * restrict format, ...);
23058 int scanf(const char * restrict format, ...);
23059 int snprintf(char * restrict s, size_t n,
23060 const char * restrict format, ...);
23061 int sprintf(char * restrict s,
23062 const char * restrict format, ...);
23063 int sscanf(const char * restrict s,
23064 const char * restrict format, ...);
23065 int vfprintf(FILE * restrict stream,
23066 const char * restrict format, va_list arg);
23067 int vfscanf(FILE * restrict stream,
23068 const char * restrict format, va_list arg);
23069 int vprintf(const char * restrict format, va_list arg);
23070 int vscanf(const char * restrict format, va_list arg);
23071 int vsnprintf(char * restrict s, size_t n,
23072 const char * restrict format, va_list arg);
23073 int vsprintf(char * restrict s,
23074 const char * restrict format, va_list arg);
23075 int vsscanf(const char * restrict s,
23076 const char * restrict format, va_list arg);
23077 int fgetc(FILE *stream);
23078 char *fgets(char * restrict s, int n,
23079 FILE * restrict stream);
23080 int fputc(int c, FILE *stream);
23081 int fputs(const char * restrict s,
23082 FILE * restrict stream);
23083 int getc(FILE *stream);
23085 int putc(int c, FILE *stream); *
23086 int putchar(int c);
23087 int puts(const char *s);
23088 int ungetc(int c, FILE *stream);
23089 size_t fread(void * restrict ptr,
23090 size_t size, size_t nmemb,
23091 FILE * restrict stream);
23092 size_t fwrite(const void * restrict ptr,
23093 size_t size, size_t nmemb,
23094 FILE * restrict stream);
23095 int fgetpos(FILE * restrict stream,
23096 fpos_t * restrict pos);
23097 int fseek(FILE *stream, long int offset, int whence);
23098 int fsetpos(FILE *stream, const fpos_t *pos);
23099 long int ftell(FILE *stream);
23100 void rewind(FILE *stream);
23101 void clearerr(FILE *stream);
23102 int feof(FILE *stream);
23103 int ferror(FILE *stream);
23104 void perror(const char *s);
23105 __STDC_WANT_LIB_EXT1__
23106 L_tmpnam_s TMP_MAX_S errno_t rsize_t
23107 errno_t tmpfile_s(FILE * restrict * restrict streamptr);
23108 errno_t tmpnam_s(char *s, rsize_t maxsize);
23109 errno_t fopen_s(FILE * restrict * restrict streamptr,
23110 const char * restrict filename,
23111 const char * restrict mode);
23112 errno_t freopen_s(FILE * restrict * restrict newstreamptr,
23113 const char * restrict filename,
23114 const char * restrict mode,
23115 FILE * restrict stream);
23116 int fprintf_s(FILE * restrict stream,
23117 const char * restrict format, ...);
23118 int fscanf_s(FILE * restrict stream,
23119 const char * restrict format, ...);
23120 int printf_s(const char * restrict format, ...);
23121 int scanf_s(const char * restrict format, ...);
23122 int snprintf_s(char * restrict s, rsize_t n,
23123 const char * restrict format, ...);
23124 int sprintf_s(char * restrict s, rsize_t n,
23125 const char * restrict format, ...);
23126 int sscanf_s(const char * restrict s,
23127 const char * restrict format, ...);
23128 int vfprintf_s(FILE * restrict stream,
23129 const char * restrict format,
23131 int vfscanf_s(FILE * restrict stream,
23132 const char * restrict format,
23134 int vprintf_s(const char * restrict format,
23136 int vscanf_s(const char * restrict format,
23138 int vsnprintf_s(char * restrict s, rsize_t n,
23139 const char * restrict format,
23141 int vsprintf_s(char * restrict s, rsize_t n,
23142 const char * restrict format,
23144 int vsscanf_s(const char * restrict s,
23145 const char * restrict format,
23147 char *gets_s(char *s, rsize_t n);</pre>
23149 <a name="B.21" href="#B.21"><h3>B.21 General utilities <stdlib.h></h3></a>
23150 <!--page 506 indent -1-->
23151 <!--page 507 indent 0-->
23153 size_t ldiv_t EXIT_FAILURE MB_CUR_MAX
23154 wchar_t lldiv_t EXIT_SUCCESS
23155 div_t NULL RAND_MAX
23156 double atof(const char *nptr);
23157 int atoi(const char *nptr);
23158 long int atol(const char *nptr);
23159 long long int atoll(const char *nptr);
23160 double strtod(const char * restrict nptr,
23161 char ** restrict endptr);
23162 float strtof(const char * restrict nptr,
23163 char ** restrict endptr);
23164 long double strtold(const char * restrict nptr,
23165 char ** restrict endptr);
23166 long int strtol(const char * restrict nptr,
23167 char ** restrict endptr, int base);
23168 long long int strtoll(const char * restrict nptr,
23169 char ** restrict endptr, int base);
23170 unsigned long int strtoul(
23171 const char * restrict nptr,
23172 char ** restrict endptr, int base);
23173 unsigned long long int strtoull(
23174 const char * restrict nptr,
23175 char ** restrict endptr, int base);
23177 void srand(unsigned int seed);
23178 void *aligned_alloc(size_t alignment, size_t size);
23179 void *calloc(size_t nmemb, size_t size);
23180 void free(void *ptr);
23181 void *malloc(size_t size);
23182 void *realloc(void *ptr, size_t size);
23183 _Noreturn void abort(void);
23184 int atexit(void (*func)(void));
23185 int at_quick_exit(void (*func)(void));
23186 _Noreturn void exit(int status);
23187 _Noreturn void _Exit(int status);
23188 char *getenv(const char *name);
23189 _Noreturn void quick_exit(int status);
23190 int system(const char *string);
23191 void *bsearch(const void *key, const void *base,
23192 size_t nmemb, size_t size,
23193 int (*compar)(const void *, const void *));
23194 void qsort(void *base, size_t nmemb, size_t size,
23195 int (*compar)(const void *, const void *));
23197 long int labs(long int j);
23198 long long int llabs(long long int j);
23199 div_t div(int numer, int denom);
23200 ldiv_t ldiv(long int numer, long int denom);
23201 lldiv_t lldiv(long long int numer,
23202 long long int denom);
23203 int mblen(const char *s, size_t n);
23204 int mbtowc(wchar_t * restrict pwc,
23205 const char * restrict s, size_t n);
23206 int wctomb(char *s, wchar_t wchar);
23207 size_t mbstowcs(wchar_t * restrict pwcs,
23208 const char * restrict s, size_t n);
23209 size_t wcstombs(char * restrict s,
23210 const wchar_t * restrict pwcs, size_t n);
23211 __STDC_WANT_LIB_EXT1__
23214 constraint_handler_t
23215 constraint_handler_t set_constraint_handler_s(
23216 constraint_handler_t handler);
23217 void abort_handler_s(
23218 const char * restrict msg,
23219 void * restrict ptr,
23221 void ignore_handler_s(
23222 const char * restrict msg,
23223 void * restrict ptr,
23225 errno_t getenv_s(size_t * restrict len,
23226 char * restrict value, rsize_t maxsize,
23227 const char * restrict name);
23228 void *bsearch_s(const void *key, const void *base,
23229 rsize_t nmemb, rsize_t size,
23230 int (*compar)(const void *k, const void *y,
23233 errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size,
23234 int (*compar)(const void *x, const void *y,
23237 errno_t wctomb_s(int * restrict status,
23241 errno_t mbstowcs_s(size_t * restrict retval,
23242 wchar_t * restrict dst, rsize_t dstmax,
23243 const char * restrict src, rsize_t len);
23244 errno_t wcstombs_s(size_t * restrict retval,
23245 char * restrict dst, rsize_t dstmax,
23246 const wchar_t * restrict src, rsize_t len);</pre>
23248 <a name="B.22" href="#B.22"><h3>B.22 String handling <string.h></h3></a>
23249 <!--page 508 indent -1-->
23250 <!--page 509 indent 0-->
23254 void *memcpy(void * restrict s1,
23255 const void * restrict s2, size_t n);
23256 void *memmove(void *s1, const void *s2, size_t n);
23257 char *strcpy(char * restrict s1,
23258 const char * restrict s2);
23259 char *strncpy(char * restrict s1,
23260 const char * restrict s2, size_t n);
23261 char *strcat(char * restrict s1,
23262 const char * restrict s2);
23263 char *strncat(char * restrict s1,
23264 const char * restrict s2, size_t n);
23265 int memcmp(const void *s1, const void *s2, size_t n);
23266 int strcmp(const char *s1, const char *s2);
23267 int strcoll(const char *s1, const char *s2);
23268 int strncmp(const char *s1, const char *s2, size_t n);
23269 size_t strxfrm(char * restrict s1,
23270 const char * restrict s2, size_t n);
23271 void *memchr(const void *s, int c, size_t n);
23272 char *strchr(const char *s, int c);
23273 size_t strcspn(const char *s1, const char *s2);
23274 char *strpbrk(const char *s1, const char *s2);
23275 char *strrchr(const char *s, int c);
23276 size_t strspn(const char *s1, const char *s2);
23277 char *strstr(const char *s1, const char *s2);
23278 char *strtok(char * restrict s1,
23279 const char * restrict s2);
23280 void *memset(void *s, int c, size_t n);
23281 char *strerror(int errnum);
23282 size_t strlen(const char *s);
23283 __STDC_WANT_LIB_EXT1__
23286 errno_t memcpy_s(void * restrict s1, rsize_t s1max,
23287 const void * restrict s2, rsize_t n);
23288 errno_t memmove_s(void *s1, rsize_t s1max,
23289 const void *s2, rsize_t n);
23290 errno_t strcpy_s(char * restrict s1,
23292 const char * restrict s2);
23293 errno_t strncpy_s(char * restrict s1,
23295 const char * restrict s2,
23297 errno_t strcat_s(char * restrict s1,
23299 const char * restrict s2);
23300 errno_t strncat_s(char * restrict s1,
23302 const char * restrict s2,
23304 char *strtok_s(char * restrict s1,
23305 rsize_t * restrict s1max,
23306 const char * restrict s2,
23307 char ** restrict ptr);
23308 errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)
23309 errno_t strerror_s(char *s, rsize_t maxsize,
23311 size_t strerrorlen_s(errno_t errnum);
23312 size_t strnlen_s(const char *s, size_t maxsize);</pre>
23314 <a name="B.23" href="#B.23"><h3>B.23 Type-generic math <tgmath.h></h3></a>
23316 acos sqrt fmod nextafter
23317 asin fabs frexp nexttoward
23318 atan atan2 hypot remainder
23319 acosh cbrt ilogb remquo
23320 asinh ceil ldexp rint
23321 atanh copysign lgamma round
23322 cos erf llrint scalbn
23323 sin erfc llround scalbln
23324 tan exp2 log10 tgamma
23325 cosh expm1 log1p trunc
23326 sinh fdim log2 carg
23327 tanh floor logb cimag
23329 log fmax lround cproj
23330 pow fmin nearbyint creal</pre>
23332 <a name="B.24" href="#B.24"><h3>B.24 Threads <threads.h></h3></a>
23333 <!--page 510 indent 0-->
23335 ONCE_FLAG_INIT mtx_plain
23336 TSS_DTOR_ITERATIONS mtx_recursive
23341 tss_dtor_t thrd_busy
23342 thrd_start_t thrd_error
23343 once_flag thrd_nomem
23345 void call_once(once_flag *flag, void (*func)(void));
23346 int cnd_broadcast(cnd_t *cond);
23347 void cnd_destroy(cnd_t *cond);
23348 int cnd_init(cnd_t *cond);
23349 int cnd_signal(cnd_t *cond);
23350 int cnd_timedwait(cnd_t *cond, mtx_t *mtx,
23352 int cnd_wait(cnd_t *cond, mtx_t *mtx);
23353 void mtx_destroy(mtx_t *mtx);
23354 int mtx_init(mtx_t *mtx, int type);
23355 int mtx_lock(mtx_t *mtx);
23356 int mtx_timedlock(mtx_t *mtx, const xtime *xt);
23357 int mtx_trylock(mtx_t *mtx);
23358 int mtx_unlock(mtx_t *mtx);
23359 int thrd_create(thrd_t *thr, thrd_start_t func,
23361 thrd_t thrd_current(void);
23362 int thrd_detach(thrd_t thr);
23363 int thrd_equal(thrd_t thr0, thrd_t thr1);
23364 void thrd_exit(int res);
23365 int thrd_join(thrd_t thr, int *res);
23366 void thrd_sleep(const xtime *xt);
23367 void thrd_yield(void);
23368 int tss_create(tss_t *key, tss_dtor_t dtor);
23369 void tss_delete(tss_t key);
23370 void *tss_get(tss_t key);
23371 int tss_set(tss_t key, void *val);
23372 int xtime_get(xtime *xt, int base);</pre>
23374 <a name="B.25" href="#B.25"><h3>B.25 Date and time <time.h></h3></a>
23375 <!--page 511 indent 0-->
23378 CLOCKS_PER_SEC clock_t struct tm
23379 clock_t clock(void);
23380 double difftime(time_t time1, time_t time0);
23381 time_t mktime(struct tm *timeptr);
23382 time_t time(time_t *timer);
23383 char *asctime(const struct tm *timeptr);
23384 char *ctime(const time_t *timer);
23385 struct tm *gmtime(const time_t *timer);
23386 struct tm *localtime(const time_t *timer);
23387 size_t strftime(char * restrict s,
23389 const char * restrict format,
23390 const struct tm * restrict timeptr);
23391 __STDC_WANT_LIB_EXT1__
23394 errno_t asctime_s(char *s, rsize_t maxsize,
23395 const struct tm *timeptr);
23396 errno_t ctime_s(char *s, rsize_t maxsize,
23397 const time_t *timer);
23398 struct tm *gmtime_s(const time_t * restrict timer,
23399 struct tm * restrict result);
23400 struct tm *localtime_s(const time_t * restrict timer,
23401 struct tm * restrict result);</pre>
23403 <a name="B.26" href="#B.26"><h3>B.26 Unicode utilities <uchar.h></h3></a>
23405 mbstate_t size_t char16_t char32_t
23406 size_t mbrtoc16(char16_t * restrict pc16,
23407 const char * restrict s, size_t n,
23408 mbstate_t * restrict ps);
23409 size_t c16rtomb(char * restrict s, char16_t c16,
23410 mbstate_t * restrict ps);
23411 size_t mbrtoc32(char32_t * restrict pc32,
23412 const char * restrict s, size_t n,
23413 mbstate_t * restrict ps);
23414 size_t c32rtomb(char * restrict s, char32_t c32,
23415 mbstate_t * restrict ps);</pre>
23417 <a name="B.27" href="#B.27"><h3>B.27 Extended multibyte/wide character utilities <wchar.h></h3></a>
23418 <!--page 512 indent -1-->
23419 <!--page 513 indent -1-->
23420 <!--page 514 indent -1-->
23421 <!--page 515 indent -1-->
23422 <!--page 516 indent 0-->
23424 wchar_t wint_t WCHAR_MAX
23425 size_t struct tm WCHAR_MIN
23426 mbstate_t NULL WEOF
23427 int fwprintf(FILE * restrict stream,
23428 const wchar_t * restrict format, ...);
23429 int fwscanf(FILE * restrict stream,
23430 const wchar_t * restrict format, ...);
23431 int swprintf(wchar_t * restrict s, size_t n,
23432 const wchar_t * restrict format, ...);
23433 int swscanf(const wchar_t * restrict s,
23434 const wchar_t * restrict format, ...);
23435 int vfwprintf(FILE * restrict stream,
23436 const wchar_t * restrict format, va_list arg);
23437 int vfwscanf(FILE * restrict stream,
23438 const wchar_t * restrict format, va_list arg);
23439 int vswprintf(wchar_t * restrict s, size_t n,
23440 const wchar_t * restrict format, va_list arg);
23441 int vswscanf(const wchar_t * restrict s,
23442 const wchar_t * restrict format, va_list arg);
23443 int vwprintf(const wchar_t * restrict format,
23445 int vwscanf(const wchar_t * restrict format,
23447 int wprintf(const wchar_t * restrict format, ...);
23448 int wscanf(const wchar_t * restrict format, ...);
23449 wint_t fgetwc(FILE *stream);
23450 wchar_t *fgetws(wchar_t * restrict s, int n,
23451 FILE * restrict stream);
23452 wint_t fputwc(wchar_t c, FILE *stream);
23453 int fputws(const wchar_t * restrict s,
23454 FILE * restrict stream);
23455 int fwide(FILE *stream, int mode);
23456 wint_t getwc(FILE *stream);
23457 wint_t getwchar(void);
23458 wint_t putwc(wchar_t c, FILE *stream);
23459 wint_t putwchar(wchar_t c);
23460 wint_t ungetwc(wint_t c, FILE *stream);
23461 double wcstod(const wchar_t * restrict nptr,
23462 wchar_t ** restrict endptr);
23463 float wcstof(const wchar_t * restrict nptr,
23464 wchar_t ** restrict endptr);
23465 long double wcstold(const wchar_t * restrict nptr,
23466 wchar_t ** restrict endptr);
23467 long int wcstol(const wchar_t * restrict nptr,
23468 wchar_t ** restrict endptr, int base);
23469 long long int wcstoll(const wchar_t * restrict nptr,
23470 wchar_t ** restrict endptr, int base);
23471 unsigned long int wcstoul(const wchar_t * restrict nptr,
23472 wchar_t ** restrict endptr, int base);
23473 unsigned long long int wcstoull(
23474 const wchar_t * restrict nptr,
23475 wchar_t ** restrict endptr, int base);
23476 wchar_t *wcscpy(wchar_t * restrict s1,
23477 const wchar_t * restrict s2);
23478 wchar_t *wcsncpy(wchar_t * restrict s1,
23479 const wchar_t * restrict s2, size_t n);
23480 wchar_t *wmemcpy(wchar_t * restrict s1,
23481 const wchar_t * restrict s2, size_t n);
23482 wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2,
23484 wchar_t *wcscat(wchar_t * restrict s1,
23485 const wchar_t * restrict s2);
23486 wchar_t *wcsncat(wchar_t * restrict s1,
23487 const wchar_t * restrict s2, size_t n);
23488 int wcscmp(const wchar_t *s1, const wchar_t *s2);
23489 int wcscoll(const wchar_t *s1, const wchar_t *s2);
23490 int wcsncmp(const wchar_t *s1, const wchar_t *s2,
23492 size_t wcsxfrm(wchar_t * restrict s1,
23493 const wchar_t * restrict s2, size_t n);
23494 int wmemcmp(const wchar_t *s1, const wchar_t *s2,
23496 wchar_t *wcschr(const wchar_t *s, wchar_t c);
23497 size_t wcscspn(const wchar_t *s1, const wchar_t *s2);
23498 wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);
23499 wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
23500 size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
23501 wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);
23502 wchar_t *wcstok(wchar_t * restrict s1,
23503 const wchar_t * restrict s2,
23504 wchar_t ** restrict ptr);
23505 wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
23506 size_t wcslen(const wchar_t *s);
23507 wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
23508 size_t wcsftime(wchar_t * restrict s, size_t maxsize,
23509 const wchar_t * restrict format,
23510 const struct tm * restrict timeptr);
23511 wint_t btowc(int c);
23512 int wctob(wint_t c);
23513 int mbsinit(const mbstate_t *ps);
23514 size_t mbrlen(const char * restrict s, size_t n,
23515 mbstate_t * restrict ps);
23516 size_t mbrtowc(wchar_t * restrict pwc,
23517 const char * restrict s, size_t n,
23518 mbstate_t * restrict ps);
23519 size_t wcrtomb(char * restrict s, wchar_t wc,
23520 mbstate_t * restrict ps);
23521 size_t mbsrtowcs(wchar_t * restrict dst,
23522 const char ** restrict src, size_t len,
23523 mbstate_t * restrict ps);
23524 size_t wcsrtombs(char * restrict dst,
23525 const wchar_t ** restrict src, size_t len,
23526 mbstate_t * restrict ps);
23527 __STDC_WANT_LIB_EXT1__
23530 int fwprintf_s(FILE * restrict stream,
23531 const wchar_t * restrict format, ...);
23532 int fwscanf_s(FILE * restrict stream,
23533 const wchar_t * restrict format, ...);
23534 int snwprintf_s(wchar_t * restrict s,
23536 const wchar_t * restrict format, ...);
23537 int swprintf_s(wchar_t * restrict s, rsize_t n,
23538 const wchar_t * restrict format, ...);
23539 int swscanf_s(const wchar_t * restrict s,
23540 const wchar_t * restrict format, ...);
23541 int vfwprintf_s(FILE * restrict stream,
23542 const wchar_t * restrict format,
23544 int vfwscanf_s(FILE * restrict stream,
23545 const wchar_t * restrict format, va_list arg);
23546 int vsnwprintf_s(wchar_t * restrict s,
23548 const wchar_t * restrict format,
23550 int vswprintf_s(wchar_t * restrict s,
23552 const wchar_t * restrict format,
23554 int vswscanf_s(const wchar_t * restrict s,
23555 const wchar_t * restrict format,
23557 int vwprintf_s(const wchar_t * restrict format,
23559 int vwscanf_s(const wchar_t * restrict format,
23561 int wprintf_s(const wchar_t * restrict format, ...);
23562 int wscanf_s(const wchar_t * restrict format, ...);
23563 errno_t wcscpy_s(wchar_t * restrict s1,
23565 const wchar_t * restrict s2);
23566 errno_t wcsncpy_s(wchar_t * restrict s1,
23568 const wchar_t * restrict s2,
23570 errno_t wmemcpy_s(wchar_t * restrict s1,
23572 const wchar_t * restrict s2,
23574 errno_t wmemmove_s(wchar_t *s1, rsize_t s1max,
23575 const wchar_t *s2, rsize_t n);
23576 errno_t wcscat_s(wchar_t * restrict s1,
23578 const wchar_t * restrict s2);
23579 errno_t wcsncat_s(wchar_t * restrict s1,
23581 const wchar_t * restrict s2,
23583 wchar_t *wcstok_s(wchar_t * restrict s1,
23584 rsize_t * restrict s1max,
23585 const wchar_t * restrict s2,
23586 wchar_t ** restrict ptr);
23587 size_t wcsnlen_s(const wchar_t *s, size_t maxsize);
23588 errno_t wcrtomb_s(size_t * restrict retval,
23589 char * restrict s, rsize_t smax,
23590 wchar_t wc, mbstate_t * restrict ps);
23591 errno_t mbsrtowcs_s(size_t * restrict retval,
23592 wchar_t * restrict dst, rsize_t dstmax,
23593 const char ** restrict src, rsize_t len,
23594 mbstate_t * restrict ps);
23595 errno_t wcsrtombs_s(size_t * restrict retval,
23596 char * restrict dst, rsize_t dstmax,
23597 const wchar_t ** restrict src, rsize_t len,
23598 mbstate_t * restrict ps);</pre>
23600 <a name="B.28" href="#B.28"><h3>B.28 Wide character classification and mapping utilities <wctype.h></h3></a>
23601 <!--page 517 indent 4-->
23603 wint_t wctrans_t wctype_t WEOF
23604 int iswalnum(wint_t wc);
23605 int iswalpha(wint_t wc);
23606 int iswblank(wint_t wc);
23607 int iswcntrl(wint_t wc);
23608 int iswdigit(wint_t wc);
23609 int iswgraph(wint_t wc);
23610 int iswlower(wint_t wc);
23611 int iswprint(wint_t wc);
23612 int iswpunct(wint_t wc);
23613 int iswspace(wint_t wc);
23614 int iswupper(wint_t wc);
23615 int iswxdigit(wint_t wc);
23616 int iswctype(wint_t wc, wctype_t desc);
23617 wctype_t wctype(const char *property);
23618 wint_t towlower(wint_t wc);
23619 wint_t towupper(wint_t wc);
23620 wint_t towctrans(wint_t wc, wctrans_t desc);
23621 wctrans_t wctrans(const char *property);</pre>
23623 <a name="C" href="#C"><h2>Annex C</h2></a>
23627 Sequence points</pre>
23628 The following are the sequence points described in <a href="#5.1.2.3">5.1.2.3</a>:
23630 <li> Between the evaluations of the function designator and actual arguments in a function
23631 call and the actual call. (<a href="#6.5.2.2">6.5.2.2</a>).
23632 <li> Between the evaluations of the first and second operands of the following operators:
23633 logical AND && (<a href="#6.5.13">6.5.13</a>); logical OR || (<a href="#6.5.14">6.5.14</a>); comma , (<a href="#6.5.17">6.5.17</a>). *
23634 <li> Between the evaluations of the first operand of the conditional ? : operator and
23635 whichever of the second and third operands is evaluated (<a href="#6.5.15">6.5.15</a>).
23636 <li> The end of a full declarator: declarators (<a href="#6.7.6">6.7.6</a>);
23637 <li> Between the evaluation of a full expression and the next full expression to be
23638 evaluated. The following are full expressions: an initializer that is not part of a
23639 compound literal (<a href="#6.7.9">6.7.9</a>); the expression in an expression statement (<a href="#6.8.3">6.8.3</a>); the
23640 controlling expression of a selection statement (if or switch) (<a href="#6.8.4">6.8.4</a>); the
23641 controlling expression of a while or do statement (<a href="#6.8.5">6.8.5</a>); each of the (optional)
23642 expressions of a for statement (<a href="#6.8.5.3">6.8.5.3</a>); the (optional) expression in a return
23643 statement (<a href="#6.8.6.4">6.8.6.4</a>).
23644 <li> Immediately before a library function returns (<a href="#7.1.4">7.1.4</a>).
23645 <li> After the actions associated with each formatted input/output function conversion
23646 specifier (<a href="#7.21.6">7.21.6</a>, <a href="#7.28.2">7.28.2</a>).
23647 <li> Immediately before and immediately after each call to a comparison function, and
23648 also between any call to a comparison function and any movement of the objects
23649 passed as arguments to that call (<a href="#7.22.5">7.22.5</a>).
23650 <!--page 518 indent 4-->
23653 <a name="D" href="#D"><h2>Annex D</h2></a>
23657 Universal character names for identifiers</pre>
23658 This clause lists the hexadecimal code values that are valid in universal character names
23661 <a name="D.1" href="#D.1"><h3>D.1 Ranges of characters allowed</h3></a>
23663 00A8, 00AA, 00AD, 00AF, 00B2-00B5, 00B7-00BA, 00BC-00BE, 00C0-00D6,
23664 00D8-00F6, 00F8-00FF
23666 0100-167F, 1681-180D, 180F-1FFF
23668 200B-200D, 202A-202E, 203F-2040, 2054, 2060-206F
23670 2070-218F, 2460-24FF, 2776-2793, 2C00-2DFF, 2E80-2FFF
23672 3004-3007, 3021-302F, 3031-303F
23676 F900-FD3D, FD40-FDCF, FDF0-FE44, FE47-FFFD
23678 10000-1FFFD, 20000-2FFFD, 30000-3FFFD, 40000-4FFFD, 50000-5FFFD,
23679 60000-6FFFD, 70000-7FFFD, 80000-8FFFD, 90000-9FFFD, A0000-AFFFD,
23680 B0000-BFFFD, C0000-CFFFD, D0000-DFFFD, E0000-EFFFD
23682 <a name="D.2" href="#D.2"><h3>D.2 Ranges of characters disallowed initially</h3></a>
23684 0300-036F, 1DC0-1DFF, 20D0-20FF, FE20-FE2F
23685 <!--page 519 indent 4-->
23687 <a name="E" href="#E"><h2>Annex E</h2></a>
23691 Implementation limits</pre>
23692 The contents of the header <limits.h> are given below, in alphabetical order. The
23693 minimum magnitudes shown shall be replaced by implementation-defined magnitudes
23694 with the same sign. The values shall all be constant expressions suitable for use in #if
23695 preprocessing directives. The components are described further in <a href="#5.2.4.2.1">5.2.4.2.1</a>.
23699 #define CHAR_MAX UCHAR_MAX or SCHAR_MAX
23700 #define CHAR_MIN 0 or SCHAR_MIN
23701 #define INT_MAX +32767
23702 #define INT_MIN -32767
23703 #define LONG_MAX +2147483647
23704 #define LONG_MIN -2147483647
23705 #define LLONG_MAX +9223372036854775807
23706 #define LLONG_MIN -9223372036854775807
23707 #define MB_LEN_MAX 1
23708 #define SCHAR_MAX +127
23709 #define SCHAR_MIN -127
23710 #define SHRT_MAX +32767
23711 #define SHRT_MIN -32767
23712 #define UCHAR_MAX 255
23713 #define USHRT_MAX 65535
23714 #define UINT_MAX 65535
23715 #define ULONG_MAX 4294967295
23716 #define ULLONG_MAX 18446744073709551615</pre>
23717 The contents of the header <float.h> are given below. All integer values, except
23718 FLT_ROUNDS, shall be constant expressions suitable for use in #if preprocessing
23719 directives; all floating values shall be constant expressions. The components are
23720 described further in <a href="#5.2.4.2.2">5.2.4.2.2</a>.
23722 The values given in the following list shall be replaced by implementation-defined
23726 #define FLT_EVAL_METHOD
23727 #define FLT_ROUNDS</pre>
23728 The values given in the following list shall be replaced by implementation-defined
23729 constant expressions that are greater or equal in magnitude (absolute value) to those
23730 shown, with the same sign:
23731 <!--page 520 indent 4-->
23734 #define DLB_DECIMAL_DIG 10
23736 #define DBL_MANT_DIG
23737 #define DBL_MAX_10_EXP +37
23738 #define DBL_MAX_EXP
23739 #define DBL_MIN_10_EXP -37
23740 #define DBL_MIN_EXP
23741 #define DECIMAL_DIG 10
23742 #define FLT_DECIMAL_DIG 6
23744 #define FLT_MANT_DIG
23745 #define FLT_MAX_10_EXP +37
23746 #define FLT_MAX_EXP
23747 #define FLT_MIN_10_EXP -37
23748 #define FLT_MIN_EXP
23749 #define FLT_RADIX 2
23750 #define LDLB_DECIMAL_DIG 10
23751 #define LDBL_DIG 10
23752 #define LDBL_MANT_DIG
23753 #define LDBL_MAX_10_EXP +37
23754 #define LDBL_MAX_EXP
23755 #define LDBL_MIN_10_EXP -37
23756 #define LDBL_MIN_EXP</pre>
23757 The values given in the following list shall be replaced by implementation-defined
23758 constant expressions with values that are greater than or equal to those shown:
23761 #define DBL_MAX 1E+37
23762 #define FLT_MAX 1E+37
23763 #define LDBL_MAX 1E+37</pre>
23764 The values given in the following list shall be replaced by implementation-defined
23765 constant expressions with (positive) values that are less than or equal to those shown:
23766 <!--page 521 indent 4-->
23768 #define DBL_EPSILON 1E-9
23769 #define DBL_MIN 1E-37
23770 #define FLT_EPSILON 1E-5
23771 #define FLT_MIN 1E-37
23772 #define LDBL_EPSILON 1E-9
23773 #define LDBL_MIN 1E-37</pre>
23775 <a name="F" href="#F"><h2>Annex F</h2></a>
23778 IEC 60559 floating-point arithmetic</pre>
23780 <a name="F.1" href="#F.1"><h3>F.1 Introduction</h3></a>
23782 This annex specifies C language support for the IEC 60559 floating-point standard. The
23783 IEC 60559 floating-point standard is specifically Binary floating-point arithmetic for
23784 microprocessor systems, second edition (IEC 60559:1989), previously designated
23785 IEC 559:1989 and as IEEE Standard for Binary Floating-Point Arithmetic
23786 (ANSI/IEEE 754-1985). IEEE Standard for Radix-Independent Floating-Point
23787 Arithmetic (ANSI/IEEE 854-1987) generalizes the binary standard to remove
23788 dependencies on radix and word length. IEC 60559 generally refers to the floating-point
23789 standard, as in IEC 60559 operation, IEC 60559 format, etc. An implementation that
23790 defines __STDC_IEC_559__ shall conform to the specifications in this annex.<sup><a href="#note343"><b>343)</b></a></sup>
23791 Where a binding between the C language and IEC 60559 is indicated, the
23792 IEC 60559-specified behavior is adopted by reference, unless stated otherwise. Since
23793 negative and positive infinity are representable in IEC 60559 formats, all real numbers lie
23794 within the range of representable values.
23797 <p><a name="note343">343)</a> Implementations that do not define __STDC_IEC_559__ are not required to conform to these
23801 <a name="F.2" href="#F.2"><h3>F.2 Types</h3></a>
23803 The C floating types match the IEC 60559 formats as follows:
23805 <li> The float type matches the IEC 60559 single format.
23806 <li> The double type matches the IEC 60559 double format.
23807 <li> The long double type matches an IEC 60559 extended format,<sup><a href="#note344"><b>344)</b></a></sup> else a
23808 non-IEC 60559 extended format, else the IEC 60559 double format.
23810 Any non-IEC 60559 extended format used for the long double type shall have more
23811 precision than IEC 60559 double and at least the range of IEC 60559 double.<sup><a href="#note345"><b>345)</b></a></sup>
23816 <!--page 522 indent 4-->
23817 Recommended practice
23819 The long double type should match an IEC 60559 extended format.
23822 <p><a name="note344">344)</a> ''Extended'' is IEC 60559's double-extended data format. Extended refers to both the common 80-bit
23823 and quadruple 128-bit IEC 60559 formats.
23825 <p><a name="note345">345)</a> A non-IEC 60559 long double type is required to provide infinity and NaNs, as its values include
23829 <a name="F.2.1" href="#F.2.1"><h4>F.2.1 Infinities, signed zeros, and NaNs</h4></a>
23831 This specification does not define the behavior of signaling NaNs.<sup><a href="#note346"><b>346)</b></a></sup> It generally uses
23832 the term NaN to denote quiet NaNs. The NAN and INFINITY macros and the nan
23833 functions in <math.h> provide designations for IEC 60559 NaNs and infinities.
23836 <p><a name="note346">346)</a> Since NaNs created by IEC 60559 operations are always quiet, quiet NaNs (along with infinities) are
23837 sufficient for closure of the arithmetic.
23840 <a name="F.3" href="#F.3"><h3>F.3 Operators and functions</h3></a>
23842 C operators and functions provide IEC 60559 required and recommended facilities as
23845 <li> The +, -, *, and / operators provide the IEC 60559 add, subtract, multiply, and
23847 <li> The sqrt functions in <math.h> provide the IEC 60559 square root operation.
23848 <li> The remainder functions in <math.h> provide the IEC 60559 remainder
23849 operation. The remquo functions in <math.h> provide the same operation but
23850 with additional information.
23851 <li> The rint functions in <math.h> provide the IEC 60559 operation that rounds a
23852 floating-point number to an integer value (in the same precision). The nearbyint
23853 functions in <math.h> provide the nearbyinteger function recommended in the
23854 Appendix to ANSI/IEEE 854.
23855 <li> The conversions for floating types provide the IEC 60559 conversions between
23856 floating-point precisions.
23857 <li> The conversions from integer to floating types provide the IEC 60559 conversions
23858 from integer to floating point.
23859 <li> The conversions from floating to integer types provide IEC 60559-like conversions
23860 but always round toward zero.
23861 <li> The lrint and llrint functions in <math.h> provide the IEC 60559
23862 conversions, which honor the directed rounding mode, from floating point to the
23863 long int and long long int integer formats. The lrint and llrint
23864 functions can be used to implement IEC 60559 conversions from floating to other
23866 <li> The translation time conversion of floating constants and the strtod, strtof,
23867 strtold, fprintf, fscanf, and related library functions in <stdlib.h>,
23870 <!--page 523 indent 0-->
23871 <stdio.h>, and <wchar.h> provide IEC 60559 binary-decimal conversions. The
23872 strtold function in <stdlib.h> provides the conv function recommended in the
23873 Appendix to ANSI/IEEE 854.
23874 <li> The relational and equality operators provide IEC 60559 comparisons. IEC 60559
23875 identifies a need for additional comparison predicates to facilitate writing code that
23876 accounts for NaNs. The comparison macros (isgreater, isgreaterequal,
23877 isless, islessequal, islessgreater, and isunordered) in <math.h>
23878 supplement the language operators to address this need. The islessgreater and
23879 isunordered macros provide respectively a quiet version of the <> predicate and
23880 the unordered predicate recommended in the Appendix to IEC 60559.
23881 <li> The feclearexcept, feraiseexcept, and fetestexcept functions in
23882 <fenv.h> provide the facility to test and alter the IEC 60559 floating-point
23883 exception status flags. The fegetexceptflag and fesetexceptflag
23884 functions in <fenv.h> provide the facility to save and restore all five status flags at
23885 one time. These functions are used in conjunction with the type fexcept_t and the
23886 floating-point exception macros (FE_INEXACT, FE_DIVBYZERO,
23887 FE_UNDERFLOW, FE_OVERFLOW, FE_INVALID) also in <fenv.h>.
23888 <li> The fegetround and fesetround functions in <fenv.h> provide the facility
23889 to select among the IEC 60559 directed rounding modes represented by the rounding
23890 direction macros in <fenv.h> (FE_TONEAREST, FE_UPWARD, FE_DOWNWARD,
23891 FE_TOWARDZERO) and the values 0, 1, 2, and 3 of FLT_ROUNDS are the
23892 IEC 60559 directed rounding modes.
23893 <li> The fegetenv, feholdexcept, fesetenv, and feupdateenv functions in
23894 <fenv.h> provide a facility to manage the floating-point environment, comprising
23895 the IEC 60559 status flags and control modes.
23896 <li> The copysign functions in <math.h> provide the copysign function
23897 recommended in the Appendix to IEC 60559.
23898 <li> The fabs functions in <math.h> provide the abs function recommended in the
23899 Appendix to IEC 60559.
23900 <li> The unary minus (-) operator provides the unary minus (-) operation recommended
23901 in the Appendix to IEC 60559.
23902 <li> The scalbn and scalbln functions in <math.h> provide the scalb function
23903 recommended in the Appendix to IEC 60559.
23904 <li> The logb functions in <math.h> provide the logb function recommended in the
23905 Appendix to IEC 60559, but following the newer specifications in ANSI/IEEE 854.
23906 <li> The nextafter and nexttoward functions in <math.h> provide the nextafter
23907 function recommended in the Appendix to IEC 60559 (but with a minor change to
23908 <!--page 524 indent 4-->
23909 better handle signed zeros).
23910 <li> The isfinite macro in <math.h> provides the finite function recommended in
23911 the Appendix to IEC 60559.
23912 <li> The isnan macro in <math.h> provides the isnan function recommended in the
23913 Appendix to IEC 60559.
23914 <li> The signbit macro and the fpclassify macro in <math.h>, used in
23915 conjunction with the number classification macros (FP_NAN, FP_INFINITE,
23916 FP_NORMAL, FP_SUBNORMAL, FP_ZERO), provide the facility of the class
23917 function recommended in the Appendix to IEC 60559 (except that the classification
23918 macros defined in <a href="#7.12.3">7.12.3</a> do not distinguish signaling from quiet NaNs).
23921 <a name="F.4" href="#F.4"><h3>F.4 Floating to integer conversion</h3></a>
23923 If the integer type is _Bool, <a href="#6.3.1.2">6.3.1.2</a> applies and no floating-point exceptions are raised
23924 (even for NaN). Otherwise, if the floating value is infinite or NaN or if the integral part
23925 of the floating value exceeds the range of the integer type, then the ''invalid'' floating-
23926 point exception is raised and the resulting value is unspecified. Otherwise, the resulting
23927 value is determined by <a href="#6.3.1.4">6.3.1.4</a>. Conversion of an integral floating value that does not
23928 exceed the range of the integer type raises no floating-point exceptions; whether
23929 conversion of a non-integral floating value raises the ''inexact'' floating-point exception is
23930 unspecified.<sup><a href="#note347"><b>347)</b></a></sup>
23933 <p><a name="note347">347)</a> ANSI/IEEE 854, but not IEC 60559 (ANSI/IEEE 754), directly specifies that floating-to-integer
23934 conversions raise the ''inexact'' floating-point exception for non-integer in-range values. In those
23935 cases where it matters, library functions can be used to effect such conversions with or without raising
23936 the ''inexact'' floating-point exception. See rint, lrint, llrint, and nearbyint in
23940 <a name="F.5" href="#F.5"><h3>F.5 Binary-decimal conversion</h3></a>
23942 Conversion from the widest supported IEC 60559 format to decimal with
23943 DECIMAL_DIG digits and back is the identity function.<sup><a href="#note348"><b>348)</b></a></sup>
23945 Conversions involving IEC 60559 formats follow all pertinent recommended practice. In
23946 particular, conversion between any supported IEC 60559 format and decimal with
23947 DECIMAL_DIG or fewer significant digits is correctly rounded (honoring the current
23948 rounding mode), which assures that conversion from the widest supported IEC 60559
23949 format to decimal with DECIMAL_DIG digits and back is the identity function.
23953 <!--page 525 indent 4-->
23955 Functions such as strtod that convert character sequences to floating types honor the
23956 rounding direction. Hence, if the rounding direction might be upward or downward, the
23957 implementation cannot convert a minus-signed sequence by negating the converted
23961 <p><a name="note348">348)</a> If the minimum-width IEC 60559 extended format (64 bits of precision) is supported,
23962 DECIMAL_DIG shall be at least 21. If IEC 60559 double (53 bits of precision) is the widest
23963 IEC 60559 format supported, then DECIMAL_DIG shall be at least 17. (By contrast, LDBL_DIG and
23964 DBL_DIG are 18 and 15, respectively, for these formats.)
23967 <a name="F.6" href="#F.6"><h3>F.6 The return statement</h3></a>
23968 If the return expression is evaluated in a floating-point format different from the return
23969 type, the expression is converted as if by assignment<sup><a href="#note349"><b>349)</b></a></sup> to the return type of the function
23970 and the resulting value is returned to the caller.
23973 <p><a name="note349">349)</a> Assignment removes any extra range and precision.
23976 <a name="F.7" href="#F.7"><h3>F.7 Contracted expressions</h3></a>
23978 A contracted expression is correctly rounded (once) and treats infinities, NaNs, signed
23979 zeros, subnormals, and the rounding directions in a manner consistent with the basic
23980 arithmetic operations covered by IEC 60559.
23981 Recommended practice
23983 A contracted expression should raise floating-point exceptions in a manner generally
23984 consistent with the basic arithmetic operations. *
23986 <a name="F.8" href="#F.8"><h3>F.8 Floating-point environment</h3></a>
23988 The floating-point environment defined in <fenv.h> includes the IEC 60559 floating-
23989 point exception status flags and directed-rounding control modes. It includes also
23990 IEC 60559 dynamic rounding precision and trap enablement modes, if the
23991 implementation supports them.<sup><a href="#note350"><b>350)</b></a></sup>
23994 <p><a name="note350">350)</a> This specification does not require dynamic rounding precision nor trap enablement modes.
23997 <a name="F.8.1" href="#F.8.1"><h4>F.8.1 Environment management</h4></a>
23999 IEC 60559 requires that floating-point operations implicitly raise floating-point exception
24000 status flags, and that rounding control modes can be set explicitly to affect result values of
24001 floating-point operations. When the state for the FENV_ACCESS pragma (defined in
24002 <fenv.h>) is ''on'', these changes to the floating-point state are treated as side effects
24003 which respect sequence points.<sup><a href="#note351"><b>351)</b></a></sup>
24008 <!--page 526 indent 4-->
24011 <p><a name="note351">351)</a> If the state for the FENV_ACCESS pragma is ''off'', the implementation is free to assume the floating-
24012 point control modes will be the default ones and the floating-point status flags will not be tested,
24013 which allows certain optimizations (see <a href="#F.9">F.9</a>).
24016 <a name="F.8.2" href="#F.8.2"><h4>F.8.2 Translation</h4></a>
24018 During translation the IEC 60559 default modes are in effect:
24020 <li> The rounding direction mode is rounding to nearest.
24021 <li> The rounding precision mode (if supported) is set so that results are not shortened.
24022 <li> Trapping or stopping (if supported) is disabled on all floating-point exceptions.
24024 Recommended practice
24026 The implementation should produce a diagnostic message for each translation-time
24027 floating-point exception, other than ''inexact'';<sup><a href="#note352"><b>352)</b></a></sup> the implementation should then
24028 proceed with the translation of the program.
24031 <p><a name="note352">352)</a> As floating constants are converted to appropriate internal representations at translation time, their
24032 conversion is subject to default rounding modes and raises no execution-time floating-point exceptions
24033 (even where the state of the FENV_ACCESS pragma is ''on''). Library functions, for example
24034 strtod, provide execution-time conversion of numeric strings.
24037 <a name="F.8.3" href="#F.8.3"><h4>F.8.3 Execution</h4></a>
24039 At program startup the floating-point environment is initialized as prescribed by
24042 <li> All floating-point exception status flags are cleared.
24043 <li> The rounding direction mode is rounding to nearest.
24044 <li> The dynamic rounding precision mode (if supported) is set so that results are not
24046 <li> Trapping or stopping (if supported) is disabled on all floating-point exceptions.
24049 <a name="F.8.4" href="#F.8.4"><h4>F.8.4 Constant expressions</h4></a>
24051 An arithmetic constant expression of floating type, other than one in an initializer for an
24052 object that has static or thread storage duration, is evaluated (as if) during execution; thus,
24053 it is affected by any operative floating-point control modes and raises floating-point
24054 exceptions as required by IEC 60559 (provided the state for the FENV_ACCESS pragma
24055 is ''on'').<sup><a href="#note353"><b>353)</b></a></sup>
24061 <!--page 527 indent 4-->
24064 #include <fenv.h>
24065 #pragma STDC FENV_ACCESS ON
24068 float w[] = { 0.0/0.0 }; // raises an exception
24069 static float x = 0.0/0.0; // does not raise an exception
24070 float y = 0.0/0.0; // raises an exception
24071 double z = 0.0/0.0; // raises an exception
24074 For the static initialization, the division is done at translation time, raising no (execution-time) floating-
24075 point exceptions. On the other hand, for the three automatic initializations the invalid division occurs at
24080 <p><a name="note353">353)</a> Where the state for the FENV_ACCESS pragma is ''on'', results of inexact expressions like 1.0/3.0
24081 are affected by rounding modes set at execution time, and expressions such as 0.0/0.0 and
24082 1.0/0.0 generate execution-time floating-point exceptions. The programmer can achieve the
24083 efficiency of translation-time evaluation through static initialization, such as
24086 const static double one_third = 1.0/3.0;</pre>
24089 <a name="F.8.5" href="#F.8.5"><h4>F.8.5 Initialization</h4></a>
24091 All computation for automatic initialization is done (as if) at execution time; thus, it is
24092 affected by any operative modes and raises floating-point exceptions as required by
24093 IEC 60559 (provided the state for the FENV_ACCESS pragma is ''on''). All computation
24094 for initialization of objects that have static or thread storage duration is done (as if) at
24100 #include <fenv.h>
24101 #pragma STDC FENV_ACCESS ON
24104 float u[] = { 1.1e75 }; // raises exceptions
24105 static float v = 1.1e75; // does not raise exceptions
24106 float w = 1.1e75; // raises exceptions
24107 double x = 1.1e75; // may raise exceptions
24108 float y = 1.1e75f; // may raise exceptions
24109 long double z = 1.1e75; // does not raise exceptions
24112 The static initialization of v raises no (execution-time) floating-point exceptions because its computation is
24113 done at translation time. The automatic initialization of u and w require an execution-time conversion to
24114 float of the wider value 1.1e75, which raises floating-point exceptions. The automatic initializations
24115 of x and y entail execution-time conversion; however, in some expression evaluation methods, the
24116 conversions is not to a narrower format, in which case no floating-point exception is raised.<sup><a href="#note354"><b>354)</b></a></sup> The
24117 automatic initialization of z entails execution-time conversion, but not to a narrower format, so no floating-
24118 point exception is raised. Note that the conversions of the floating constants 1.1e75 and 1.1e75f to
24122 <!--page 528 indent 4-->
24123 their internal representations occur at translation time in all cases.
24127 <p><a name="note354">354)</a> Use of float_t and double_t variables increases the likelihood of translation-time computation.
24128 For example, the automatic initialization
24131 double_t x = 1.1e75;</pre>
24132 could be done at translation time, regardless of the expression evaluation method.
24135 <a name="F.8.6" href="#F.8.6"><h4>F.8.6 Changing the environment</h4></a>
24137 Operations defined in <a href="#6.5">6.5</a> and functions and macros defined for the standard libraries
24138 change floating-point status flags and control modes just as indicated by their
24139 specifications (including conformance to IEC 60559). They do not change flags or modes
24140 (so as to be detectable by the user) in any other cases.
24142 If the argument to the feraiseexcept function in <fenv.h> represents IEC 60559
24143 valid coincident floating-point exceptions for atomic operations (namely ''overflow'' and
24144 ''inexact'', or ''underflow'' and ''inexact''), then ''overflow'' or ''underflow'' is raised
24145 before ''inexact''.
24147 <a name="F.9" href="#F.9"><h3>F.9 Optimization</h3></a>
24149 This section identifies code transformations that might subvert IEC 60559-specified
24150 behavior, and others that do not.
24152 <a name="F.9.1" href="#F.9.1"><h4>F.9.1 Global transformations</h4></a>
24154 Floating-point arithmetic operations and external function calls may entail side effects
24155 which optimization shall honor, at least where the state of the FENV_ACCESS pragma is
24156 ''on''. The flags and modes in the floating-point environment may be regarded as global
24157 variables; floating-point operations (+, *, etc.) implicitly read the modes and write the
24160 Concern about side effects may inhibit code motion and removal of seemingly useless
24161 code. For example, in
24163 #include <fenv.h>
24164 #pragma STDC FENV_ACCESS ON
24168 for (i = 0; i < n; i++) x + 1;
24171 x + 1 might raise floating-point exceptions, so cannot be removed. And since the loop
24172 body might not execute (maybe 0 >= n), x + 1 cannot be moved out of the loop. (Of
24173 course these optimizations are valid if the implementation can rule out the nettlesome
24176 This specification does not require support for trap handlers that maintain information
24177 about the order or count of floating-point exceptions. Therefore, between function calls,
24178 floating-point exceptions need not be precise: the actual order and number of occurrences
24179 of floating-point exceptions (> 1) may vary from what the source code expresses. Thus,
24180 <!--page 529 indent 4-->
24181 the preceding loop could be treated as
24183 if (0 < n) x + 1;</pre>
24185 <a name="F.9.2" href="#F.9.2"><h4>F.9.2 Expression transformations</h4></a>
24187 x/2 <-> x x 0.5 Although similar transformations involving inexact constants
24189 generally do not yield numerically equivalent expressions, if the
24190 constants are exact then such transformations can be made on
24191 IEC 60559 machines and others that round perfectly.</pre>
24192 1 x x and x/1 -> x The expressions 1 x x, x/1, and x are equivalent (on IEC 60559
24194 machines, among others).<sup><a href="#note355"><b>355)</b></a></sup></pre>
24195 x/x -> 1.0 The expressions x/x and 1.0 are not equivalent if x can be zero,
24197 infinite, or NaN.</pre>
24198 x - y <-> x + (-y) The expressions x - y, x + (-y), and (-y) + x are equivalent (on
24200 IEC 60559 machines, among others).</pre>
24201 x - y <-> -(y - x) The expressions x - y and -(y - x) are not equivalent because 1 - 1
24203 is +0 but -(1 - 1) is -0 (in the default rounding direction).<sup><a href="#note356"><b>356)</b></a></sup></pre>
24204 x - x -> 0.0 The expressions x - x and 0.0 are not equivalent if x is a NaN or
24207 0 x x -> 0.0 The expressions 0 x x and 0.0 are not equivalent if x is a NaN,
24209 infinite, or -0.</pre>
24210 x+0-> x The expressions x + 0 and x are not equivalent if x is -0, because
24212 (-0) + (+0) yields +0 (in the default rounding direction), not -0.</pre>
24213 x-0-> x (+0) - (+0) yields -0 when rounding is downward (toward -(inf)), but
24215 +0 otherwise, and (-0) - (+0) always yields -0; so, if the state of the
24216 FENV_ACCESS pragma is ''off'', promising default rounding, then
24217 the implementation can replace x - 0 by x, even if x might be zero.</pre>
24218 -x <-> 0 - x The expressions -x and 0 - x are not equivalent if x is +0, because
24220 -(+0) yields -0, but 0 - (+0) yields +0 (unless rounding is
24223 <!--page 530 indent 4-->
24226 <p><a name="note355">355)</a> Strict support for signaling NaNs -- not required by this specification -- would invalidate these and
24227 other transformations that remove arithmetic operators.
24229 <p><a name="note356">356)</a> IEC 60559 prescribes a signed zero to preserve mathematical identities across certain discontinuities.
24233 1/(1/ (+-) (inf)) is (+-) (inf)</pre>
24237 conj(csqrt(z)) is csqrt(conj(z)),</pre>
24241 <a name="F.9.3" href="#F.9.3"><h4>F.9.3 Relational operators</h4></a>
24243 x != x -> false The expression x != x is true if x is a NaN.
24244 x = x -> true The expression x = x is false if x is a NaN.
24245 x < y -> isless(x,y) (and similarly for <=, >, >=) Though numerically equal, these
24247 expressions are not equivalent because of side effects when x or y is a
24248 NaN and the state of the FENV_ACCESS pragma is ''on''. This
24249 transformation, which would be desirable if extra code were required
24250 to cause the ''invalid'' floating-point exception for unordered cases,
24251 could be performed provided the state of the FENV_ACCESS pragma
24253 The sense of relational operators shall be maintained. This includes handling unordered
24254 cases as expressed by the source code.
24258 // calls g and raises ''invalid'' if a and b are unordered
24263 is not equivalent to
24265 // calls f and raises ''invalid'' if a and b are unordered
24272 // calls f without raising ''invalid'' if a and b are unordered
24273 if (isgreaterequal(a,b))
24277 nor, unless the state of the FENV_ACCESS pragma is ''off'', to
24279 // calls g without raising ''invalid'' if a and b are unordered
24284 but is equivalent to
24285 <!--page 531 indent 4-->
24293 <a name="F.9.4" href="#F.9.4"><h4>F.9.4 Constant arithmetic</h4></a>
24295 The implementation shall honor floating-point exceptions raised by execution-time
24296 constant arithmetic wherever the state of the FENV_ACCESS pragma is ''on''. (See <a href="#F.8.4">F.8.4</a>
24297 and <a href="#F.8.5">F.8.5</a>.) An operation on constants that raises no floating-point exception can be
24298 folded during translation, except, if the state of the FENV_ACCESS pragma is ''on'', a
24299 further check is required to assure that changing the rounding direction to downward does
24300 not alter the sign of the result,<sup><a href="#note357"><b>357)</b></a></sup> and implementations that support dynamic rounding
24301 precision modes shall assure further that the result of the operation raises no floating-
24302 point exception when converted to the semantic type of the operation.
24305 <p><a name="note357">357)</a> 0 - 0 yields -0 instead of +0 just when the rounding direction is downward.
24308 <a name="F.10" href="#F.10"><h3>F.10 Mathematics <math.h></h3></a>
24310 This subclause contains specifications of <math.h> facilities that are particularly suited
24311 for IEC 60559 implementations.
24313 The Standard C macro HUGE_VAL and its float and long double analogs,
24314 HUGE_VALF and HUGE_VALL, expand to expressions whose values are positive
24317 Special cases for functions in <math.h> are covered directly or indirectly by
24318 IEC 60559. The functions that IEC 60559 specifies directly are identified in <a href="#F.3">F.3</a>. The
24319 other functions in <math.h> treat infinities, NaNs, signed zeros, subnormals, and
24320 (provided the state of the FENV_ACCESS pragma is ''on'') the floating-point status flags
24321 in a manner consistent with the basic arithmetic operations covered by IEC 60559.
24323 The expression math_errhandling & MATH_ERREXCEPT shall evaluate to a
24326 The ''invalid'' and ''divide-by-zero'' floating-point exceptions are raised as specified in
24327 subsequent subclauses of this annex.
24329 The ''overflow'' floating-point exception is raised whenever an infinity -- or, because of
24330 rounding direction, a maximal-magnitude finite number -- is returned in lieu of a value
24331 whose magnitude is too large.
24333 The ''underflow'' floating-point exception is raised whenever a result is tiny (essentially
24334 subnormal or zero) and suffers loss of accuracy.<sup><a href="#note358"><b>358)</b></a></sup>
24337 <!--page 532 indent 5-->
24339 Whether or when library functions raise the ''inexact'' floating-point exception is
24340 unspecified, unless explicitly specified otherwise.
24342 Whether or when library functions raise an undeserved ''underflow'' floating-point
24343 exception is unspecified.<sup><a href="#note359"><b>359)</b></a></sup> Otherwise, as implied by <a href="#F.8.6">F.8.6</a>, the <math.h> functions do
24344 not raise spurious floating-point exceptions (detectable by the user), other than the
24345 ''inexact'' floating-point exception.
24347 Whether the functions honor the rounding direction mode is implementation-defined,
24348 unless explicitly specified otherwise.
24350 Functions with a NaN argument return a NaN result and raise no floating-point exception,
24351 except where stated otherwise.
24353 The specifications in the following subclauses append to the definitions in <math.h>.
24354 For families of functions, the specifications apply to all of the functions even though only
24355 the principal function is shown. Unless otherwise specified, where the symbol ''(+-)''
24356 occurs in both an argument and the result, the result has the same sign as the argument.
24357 Recommended practice
24359 If a function with one or more NaN arguments returns a NaN result, the result should be
24360 the same as one of the NaN arguments (after possible type conversion), except perhaps
24364 <p><a name="note358">358)</a> IEC 60559 allows different definitions of underflow. They all result in the same values, but differ on
24365 when the floating-point exception is raised.
24367 <p><a name="note359">359)</a> It is intended that undeserved ''underflow'' and ''inexact'' floating-point exceptions are raised only if
24368 avoiding them would be too costly.
24371 <a name="F.10.1" href="#F.10.1"><h4>F.10.1 Trigonometric functions</h4></a>
24373 <a name="F.10.1.1" href="#F.10.1.1"><h5>F.10.1.1 The acos functions</h5></a>
24376 <li> acos(1) returns +0.
24377 <li> acos(x) returns a NaN and raises the ''invalid'' floating-point exception for
24381 <a name="F.10.1.2" href="#F.10.1.2"><h5>F.10.1.2 The asin functions</h5></a>
24384 <li> asin((+-)0) returns (+-)0.
24385 <li> asin(x) returns a NaN and raises the ''invalid'' floating-point exception for
24391 <!--page 533 indent 4-->
24394 <a name="F.10.1.3" href="#F.10.1.3"><h5>F.10.1.3 The atan functions</h5></a>
24397 <li> atan((+-)0) returns (+-)0.
24398 <li> atan((+-)(inf)) returns (+-)pi /2.
24401 <a name="F.10.1.4" href="#F.10.1.4"><h5>F.10.1.4 The atan2 functions</h5></a>
24404 <li> atan2((+-)0, -0) returns (+-)pi .<sup><a href="#note360"><b>360)</b></a></sup>
24405 <li> atan2((+-)0, +0) returns (+-)0.
24406 <li> atan2((+-)0, x) returns (+-)pi for x < 0.
24407 <li> atan2((+-)0, x) returns (+-)0 for x > 0.
24408 <li> atan2(y, (+-)0) returns -pi /2 for y < 0.
24409 <li> atan2(y, (+-)0) returns pi /2 for y > 0.
24410 <li> atan2((+-)y, -(inf)) returns (+-)pi for finite y > 0.
24411 <li> atan2((+-)y, +(inf)) returns (+-)0 for finite y > 0.
24412 <li> atan2((+-)(inf), x) returns (+-)pi /2 for finite x.
24413 <li> atan2((+-)(inf), -(inf)) returns (+-)3pi /4.
24414 <li> atan2((+-)(inf), +(inf)) returns (+-)pi /4.
24418 <p><a name="note360">360)</a> atan2(0, 0) does not raise the ''invalid'' floating-point exception, nor does atan2( y , 0) raise
24419 the ''divide-by-zero'' floating-point exception.
24422 <a name="F.10.1.5" href="#F.10.1.5"><h5>F.10.1.5 The cos functions</h5></a>
24425 <li> cos((+-)0) returns 1.
24426 <li> cos((+-)(inf)) returns a NaN and raises the ''invalid'' floating-point exception.
24429 <a name="F.10.1.6" href="#F.10.1.6"><h5>F.10.1.6 The sin functions</h5></a>
24432 <li> sin((+-)0) returns (+-)0.
24433 <li> sin((+-)(inf)) returns a NaN and raises the ''invalid'' floating-point exception.
24436 <a name="F.10.1.7" href="#F.10.1.7"><h5>F.10.1.7 The tan functions</h5></a>
24439 <li> tan((+-)0) returns (+-)0.
24440 <li> tan((+-)(inf)) returns a NaN and raises the ''invalid'' floating-point exception.
24445 <!--page 534 indent 4-->
24448 <a name="F.10.2" href="#F.10.2"><h4>F.10.2 Hyperbolic functions</h4></a>
24450 <a name="F.10.2.1" href="#F.10.2.1"><h5>F.10.2.1 The acosh functions</h5></a>
24453 <li> acosh(1) returns +0.
24454 <li> acosh(x) returns a NaN and raises the ''invalid'' floating-point exception for x < 1.
24455 <li> acosh(+(inf)) returns +(inf).
24458 <a name="F.10.2.2" href="#F.10.2.2"><h5>F.10.2.2 The asinh functions</h5></a>
24461 <li> asinh((+-)0) returns (+-)0.
24462 <li> asinh((+-)(inf)) returns (+-)(inf).
24465 <a name="F.10.2.3" href="#F.10.2.3"><h5>F.10.2.3 The atanh functions</h5></a>
24468 <li> atanh((+-)0) returns (+-)0.
24469 <li> atanh((+-)1) returns (+-)(inf) and raises the ''divide-by-zero'' floating-point exception.
24470 <li> atanh(x) returns a NaN and raises the ''invalid'' floating-point exception for
24474 <a name="F.10.2.4" href="#F.10.2.4"><h5>F.10.2.4 The cosh functions</h5></a>
24477 <li> cosh((+-)0) returns 1.
24478 <li> cosh((+-)(inf)) returns +(inf).
24481 <a name="F.10.2.5" href="#F.10.2.5"><h5>F.10.2.5 The sinh functions</h5></a>
24484 <li> sinh((+-)0) returns (+-)0.
24485 <li> sinh((+-)(inf)) returns (+-)(inf).
24488 <a name="F.10.2.6" href="#F.10.2.6"><h5>F.10.2.6 The tanh functions</h5></a>
24491 <li> tanh((+-)0) returns (+-)0.
24492 <li> tanh((+-)(inf)) returns (+-)1.
24495 <a name="F.10.3" href="#F.10.3"><h4>F.10.3 Exponential and logarithmic functions</h4></a>
24497 <a name="F.10.3.1" href="#F.10.3.1"><h5>F.10.3.1 The exp functions</h5></a>
24500 <li> exp((+-)0) returns 1.
24501 <li> exp(-(inf)) returns +0.
24502 <li> exp(+(inf)) returns +(inf).
24503 <!--page 535 indent 4-->
24506 <a name="F.10.3.2" href="#F.10.3.2"><h5>F.10.3.2 The exp2 functions</h5></a>
24509 <li> exp2((+-)0) returns 1.
24510 <li> exp2(-(inf)) returns +0.
24511 <li> exp2(+(inf)) returns +(inf).
24514 <a name="F.10.3.3" href="#F.10.3.3"><h5>F.10.3.3 The expm1 functions</h5></a>
24517 <li> expm1((+-)0) returns (+-)0.
24518 <li> expm1(-(inf)) returns -1.
24519 <li> expm1(+(inf)) returns +(inf).
24522 <a name="F.10.3.4" href="#F.10.3.4"><h5>F.10.3.4 The frexp functions</h5></a>
24525 <li> frexp((+-)0, exp) returns (+-)0, and stores 0 in the object pointed to by exp.
24526 <li> frexp((+-)(inf), exp) returns (+-)(inf), and stores an unspecified value in the object
24528 <li> frexp(NaN, exp) stores an unspecified value in the object pointed to by exp
24529 (and returns a NaN).
24532 frexp raises no floating-point exceptions.
24534 When the radix of the argument is a power of 2, the returned value is exact and is
24535 independent of the current rounding direction mode.
24537 On a binary system, the body of the frexp function might be
24540 *exp = (value == 0) ? 0 : (int)(1 + logb(value));
24541 return scalbn(value, -(*exp));
24544 <a name="F.10.3.5" href="#F.10.3.5"><h5>F.10.3.5 The ilogb functions</h5></a>
24546 When the correct result is representable in the range of the return type, the returned value
24547 is exact and is independent of the current rounding direction mode.
24549 If the correct result is outside the range of the return type, the numeric result is
24550 unspecified and the ''invalid'' floating-point exception is raised.
24551 <!--page 536 indent 4-->
24553 <a name="F.10.3.6" href="#F.10.3.6"><h5>F.10.3.6 The ldexp functions</h5></a>
24555 On a binary system, ldexp(x, exp) is equivalent to scalbn(x, exp).
24557 <a name="F.10.3.7" href="#F.10.3.7"><h5>F.10.3.7 The log functions</h5></a>
24560 <li> log((+-)0) returns -(inf) and raises the ''divide-by-zero'' floating-point exception.
24561 <li> log(1) returns +0.
24562 <li> log(x) returns a NaN and raises the ''invalid'' floating-point exception for x < 0.
24563 <li> log(+(inf)) returns +(inf).
24566 <a name="F.10.3.8" href="#F.10.3.8"><h5>F.10.3.8 The log10 functions</h5></a>
24569 <li> log10((+-)0) returns -(inf) and raises the ''divide-by-zero'' floating-point exception.
24570 <li> log10(1) returns +0.
24571 <li> log10(x) returns a NaN and raises the ''invalid'' floating-point exception for x < 0.
24572 <li> log10(+(inf)) returns +(inf).
24575 <a name="F.10.3.9" href="#F.10.3.9"><h5>F.10.3.9 The log1p functions</h5></a>
24578 <li> log1p((+-)0) returns (+-)0.
24579 <li> log1p(-1) returns -(inf) and raises the ''divide-by-zero'' floating-point exception.
24580 <li> log1p(x) returns a NaN and raises the ''invalid'' floating-point exception for
24582 <li> log1p(+(inf)) returns +(inf).
24585 <a name="F.10.3.10" href="#F.10.3.10"><h5>F.10.3.10 The log2 functions</h5></a>
24588 <li> log2((+-)0) returns -(inf) and raises the ''divide-by-zero'' floating-point exception.
24589 <li> log2(1) returns +0.
24590 <li> log2(x) returns a NaN and raises the ''invalid'' floating-point exception for x < 0.
24591 <li> log2(+(inf)) returns +(inf).
24594 <a name="F.10.3.11" href="#F.10.3.11"><h5>F.10.3.11 The logb functions</h5></a>
24597 <li> logb((+-)0) returns -(inf) and raises the ''divide-by-zero'' floating-point exception.
24598 <li> logb((+-)(inf)) returns +(inf).
24601 The returned value is exact and is independent of the current rounding direction mode.
24602 <!--page 537 indent 4-->
24604 <a name="F.10.3.12" href="#F.10.3.12"><h5>F.10.3.12 The modf functions</h5></a>
24607 <li> modf((+-)x, iptr) returns a result with the same sign as x.
24608 <li> modf((+-)(inf), iptr) returns (+-)0 and stores (+-)(inf) in the object pointed to by iptr.
24609 <li> modf(NaN, iptr) stores a NaN in the object pointed to by iptr (and returns a
24613 The returned values are exact and are independent of the current rounding direction
24616 modf behaves as though implemented by
24618 #include <math.h>
24619 #include <fenv.h>
24620 #pragma STDC FENV_ACCESS ON
24621 double modf(double value, double *iptr)
24623 int save_round = fegetround();
24624 fesetround(FE_TOWARDZERO);
24625 *iptr = nearbyint(value);
24626 fesetround(save_round);
24628 isinf(value) ? 0.0 :
24629 value - (*iptr), value);
24632 <a name="F.10.3.13" href="#F.10.3.13"><h5>F.10.3.13 The scalbn and scalbln functions</h5></a>
24635 <li> scalbn((+-)0, n) returns (+-)0.
24636 <li> scalbn(x, 0) returns x.
24637 <li> scalbn((+-)(inf), n) returns (+-)(inf).
24640 If the calculation does not overflow or underflow, the returned value is exact and
24641 independent of the current rounding direction mode.
24642 <!--page 538 indent 4-->
24644 <a name="F.10.4" href="#F.10.4"><h4>F.10.4 Power and absolute value functions</h4></a>
24646 <a name="F.10.4.1" href="#F.10.4.1"><h5>F.10.4.1 The cbrt functions</h5></a>
24649 <li> cbrt((+-)0) returns (+-)0.
24650 <li> cbrt((+-)(inf)) returns (+-)(inf).
24653 <a name="F.10.4.2" href="#F.10.4.2"><h5>F.10.4.2 The fabs functions</h5></a>
24656 <li> fabs((+-)0) returns +0.
24657 <li> fabs((+-)(inf)) returns +(inf).
24660 The returned value is exact and is independent of the current rounding direction mode.
24662 <a name="F.10.4.3" href="#F.10.4.3"><h5>F.10.4.3 The hypot functions</h5></a>
24665 <li> hypot(x, y), hypot(y, x), and hypot(x, -y) are equivalent.
24666 <li> hypot(x, (+-)0) is equivalent to fabs(x).
24667 <li> hypot((+-)(inf), y) returns +(inf), even if y is a NaN.
24670 <a name="F.10.4.4" href="#F.10.4.4"><h5>F.10.4.4 The pow functions</h5></a>
24673 <li> pow((+-)0, y) returns (+-)(inf) and raises the ''divide-by-zero'' floating-point exception
24674 for y an odd integer < 0.
24675 <li> pow((+-)0, y) returns +(inf) and raises the ''divide-by-zero'' floating-point exception
24676 for y < 0, finite, and not an odd integer.
24677 <li> pow((+-)0, -(inf)) returns +(inf) and may raise the ''divide-by-zero'' floating-point
24679 <li> pow((+-)0, y) returns (+-)0 for y an odd integer > 0.
24680 <li> pow((+-)0, y) returns +0 for y > 0 and not an odd integer.
24681 <li> pow(-1, (+-)(inf)) returns 1.
24682 <li> pow(+1, y) returns 1 for any y, even a NaN.
24683 <li> pow(x, (+-)0) returns 1 for any x, even a NaN.
24684 <li> pow(x, y) returns a NaN and raises the ''invalid'' floating-point exception for
24685 finite x < 0 and finite non-integer y.
24686 <li> pow(x, -(inf)) returns +(inf) for | x | < 1.
24687 <li> pow(x, -(inf)) returns +0 for | x | > 1.
24688 <li> pow(x, +(inf)) returns +0 for | x | < 1.
24689 <li> pow(x, +(inf)) returns +(inf) for | x | > 1.
24690 <!--page 539 indent 4-->
24691 <li> pow(-(inf), y) returns -0 for y an odd integer < 0.
24692 <li> pow(-(inf), y) returns +0 for y < 0 and not an odd integer.
24693 <li> pow(-(inf), y) returns -(inf) for y an odd integer > 0.
24694 <li> pow(-(inf), y) returns +(inf) for y > 0 and not an odd integer.
24695 <li> pow(+(inf), y) returns +0 for y < 0.
24696 <li> pow(+(inf), y) returns +(inf) for y > 0.
24699 <a name="F.10.4.5" href="#F.10.4.5"><h5>F.10.4.5 The sqrt functions</h5></a>
24701 sqrt is fully specified as a basic arithmetic operation in IEC 60559. The returned value
24702 is dependent on the current rounding direction mode.
24704 <a name="F.10.5" href="#F.10.5"><h4>F.10.5 Error and gamma functions</h4></a>
24706 <a name="F.10.5.1" href="#F.10.5.1"><h5>F.10.5.1 The erf functions</h5></a>
24709 <li> erf((+-)0) returns (+-)0.
24710 <li> erf((+-)(inf)) returns (+-)1.
24713 <a name="F.10.5.2" href="#F.10.5.2"><h5>F.10.5.2 The erfc functions</h5></a>
24716 <li> erfc(-(inf)) returns 2.
24717 <li> erfc(+(inf)) returns +0.
24720 <a name="F.10.5.3" href="#F.10.5.3"><h5>F.10.5.3 The lgamma functions</h5></a>
24723 <li> lgamma(1) returns +0.
24724 <li> lgamma(2) returns +0.
24725 <li> lgamma(x) returns +(inf) and raises the ''divide-by-zero'' floating-point exception for
24726 x a negative integer or zero.
24727 <li> lgamma(-(inf)) returns +(inf).
24728 <li> lgamma(+(inf)) returns +(inf).
24731 <a name="F.10.5.4" href="#F.10.5.4"><h5>F.10.5.4 The tgamma functions</h5></a>
24734 <li> tgamma((+-)0) returns (+-)(inf) and raises the ''divide-by-zero'' floating-point exception.
24735 <li> tgamma(x) returns a NaN and raises the ''invalid'' floating-point exception for x a
24737 <li> tgamma(-(inf)) returns a NaN and raises the ''invalid'' floating-point exception.
24738 <li> tgamma(+(inf)) returns +(inf).
24739 <!--page 540 indent 4-->
24742 <a name="F.10.6" href="#F.10.6"><h4>F.10.6 Nearest integer functions</h4></a>
24744 <a name="F.10.6.1" href="#F.10.6.1"><h5>F.10.6.1 The ceil functions</h5></a>
24747 <li> ceil((+-)0) returns (+-)0.
24748 <li> ceil((+-)(inf)) returns (+-)(inf).
24751 The returned value is independent of the current rounding direction mode.
24753 The double version of ceil behaves as though implemented by
24756 #include <math.h>
24757 #include <fenv.h>
24758 #pragma STDC FENV_ACCESS ON
24759 double ceil(double x)
24762 int save_round = fegetround();
24763 fesetround(FE_UPWARD);
24764 result = rint(x); // or nearbyint instead of rint
24765 fesetround(save_round);
24768 The ceil functions may, but are not required to, raise the ''inexact'' floating-point
24769 exception for finite non-integer arguments, as this implementation does.
24771 <a name="F.10.6.2" href="#F.10.6.2"><h5>F.10.6.2 The floor functions</h5></a>
24774 <li> floor((+-)0) returns (+-)0.
24775 <li> floor((+-)(inf)) returns (+-)(inf).
24778 The returned value and is independent of the current rounding direction mode.
24780 See the sample implementation for ceil in <a href="#F.10.6.1">F.10.6.1</a>. The floor functions may, but are
24781 not required to, raise the ''inexact'' floating-point exception for finite non-integer
24782 arguments, as that implementation does.
24784 <a name="F.10.6.3" href="#F.10.6.3"><h5>F.10.6.3 The nearbyint functions</h5></a>
24786 The nearbyint functions use IEC 60559 rounding according to the current rounding
24787 direction. They do not raise the ''inexact'' floating-point exception if the result differs in
24788 value from the argument.
24790 <li> nearbyint((+-)0) returns (+-)0 (for all rounding directions).
24791 <li> nearbyint((+-)(inf)) returns (+-)(inf) (for all rounding directions).
24792 <!--page 541 indent 4-->
24795 <a name="F.10.6.4" href="#F.10.6.4"><h5>F.10.6.4 The rint functions</h5></a>
24797 The rint functions differ from the nearbyint functions only in that they do raise the
24798 ''inexact'' floating-point exception if the result differs in value from the argument.
24800 <a name="F.10.6.5" href="#F.10.6.5"><h5>F.10.6.5 The lrint and llrint functions</h5></a>
24802 The lrint and llrint functions provide floating-to-integer conversion as prescribed
24803 by IEC 60559. They round according to the current rounding direction. If the rounded
24804 value is outside the range of the return type, the numeric result is unspecified and the
24805 ''invalid'' floating-point exception is raised. When they raise no other floating-point
24806 exception and the result differs from the argument, they raise the ''inexact'' floating-point
24809 <a name="F.10.6.6" href="#F.10.6.6"><h5>F.10.6.6 The round functions</h5></a>
24812 <li> round((+-)0) returns (+-)0.
24813 <li> round((+-)(inf)) returns (+-)(inf).
24816 The returned value is independent of the current rounding direction mode.
24818 The double version of round behaves as though implemented by
24820 #include <math.h>
24821 #include <fenv.h>
24822 #pragma STDC FENV_ACCESS ON
24823 double round(double x)
24827 feholdexcept(&save_env);
24829 if (fetestexcept(FE_INEXACT)) {
24830 fesetround(FE_TOWARDZERO);
24831 result = rint(copysign(0.5 + fabs(x), x));
24833 feupdateenv(&save_env);
24836 The round functions may, but are not required to, raise the ''inexact'' floating-point
24837 exception for finite non-integer numeric arguments, as this implementation does.
24838 <!--page 542 indent 4-->
24840 <a name="F.10.6.7" href="#F.10.6.7"><h5>F.10.6.7 The lround and llround functions</h5></a>
24842 The lround and llround functions differ from the lrint and llrint functions
24843 with the default rounding direction just in that the lround and llround functions
24844 round halfway cases away from zero and need not raise the ''inexact'' floating-point
24845 exception for non-integer arguments that round to within the range of the return type.
24847 <a name="F.10.6.8" href="#F.10.6.8"><h5>F.10.6.8 The trunc functions</h5></a>
24849 The trunc functions use IEC 60559 rounding toward zero (regardless of the current
24850 rounding direction). The returned value is exact.
24852 <li> trunc((+-)0) returns (+-)0.
24853 <li> trunc((+-)(inf)) returns (+-)(inf).
24856 The returned value is independent of the current rounding direction mode. The trunc
24857 functions may, but are not required to, raise the ''inexact'' floating-point exception for
24858 finite non-integer arguments.
24860 <a name="F.10.7" href="#F.10.7"><h4>F.10.7 Remainder functions</h4></a>
24862 <a name="F.10.7.1" href="#F.10.7.1"><h5>F.10.7.1 The fmod functions</h5></a>
24865 <li> fmod((+-)0, y) returns (+-)0 for y not zero.
24866 <li> fmod(x, y) returns a NaN and raises the ''invalid'' floating-point exception for x
24867 infinite or y zero (and neither is a NaN).
24868 <li> fmod(x, (+-)(inf)) returns x for x not infinite.
24871 When subnormal results are supported, the returned value is exact and is independent of
24872 the current rounding direction mode.
24874 The double version of fmod behaves as though implemented by
24875 <!--page 543 indent 4-->
24877 #include <math.h>
24878 #include <fenv.h>
24879 #pragma STDC FENV_ACCESS ON
24880 double fmod(double x, double y)
24883 result = remainder(fabs(x), (y = fabs(y)));
24884 if (signbit(result)) result += y;
24885 return copysign(result, x);
24888 <a name="F.10.7.2" href="#F.10.7.2"><h5>F.10.7.2 The remainder functions</h5></a>
24890 The remainder functions are fully specified as a basic arithmetic operation in
24893 When subnormal results are supported, the returned value is exact and is independent of
24894 the current rounding direction mode.
24896 <a name="F.10.7.3" href="#F.10.7.3"><h5>F.10.7.3 The remquo functions</h5></a>
24898 The remquo functions follow the specifications for the remainder functions. They
24899 have no further specifications special to IEC 60559 implementations.
24901 When subnormal results are supported, the returned value is exact and is independent of
24902 the current rounding direction mode.
24904 <a name="F.10.8" href="#F.10.8"><h4>F.10.8 Manipulation functions</h4></a>
24906 <a name="F.10.8.1" href="#F.10.8.1"><h5>F.10.8.1 The copysign functions</h5></a>
24908 copysign is specified in the Appendix to IEC 60559.
24910 The returned value is exact and is independent of the current rounding direction mode.
24912 <a name="F.10.8.2" href="#F.10.8.2"><h5>F.10.8.2 The nan functions</h5></a>
24914 All IEC 60559 implementations support quiet NaNs, in all floating formats.
24916 The returned value is exact and is independent of the current rounding direction mode.
24918 <a name="F.10.8.3" href="#F.10.8.3"><h5>F.10.8.3 The nextafter functions</h5></a>
24921 <li> nextafter(x, y) raises the ''overflow'' and ''inexact'' floating-point exceptions
24922 for x finite and the function value infinite.
24923 <li> nextafter(x, y) raises the ''underflow'' and ''inexact'' floating-point
24924 exceptions for the function value subnormal or zero and x != y.
24927 Even though underflow or overflow can occur, the returned value is independent of the
24928 current rounding direction mode.
24930 <a name="F.10.8.4" href="#F.10.8.4"><h5>F.10.8.4 The nexttoward functions</h5></a>
24932 No additional requirements beyond those on nextafter.
24934 Even though underflow or overflow can occur, the returned value is independent of the
24935 current rounding direction mode.
24936 <!--page 544 indent 4-->
24938 <a name="F.10.9" href="#F.10.9"><h4>F.10.9 Maximum, minimum, and positive difference functions</h4></a>
24940 <a name="F.10.9.1" href="#F.10.9.1"><h5>F.10.9.1 The fdim functions</h5></a>
24942 No additional requirements.
24944 <a name="F.10.9.2" href="#F.10.9.2"><h5>F.10.9.2 The fmax functions</h5></a>
24946 If just one argument is a NaN, the fmax functions return the other argument (if both
24947 arguments are NaNs, the functions return a NaN).
24949 The returned value is exact and is independent of the current rounding direction mode.
24951 The body of the fmax function might be<sup><a href="#note361"><b>361)</b></a></sup>
24953 { return (isgreaterequal(x, y) ||
24954 isnan(y)) ? x : y; }</pre>
24957 <p><a name="note361">361)</a> Ideally, fmax would be sensitive to the sign of zero, for example fmax(-0.0, +0.0) would
24958 return +0; however, implementation in software might be impractical.
24961 <a name="F.10.9.3" href="#F.10.9.3"><h5>F.10.9.3 The fmin functions</h5></a>
24963 The fmin functions are analogous to the fmax functions (see <a href="#F.10.9.2">F.10.9.2</a>).
24965 The returned value is exact and is independent of the current rounding direction mode.
24967 <a name="F.10.10" href="#F.10.10"><h4>F.10.10 Floating multiply-add</h4></a>
24969 <a name="F.10.10.1" href="#F.10.10.1"><h5>F.10.10.1 The fma functions</h5></a>
24972 <li> fma(x, y, z) computes xy + z, correctly rounded once.
24973 <li> fma(x, y, z) returns a NaN and optionally raises the ''invalid'' floating-point
24974 exception if one of x and y is infinite, the other is zero, and z is a NaN.
24975 <li> fma(x, y, z) returns a NaN and raises the ''invalid'' floating-point exception if
24976 one of x and y is infinite, the other is zero, and z is not a NaN.
24977 <li> fma(x, y, z) returns a NaN and raises the ''invalid'' floating-point exception if x
24978 times y is an exact infinity and z is also an infinity but with the opposite sign.
24983 <!--page 545 indent 4-->
24986 <a name="F.10.11" href="#F.10.11"><h4>F.10.11 Comparison macros</h4></a>
24988 Relational operators and their corresponding comparison macros (<a href="#7.12.14">7.12.14</a>) produce
24989 equivalent result values, even if argument values are represented in wider formats. Thus,
24990 comparison macro arguments represented in formats wider than their semantic types are
24991 not converted to the semantic types, unless the wide evaluation method converts operands
24992 of relational operators to their semantic types. The standard wide evaluation methods
24993 characterized by FLT_EVAL_METHOD equal to 1 or 2 (<a href="#5.2.4.2.2">5.2.4.2.2</a>), do not convert
24994 operands of relational operators to their semantic types.
24995 <!--page 546 indent 4-->
24997 <a name="G" href="#G"><h2>Annex G</h2></a>
25000 IEC 60559-compatible complex arithmetic</pre>
25002 <a name="G.1" href="#G.1"><h3>G.1 Introduction</h3></a>
25004 This annex supplements <a href="#F">annex F</a> to specify complex arithmetic for compatibility with
25005 IEC 60559 real floating-point arithmetic. An implementation that defines *
25006 __STDC_IEC_559_COMPLEX__ shall conform to the specifications in this annex.<sup><a href="#note362"><b>362)</b></a></sup>
25009 <p><a name="note362">362)</a> Implementations that do not define __STDC_IEC_559_COMPLEX__ are not required to conform
25010 to these specifications.
25013 <a name="G.2" href="#G.2"><h3>G.2 Types</h3></a>
25015 There is a new keyword _Imaginary, which is used to specify imaginary types. It is
25016 used as a type specifier within declaration specifiers in the same way as _Complex is
25017 (thus, _Imaginary float is a valid type name).
25019 There are three imaginary types, designated as float _Imaginary, double
25020 _Imaginary, and long double _Imaginary. The imaginary types (along with
25021 the real floating and complex types) are floating types.
25023 For imaginary types, the corresponding real type is given by deleting the keyword
25024 _Imaginary from the type name.
25026 Each imaginary type has the same representation and alignment requirements as the
25027 corresponding real type. The value of an object of imaginary type is the value of the real
25028 representation times the imaginary unit.
25030 The imaginary type domain comprises the imaginary types.
25032 <a name="G.3" href="#G.3"><h3>G.3 Conventions</h3></a>
25034 A complex or imaginary value with at least one infinite part is regarded as an infinity
25035 (even if its other part is a NaN). A complex or imaginary value is a finite number if each
25036 of its parts is a finite number (neither infinite nor NaN). A complex or imaginary value is
25037 a zero if each of its parts is a zero.
25042 <!--page 547 indent 4-->
25044 <a name="G.4" href="#G.4"><h3>G.4 Conversions</h3></a>
25046 <a name="G.4.1" href="#G.4.1"><h4>G.4.1 Imaginary types</h4></a>
25048 Conversions among imaginary types follow rules analogous to those for real floating
25051 <a name="G.4.2" href="#G.4.2"><h4>G.4.2 Real and imaginary</h4></a>
25053 When a value of imaginary type is converted to a real type other than _Bool,<sup><a href="#note363"><b>363)</b></a></sup> the
25054 result is a positive zero.
25056 When a value of real type is converted to an imaginary type, the result is a positive
25060 <p><a name="note363">363)</a> See <a href="#6.3.1.2">6.3.1.2</a>.
25063 <a name="G.4.3" href="#G.4.3"><h4>G.4.3 Imaginary and complex</h4></a>
25065 When a value of imaginary type is converted to a complex type, the real part of the
25066 complex result value is a positive zero and the imaginary part of the complex result value
25067 is determined by the conversion rules for the corresponding real types.
25069 When a value of complex type is converted to an imaginary type, the real part of the
25070 complex value is discarded and the value of the imaginary part is converted according to
25071 the conversion rules for the corresponding real types.
25073 <a name="G.5" href="#G.5"><h3>G.5 Binary operators</h3></a>
25075 The following subclauses supplement <a href="#6.5">6.5</a> in order to specify the type of the result for an
25076 operation with an imaginary operand.
25078 For most operand types, the value of the result of a binary operator with an imaginary or
25079 complex operand is completely determined, with reference to real arithmetic, by the usual
25080 mathematical formula. For some operand types, the usual mathematical formula is
25081 problematic because of its treatment of infinities and because of undue overflow or
25082 underflow; in these cases the result satisfies certain properties (specified in <a href="#G.5.1">G.5.1</a>), but is
25083 not completely determined.
25088 <!--page 548 indent 4-->
25090 <a name="G.5.1" href="#G.5.1"><h4>G.5.1 Multiplicative operators</h4></a>
25093 If one operand has real type and the other operand has imaginary type, then the result has
25094 imaginary type. If both operands have imaginary type, then the result has real type. (If
25095 either operand has complex type, then the result has complex type.)
25097 If the operands are not both complex, then the result and floating-point exception
25098 behavior of the * operator is defined by the usual mathematical formula:
25100 * u iv u + iv</pre>
25103 x xu i(xv) (xu) + i(xv)</pre>
25106 iy i(yu) -yv (-yv) + i(yu)</pre>
25110 x + iy (xu) + i(yu) (-yv) + i(xv)</pre>
25111 If the second operand is not complex, then the result and floating-point exception
25112 behavior of the / operator is defined by the usual mathematical formula:
25117 x x/u i(-x/v)</pre>
25120 iy i(y/u) y/v</pre>
25124 x + iy (x/u) + i(y/u) (y/v) + i(-x/v)</pre>
25125 The * and / operators satisfy the following infinity properties for all real, imaginary, and
25126 complex operands:<sup><a href="#note364"><b>364)</b></a></sup>
25128 <li> if one operand is an infinity and the other operand is a nonzero finite number or an
25129 infinity, then the result of the * operator is an infinity;
25130 <li> if the first operand is an infinity and the second operand is a finite number, then the
25131 result of the / operator is an infinity;
25132 <li> if the first operand is a finite number and the second operand is an infinity, then the
25133 result of the / operator is a zero;
25138 <!--page 549 indent 4-->
25139 <li> if the first operand is a nonzero finite number or an infinity and the second operand is
25140 a zero, then the result of the / operator is an infinity.
25143 If both operands of the * operator are complex or if the second operand of the / operator
25144 is complex, the operator raises floating-point exceptions if appropriate for the calculation
25145 of the parts of the result, and may raise spurious floating-point exceptions.
25147 EXAMPLE 1 Multiplication of double _Complex operands could be implemented as follows. Note
25148 that the imaginary unit I has imaginary type (see <a href="#G.6">G.6</a>).
25149 <!--page 550 indent 4-->
25152 #include <math.h>
25153 #include <complex.h>
25154 /* Multiply z * w ... */
25155 double complex _Cmultd(double complex z, double complex w)
25157 #pragma STDC FP_CONTRACT OFF
25158 double a, b, c, d, ac, bd, ad, bc, x, y;
25159 a = creal(z); b = cimag(z);
25160 c = creal(w); d = cimag(w);
25161 ac = a * c; bd = b * d;
25162 ad = a * d; bc = b * c;
25163 x = ac - bd; y = ad + bc;
25164 if (isnan(x) && isnan(y)) {
25165 /* Recover infinities that computed as NaN+iNaN ... */
25167 if ( isinf(a) || isinf(b) ) { // z is infinite
25168 /* "Box" the infinity and change NaNs in the other factor to 0 */
25169 a = copysign(isinf(a) ? 1.0 : 0.0, a);
25170 b = copysign(isinf(b) ? 1.0 : 0.0, b);
25171 if (isnan(c)) c = copysign(0.0, c);
25172 if (isnan(d)) d = copysign(0.0, d);
25175 if ( isinf(c) || isinf(d) ) { // w is infinite
25176 /* "Box" the infinity and change NaNs in the other factor to 0 */
25177 c = copysign(isinf(c) ? 1.0 : 0.0, c);
25178 d = copysign(isinf(d) ? 1.0 : 0.0, d);
25179 if (isnan(a)) a = copysign(0.0, a);
25180 if (isnan(b)) b = copysign(0.0, b);
25183 if (!recalc && (isinf(ac) || isinf(bd) ||
25184 isinf(ad) || isinf(bc))) {
25185 /* Recover infinities from overflow by changing NaNs to 0 ... */
25186 if (isnan(a)) a = copysign(0.0, a);
25187 if (isnan(b)) b = copysign(0.0, b);
25188 if (isnan(c)) c = copysign(0.0, c);
25189 if (isnan(d)) d = copysign(0.0, d);
25193 x = INFINITY * ( a * c - b * d );
25194 y = INFINITY * ( a * d + b * c );
25199 This implementation achieves the required treatment of infinities at the cost of only one isnan test in
25200 ordinary (finite) cases. It is less than ideal in that undue overflow and underflow may occur.
25203 EXAMPLE 2 Division of two double _Complex operands could be implemented as follows.
25204 <!--page 551 indent 4-->
25207 #include <math.h>
25208 #include <complex.h>
25209 /* Divide z / w ... */
25210 double complex _Cdivd(double complex z, double complex w)
25212 #pragma STDC FP_CONTRACT OFF
25213 double a, b, c, d, logbw, denom, x, y;
25215 a = creal(z); b = cimag(z);
25216 c = creal(w); d = cimag(w);
25217 logbw = logb(fmax(fabs(c), fabs(d)));
25218 if (logbw == INFINITY) {
25219 ilogbw = (int)logbw;
25220 c = scalbn(c, -ilogbw); d = scalbn(d, -ilogbw);
25222 denom = c * c + d * d;
25223 x = scalbn((a * c + b * d) / denom, -ilogbw);
25224 y = scalbn((b * c - a * d) / denom, -ilogbw);
25225 /* Recover infinities and zeros that computed as NaN+iNaN; */
25226 /* the only cases are nonzero/zero, infinite/finite, and finite/infinite, ... */
25227 if (isnan(x) && isnan(y)) {
25228 if ((denom == 0.0) &&
25229 (!isnan(a) || !isnan(b))) {
25230 x = copysign(INFINITY, c) * a;
25231 y = copysign(INFINITY, c) * b;
25233 else if ((isinf(a) || isinf(b)) &&
25234 isfinite(c) && isfinite(d)) {
25235 a = copysign(isinf(a) ? 1.0 : 0.0, a);
25236 b = copysign(isinf(b) ? 1.0 : 0.0, b);
25237 x = INFINITY * ( a * c + b * d );
25238 y = INFINITY * ( b * c - a * d );
25240 else if (isinf(logbw) &&
25241 isfinite(a) && isfinite(b)) {
25242 c = copysign(isinf(c) ? 1.0 : 0.0, c);
25243 d = copysign(isinf(d) ? 1.0 : 0.0, d);
25244 x = 0.0 * ( a * c + b * d );
25245 y = 0.0 * ( b * c - a * d );
25250 Scaling the denominator alleviates the main overflow and underflow problem, which is more serious than
25251 for multiplication. In the spirit of the multiplication example above, this code does not defend against
25252 overflow and underflow in the calculation of the numerator. Scaling with the scalbn function, instead of
25253 with division, provides better roundoff characteristics.
25257 <p><a name="note364">364)</a> These properties are already implied for those cases covered in the tables, but are required for all cases
25258 (at least where the state for CX_LIMITED_RANGE is ''off'').
25261 <a name="G.5.2" href="#G.5.2"><h4>G.5.2 Additive operators</h4></a>
25264 If both operands have imaginary type, then the result has imaginary type. (If one operand
25265 has real type and the other operand has imaginary type, or if either operand has complex
25266 type, then the result has complex type.)
25268 In all cases the result and floating-point exception behavior of a + or - operator is defined
25269 by the usual mathematical formula:
25271 + or - u iv u + iv</pre>
25274 x x(+-)u x (+-) iv (x (+-) u) (+-) iv</pre>
25277 iy (+-)u + iy i(y (+-) v) (+-)u + i(y (+-) v)</pre>
25280 x + iy (x (+-) u) + iy x + i(y (+-) v) (x (+-) u) + i(y (+-) v)</pre>
25282 <a name="G.6" href="#G.6"><h3>G.6 Complex arithmetic <complex.h></h3></a>
25290 are defined, respectively, as _Imaginary and a constant expression of type const
25291 float _Imaginary with the value of the imaginary unit. The macro
25294 is defined to be _Imaginary_I (not _Complex_I as stated in <a href="#7.3">7.3</a>). Notwithstanding
25295 the provisions of <a href="#7.1.3">7.1.3</a>, a program may undefine and then perhaps redefine the macro
25298 This subclause contains specifications for the <complex.h> functions that are
25299 particularly suited to IEC 60559 implementations. For families of functions, the
25300 specifications apply to all of the functions even though only the principal function is
25301 <!--page 552 indent 4-->
25302 shown. Unless otherwise specified, where the symbol ''(+-)'' occurs in both an argument
25303 and the result, the result has the same sign as the argument.
25305 The functions are continuous onto both sides of their branch cuts, taking into account the
25306 sign of zero. For example, csqrt(-2 (+-) i0) = (+-)i(sqrt)2. -
25308 Since complex and imaginary values are composed of real values, each function may be
25309 regarded as computing real values from real values. Except as noted, the functions treat
25310 real infinities, NaNs, signed zeros, subnormals, and the floating-point exception flags in a
25311 manner consistent with the specifications for real functions in F.10.<sup><a href="#note365"><b>365)</b></a></sup>
25313 The functions cimag, conj, cproj, and creal are fully specified for all
25314 implementations, including IEC 60559 ones, in <a href="#7.3.9">7.3.9</a>. These functions raise no floating-
25317 Each of the functions cabs and carg is specified by a formula in terms of a real
25318 function (whose special cases are covered in <a href="#F">annex F</a>):
25321 cabs(x + iy) = hypot(x, y)
25322 carg(x + iy) = atan2(y, x)</pre>
25323 Each of the functions casin, catan, ccos, csin, and ctan is specified implicitly by
25324 a formula in terms of other complex functions (whose special cases are specified below):
25327 casin(z) = -i casinh(iz)
25328 catan(z) = -i catanh(iz)
25329 ccos(z) = ccosh(iz)
25330 csin(z) = -i csinh(iz)
25331 ctan(z) = -i ctanh(iz)</pre>
25332 For the other functions, the following subclauses specify behavior for special cases,
25333 including treatment of the ''invalid'' and ''divide-by-zero'' floating-point exceptions. For
25334 families of functions, the specifications apply to all of the functions even though only the
25335 principal function is shown. For a function f satisfying f (conj(z)) = conj( f (z)), the
25336 specifications for the upper half-plane imply the specifications for the lower half-plane; if
25337 the function f is also either even, f (-z) = f (z), or odd, f (-z) = - f (z), then the
25338 specifications for the first quadrant imply the specifications for the other three quadrants.
25340 In the following subclauses, cis(y) is defined as cos(y) + i sin(y).
25345 <!--page 553 indent 4-->
25348 <p><a name="note365">365)</a> As noted in <a href="#G.3">G.3</a>, a complex value with at least one infinite part is regarded as an infinity even if its
25349 other part is a NaN.
25352 <a name="G.6.1" href="#G.6.1"><h4>G.6.1 Trigonometric functions</h4></a>
25354 <a name="G.6.1.1" href="#G.6.1.1"><h5>G.6.1.1 The cacos functions</h5></a>
25357 <li> cacos(conj(z)) = conj(cacos(z)).
25358 <li> cacos((+-)0 + i0) returns pi /2 - i0.
25359 <li> cacos((+-)0 + iNaN) returns pi /2 + iNaN.
25360 <li> cacos(x + i (inf)) returns pi /2 - i (inf), for finite x.
25361 <li> cacos(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25362 point exception, for nonzero finite x.
25363 <li> cacos(-(inf) + iy) returns pi - i (inf), for positive-signed finite y.
25364 <li> cacos(+(inf) + iy) returns +0 - i (inf), for positive-signed finite y.
25365 <li> cacos(-(inf) + i (inf)) returns 3pi /4 - i (inf).
25366 <li> cacos(+(inf) + i (inf)) returns pi /4 - i (inf).
25367 <li> cacos((+-)(inf) + iNaN) returns NaN (+-) i (inf) (where the sign of the imaginary part of the
25368 result is unspecified).
25369 <li> cacos(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25370 point exception, for finite y.
25371 <li> cacos(NaN + i (inf)) returns NaN - i (inf).
25372 <li> cacos(NaN + iNaN) returns NaN + iNaN.
25375 <a name="G.6.2" href="#G.6.2"><h4>G.6.2 Hyperbolic functions</h4></a>
25377 <a name="G.6.2.1" href="#G.6.2.1"><h5>G.6.2.1 The cacosh functions</h5></a>
25380 <li> cacosh(conj(z)) = conj(cacosh(z)).
25381 <li> cacosh((+-)0 + i0) returns +0 + ipi /2.
25382 <li> cacosh(x + i (inf)) returns +(inf) + ipi /2, for finite x.
25383 <li> cacosh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid''
25384 floating-point exception, for finite x.
25385 <li> cacosh(-(inf) + iy) returns +(inf) + ipi , for positive-signed finite y.
25386 <li> cacosh(+(inf) + iy) returns +(inf) + i0, for positive-signed finite y.
25387 <li> cacosh(-(inf) + i (inf)) returns +(inf) + i3pi /4.
25388 <li> cacosh(+(inf) + i (inf)) returns +(inf) + ipi /4.
25389 <li> cacosh((+-)(inf) + iNaN) returns +(inf) + iNaN.
25390 <!--page 554 indent 4-->
25391 <li> cacosh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid''
25392 floating-point exception, for finite y.
25393 <li> cacosh(NaN + i (inf)) returns +(inf) + iNaN.
25394 <li> cacosh(NaN + iNaN) returns NaN + iNaN.
25397 <a name="G.6.2.2" href="#G.6.2.2"><h5>G.6.2.2 The casinh functions</h5></a>
25400 <li> casinh(conj(z)) = conj(casinh(z)) and casinh is odd.
25401 <li> casinh(+0 + i0) returns 0 + i0.
25402 <li> casinh(x + i (inf)) returns +(inf) + ipi /2 for positive-signed finite x.
25403 <li> casinh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid''
25404 floating-point exception, for finite x.
25405 <li> casinh(+(inf) + iy) returns +(inf) + i0 for positive-signed finite y.
25406 <li> casinh(+(inf) + i (inf)) returns +(inf) + ipi /4.
25407 <li> casinh(+(inf) + iNaN) returns +(inf) + iNaN.
25408 <li> casinh(NaN + i0) returns NaN + i0.
25409 <li> casinh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid''
25410 floating-point exception, for finite nonzero y.
25411 <li> casinh(NaN + i (inf)) returns (+-)(inf) + iNaN (where the sign of the real part of the result
25413 <li> casinh(NaN + iNaN) returns NaN + iNaN.
25416 <a name="G.6.2.3" href="#G.6.2.3"><h5>G.6.2.3 The catanh functions</h5></a>
25419 <li> catanh(conj(z)) = conj(catanh(z)) and catanh is odd.
25420 <li> catanh(+0 + i0) returns +0 + i0.
25421 <li> catanh(+0 + iNaN) returns +0 + iNaN.
25422 <li> catanh(+1 + i0) returns +(inf) + i0 and raises the ''divide-by-zero'' floating-point
25424 <li> catanh(x + i (inf)) returns +0 + ipi /2, for finite positive-signed x.
25425 <li> catanh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid''
25426 floating-point exception, for nonzero finite x.
25427 <li> catanh(+(inf) + iy) returns +0 + ipi /2, for finite positive-signed y.
25428 <li> catanh(+(inf) + i (inf)) returns +0 + ipi /2.
25429 <li> catanh(+(inf) + iNaN) returns +0 + iNaN.
25430 <!--page 555 indent 4-->
25431 <li> catanh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid''
25432 floating-point exception, for finite y.
25433 <li> catanh(NaN + i (inf)) returns (+-)0 + ipi /2 (where the sign of the real part of the result is
25435 <li> catanh(NaN + iNaN) returns NaN + iNaN.
25438 <a name="G.6.2.4" href="#G.6.2.4"><h5>G.6.2.4 The ccosh functions</h5></a>
25441 <li> ccosh(conj(z)) = conj(ccosh(z)) and ccosh is even.
25442 <li> ccosh(+0 + i0) returns 1 + i0.
25443 <li> ccosh(+0 + i (inf)) returns NaN (+-) i0 (where the sign of the imaginary part of the
25444 result is unspecified) and raises the ''invalid'' floating-point exception.
25445 <li> ccosh(+0 + iNaN) returns NaN (+-) i0 (where the sign of the imaginary part of the
25446 result is unspecified).
25447 <li> ccosh(x + i (inf)) returns NaN + iNaN and raises the ''invalid'' floating-point
25448 exception, for finite nonzero x.
25449 <li> ccosh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25450 point exception, for finite nonzero x.
25451 <li> ccosh(+(inf) + i0) returns +(inf) + i0.
25452 <li> ccosh(+(inf) + iy) returns +(inf) cis(y), for finite nonzero y.
25453 <li> ccosh(+(inf) + i (inf)) returns (+-)(inf) + iNaN (where the sign of the real part of the result is
25454 unspecified) and raises the ''invalid'' floating-point exception.
25455 <li> ccosh(+(inf) + iNaN) returns +(inf) + iNaN.
25456 <li> ccosh(NaN + i0) returns NaN (+-) i0 (where the sign of the imaginary part of the
25457 result is unspecified).
25458 <li> ccosh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25459 point exception, for all nonzero numbers y.
25460 <li> ccosh(NaN + iNaN) returns NaN + iNaN.
25463 <a name="G.6.2.5" href="#G.6.2.5"><h5>G.6.2.5 The csinh functions</h5></a>
25466 <li> csinh(conj(z)) = conj(csinh(z)) and csinh is odd.
25467 <li> csinh(+0 + i0) returns +0 + i0.
25468 <li> csinh(+0 + i (inf)) returns (+-)0 + iNaN (where the sign of the real part of the result is
25469 unspecified) and raises the ''invalid'' floating-point exception.
25470 <li> csinh(+0 + iNaN) returns (+-)0 + iNaN (where the sign of the real part of the result is
25472 <!--page 556 indent 4-->
25473 <li> csinh(x + i (inf)) returns NaN + iNaN and raises the ''invalid'' floating-point
25474 exception, for positive finite x.
25475 <li> csinh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25476 point exception, for finite nonzero x.
25477 <li> csinh(+(inf) + i0) returns +(inf) + i0.
25478 <li> csinh(+(inf) + iy) returns +(inf) cis(y), for positive finite y.
25479 <li> csinh(+(inf) + i (inf)) returns (+-)(inf) + iNaN (where the sign of the real part of the result is
25480 unspecified) and raises the ''invalid'' floating-point exception.
25481 <li> csinh(+(inf) + iNaN) returns (+-)(inf) + iNaN (where the sign of the real part of the result
25483 <li> csinh(NaN + i0) returns NaN + i0.
25484 <li> csinh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25485 point exception, for all nonzero numbers y.
25486 <li> csinh(NaN + iNaN) returns NaN + iNaN.
25489 <a name="G.6.2.6" href="#G.6.2.6"><h5>G.6.2.6 The ctanh functions</h5></a>
25492 <li> ctanh(conj(z)) = conj(ctanh(z))and ctanh is odd.
25493 <li> ctanh(+0 + i0) returns +0 + i0.
25494 <li> ctanh(x + i (inf)) returns NaN + iNaN and raises the ''invalid'' floating-point
25495 exception, for finite x.
25496 <li> ctanh(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25497 point exception, for finite x.
25498 <li> ctanh(+(inf) + iy) returns 1 + i0 sin(2y), for positive-signed finite y.
25499 <li> ctanh(+(inf) + i (inf)) returns 1 (+-) i0 (where the sign of the imaginary part of the result
25501 <li> ctanh(+(inf) + iNaN) returns 1 (+-) i0 (where the sign of the imaginary part of the
25502 result is unspecified).
25503 <li> ctanh(NaN + i0) returns NaN + i0.
25504 <li> ctanh(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25505 point exception, for all nonzero numbers y.
25506 <li> ctanh(NaN + iNaN) returns NaN + iNaN.
25507 <!--page 557 indent 4-->
25510 <a name="G.6.3" href="#G.6.3"><h4>G.6.3 Exponential and logarithmic functions</h4></a>
25512 <a name="G.6.3.1" href="#G.6.3.1"><h5>G.6.3.1 The cexp functions</h5></a>
25515 <li> cexp(conj(z)) = conj(cexp(z)).
25516 <li> cexp((+-)0 + i0) returns 1 + i0.
25517 <li> cexp(x + i (inf)) returns NaN + iNaN and raises the ''invalid'' floating-point
25518 exception, for finite x.
25519 <li> cexp(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25520 point exception, for finite x.
25521 <li> cexp(+(inf) + i0) returns +(inf) + i0.
25522 <li> cexp(-(inf) + iy) returns +0 cis(y), for finite y.
25523 <li> cexp(+(inf) + iy) returns +(inf) cis(y), for finite nonzero y.
25524 <li> cexp(-(inf) + i (inf)) returns (+-)0 (+-) i0 (where the signs of the real and imaginary parts of
25525 the result are unspecified).
25526 <li> cexp(+(inf) + i (inf)) returns (+-)(inf) + iNaN and raises the ''invalid'' floating-point
25527 exception (where the sign of the real part of the result is unspecified).
25528 <li> cexp(-(inf) + iNaN) returns (+-)0 (+-) i0 (where the signs of the real and imaginary parts
25529 of the result are unspecified).
25530 <li> cexp(+(inf) + iNaN) returns (+-)(inf) + iNaN (where the sign of the real part of the result
25532 <li> cexp(NaN + i0) returns NaN + i0.
25533 <li> cexp(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25534 point exception, for all nonzero numbers y.
25535 <li> cexp(NaN + iNaN) returns NaN + iNaN.
25538 <a name="G.6.3.2" href="#G.6.3.2"><h5>G.6.3.2 The clog functions</h5></a>
25541 <li> clog(conj(z)) = conj(clog(z)).
25542 <li> clog(-0 + i0) returns -(inf) + ipi and raises the ''divide-by-zero'' floating-point
25544 <li> clog(+0 + i0) returns -(inf) + i0 and raises the ''divide-by-zero'' floating-point
25546 <li> clog(x + i (inf)) returns +(inf) + ipi /2, for finite x.
25547 <li> clog(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25548 point exception, for finite x.
25549 <!--page 558 indent 4-->
25550 <li> clog(-(inf) + iy) returns +(inf) + ipi , for finite positive-signed y.
25551 <li> clog(+(inf) + iy) returns +(inf) + i0, for finite positive-signed y.
25552 <li> clog(-(inf) + i (inf)) returns +(inf) + i3pi /4.
25553 <li> clog(+(inf) + i (inf)) returns +(inf) + ipi /4.
25554 <li> clog((+-)(inf) + iNaN) returns +(inf) + iNaN.
25555 <li> clog(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25556 point exception, for finite y.
25557 <li> clog(NaN + i (inf)) returns +(inf) + iNaN.
25558 <li> clog(NaN + iNaN) returns NaN + iNaN.
25561 <a name="G.6.4" href="#G.6.4"><h4>G.6.4 Power and absolute-value functions</h4></a>
25563 <a name="G.6.4.1" href="#G.6.4.1"><h5>G.6.4.1 The cpow functions</h5></a>
25565 The cpow functions raise floating-point exceptions if appropriate for the calculation of
25566 the parts of the result, and may also raise spurious floating-point exceptions.<sup><a href="#note366"><b>366)</b></a></sup>
25569 <p><a name="note366">366)</a> This allows cpow( z , c ) to be implemented as cexp(c clog( z )) without precluding
25570 implementations that treat special cases more carefully.
25573 <a name="G.6.4.2" href="#G.6.4.2"><h5>G.6.4.2 The csqrt functions</h5></a>
25576 <li> csqrt(conj(z)) = conj(csqrt(z)).
25577 <li> csqrt((+-)0 + i0) returns +0 + i0.
25578 <li> csqrt(x + i (inf)) returns +(inf) + i (inf), for all x (including NaN).
25579 <li> csqrt(x + iNaN) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25580 point exception, for finite x.
25581 <li> csqrt(-(inf) + iy) returns +0 + i (inf), for finite positive-signed y.
25582 <li> csqrt(+(inf) + iy) returns +(inf) + i0, for finite positive-signed y.
25583 <li> csqrt(-(inf) + iNaN) returns NaN (+-) i (inf) (where the sign of the imaginary part of the
25584 result is unspecified).
25585 <li> csqrt(+(inf) + iNaN) returns +(inf) + iNaN.
25586 <li> csqrt(NaN + iy) returns NaN + iNaN and optionally raises the ''invalid'' floating-
25587 point exception, for finite y.
25588 <li> csqrt(NaN + iNaN) returns NaN + iNaN.
25593 <!--page 559 indent 4-->
25596 <a name="G.7" href="#G.7"><h3>G.7 Type-generic math <tgmath.h></h3></a>
25598 Type-generic macros that accept complex arguments also accept imaginary arguments. If
25599 an argument is imaginary, the macro expands to an expression whose type is real,
25600 imaginary, or complex, as appropriate for the particular function: if the argument is
25601 imaginary, then the types of cos, cosh, fabs, carg, cimag, and creal are real; the
25602 types of sin, tan, sinh, tanh, asin, atan, asinh, and atanh are imaginary; and
25603 the types of the others are complex.
25605 Given an imaginary argument, each of the type-generic macros cos, sin, tan, cosh,
25606 sinh, tanh, asin, atan, asinh, atanh is specified by a formula in terms of real
25608 <!--page 560 indent 4-->
25611 sin(iy) = i sinh(y)
25612 tan(iy) = i tanh(y)
25614 sinh(iy) = i sin(y)
25615 tanh(iy) = i tan(y)
25616 asin(iy) = i asinh(y)
25617 atan(iy) = i atanh(y)
25618 asinh(iy) = i asin(y)
25619 atanh(iy) = i atan(y)</pre>
25621 <a name="H" href="#H"><h2>Annex H</h2></a>
25624 Language independent arithmetic</pre>
25626 <a name="H.1" href="#H.1"><h3>H.1 Introduction</h3></a>
25628 This annex documents the extent to which the C language supports the ISO/IEC 10967-1
25629 standard for language-independent arithmetic (LIA-1). LIA-1 is more general than
25630 IEC 60559 (<a href="#F">annex F</a>) in that it covers integer and diverse floating-point arithmetics.
25632 <a name="H.2" href="#H.2"><h3>H.2 Types</h3></a>
25634 The relevant C arithmetic types meet the requirements of LIA-1 types if an
25635 implementation adds notification of exceptional arithmetic operations and meets the 1
25636 unit in the last place (ULP) accuracy requirement (LIA-1 subclause <a href="#5.2.8">5.2.8</a>).
25638 <a name="H.2.1" href="#H.2.1"><h4>H.2.1 Boolean type</h4></a>
25640 The LIA-1 data type Boolean is implemented by the C data type bool with values of
25641 true and false, all from <stdbool.h>.
25643 <a name="H.2.2" href="#H.2.2"><h4>H.2.2 Integer types</h4></a>
25645 The signed C integer types int, long int, long long int, and the corresponding
25646 unsigned types are compatible with LIA-1. If an implementation adds support for the
25647 LIA-1 exceptional values ''integer_overflow'' and ''undefined'', then those types are
25648 LIA-1 conformant types. C's unsigned integer types are ''modulo'' in the LIA-1 sense
25649 in that overflows or out-of-bounds results silently wrap. An implementation that defines
25650 signed integer types as also being modulo need not detect integer overflow, in which case,
25651 only integer divide-by-zero need be detected.
25653 The parameters for the integer data types can be accessed by the following:
25654 maxint INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX,
25657 minint INT_MIN, LONG_MIN, LLONG_MIN
25659 The parameter ''bounded'' is always true, and is not provided. The parameter ''minint''
25660 is always 0 for the unsigned types, and is not provided for those types.
25661 <!--page 561 indent 4-->
25663 <a name="H.2.2.1" href="#H.2.2.1"><h5>H.2.2.1 Integer operations</h5></a>
25665 The integer operations on integer types are the following:
25672 absI abs(x), labs(x), llabs(x)
25679 where x and y are expressions of the same integer type.
25681 <a name="H.2.3" href="#H.2.3"><h4>H.2.3 Floating-point types</h4></a>
25683 The C floating-point types float, double, and long double are compatible with
25684 LIA-1. If an implementation adds support for the LIA-1 exceptional values
25685 ''underflow'', ''floating_overflow'', and ''"undefined'', then those types are conformant
25686 with LIA-1. An implementation that uses IEC 60559 floating-point formats and
25687 operations (see <a href="#F">annex F</a>) along with IEC 60559 status flags and traps has LIA-1
25690 <a name="H.2.3.1" href="#H.2.3.1"><h5>H.2.3.1 Floating-point parameters</h5></a>
25692 The parameters for a floating point data type can be accessed by the following:
25694 p FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG
25695 emax FLT_MAX_EXP, DBL_MAX_EXP, LDBL_MAX_EXP
25696 emin FLT_MIN_EXP, DBL_MIN_EXP, LDBL_MIN_EXP
25698 The derived constants for the floating point types are accessed by the following:
25699 <!--page 562 indent 4-->
25700 fmax FLT_MAX, DBL_MAX, LDBL_MAX
25701 fminN FLT_MIN, DBL_MIN, LDBL_MIN
25702 epsilon FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON
25703 rnd_style FLT_ROUNDS
25705 <a name="H.2.3.2" href="#H.2.3.2"><h5>H.2.3.2 Floating-point operations</h5></a>
25707 The floating-point operations on floating-point types are the following:
25713 absF fabsf(x), fabs(x), fabsl(x)
25714 exponentF 1.f+logbf(x), 1.0+logb(x), 1.L+logbl(x)
25715 scaleF scalbnf(x, n), scalbn(x, n), scalbnl(x, n),
25717 scalblnf(x, li), scalbln(x, li), scalblnl(x, li)</pre>
25718 intpartF modff(x, &y), modf(x, &y), modfl(x, &y)
25719 fractpartF modff(x, &y), modf(x, &y), modfl(x, &y)
25726 where x and y are expressions of the same floating point type, n is of type int, and li
25727 is of type long int.
25729 <a name="H.2.3.3" href="#H.2.3.3"><h5>H.2.3.3 Rounding styles</h5></a>
25731 The C Standard requires all floating types to use the same radix and rounding style, so
25732 that only one identifier for each is provided to map to LIA-1.
25734 The FLT_ROUNDS parameter can be used to indicate the LIA-1 rounding styles:
25735 truncate FLT_ROUNDS == 0
25736 <!--page 563 indent 4-->
25737 nearest FLT_ROUNDS == 1
25738 other FLT_ROUNDS != 0 && FLT_ROUNDS != 1
25739 provided that an implementation extends FLT_ROUNDS to cover the rounding style used
25740 in all relevant LIA-1 operations, not just addition as in C.
25742 <a name="H.2.4" href="#H.2.4"><h4>H.2.4 Type conversions</h4></a>
25744 The LIA-1 type conversions are the following type casts:
25745 cvtI' -> I (int)i, (long int)i, (long long int)i,
25747 (unsigned int)i, (unsigned long int)i,
25748 (unsigned long long int)i</pre>
25749 cvtF -> I (int)x, (long int)x, (long long int)x,
25751 (unsigned int)x, (unsigned long int)x,
25752 (unsigned long long int)x</pre>
25753 cvtI -> F (float)i, (double)i, (long double)i
25754 cvtF' -> F (float)x, (double)x, (long double)x
25756 In the above conversions from floating to integer, the use of (cast)x can be replaced with
25757 (cast)round(x), (cast)rint(x), (cast)nearbyint(x), (cast)trunc(x),
25758 (cast)ceil(x), or (cast)floor(x). In addition, C's floating-point to integer
25759 conversion functions, lrint(), llrint(), lround(), and llround(), can be
25760 used. They all meet LIA-1's requirements on floating to integer rounding for in-range
25761 values. For out-of-range values, the conversions shall silently wrap for the modulo types.
25763 The fmod() function is useful for doing silent wrapping to unsigned integer types, e.g.,
25764 fmod( fabs(rint(x)), 65536.0 ) or (0.0 <= (y = fmod( rint(x),
25765 65536.0 )) ? y : 65536.0 + y) will compute an integer value in the range 0.0
25766 to 65535.0 which can then be cast to unsigned short int. But, the
25767 remainder() function is not useful for doing silent wrapping to signed integer types,
25768 e.g., remainder( rint(x), 65536.0 ) will compute an integer value in the
25769 range -32767.0 to +32768.0 which is not, in general, in the range of signed short
25772 C's conversions (casts) from floating-point to floating-point can meet LIA-1
25773 requirements if an implementation uses round-to-nearest (IEC 60559 default).
25775 C's conversions (casts) from integer to floating-point can meet LIA-1 requirements if an
25776 implementation uses round-to-nearest.
25777 <!--page 564 indent 4-->
25779 <a name="H.3" href="#H.3"><h3>H.3 Notification</h3></a>
25781 Notification is the process by which a user or program is informed that an exceptional
25782 arithmetic operation has occurred. C's operations are compatible with LIA-1 in that C
25783 allows an implementation to cause a notification to occur when any arithmetic operation
25784 returns an exceptional value as defined in LIA-1 clause 5.
25786 <a name="H.3.1" href="#H.3.1"><h4>H.3.1 Notification alternatives</h4></a>
25788 LIA-1 requires at least the following two alternatives for handling of notifications:
25789 setting indicators or trap-and-terminate. LIA-1 allows a third alternative: trap-and-
25792 An implementation need only support a given notification alternative for the entire
25793 program. An implementation may support the ability to switch between notification
25794 alternatives during execution, but is not required to do so. An implementation can
25795 provide separate selection for each kind of notification, but this is not required.
25797 C allows an implementation to provide notification. C's SIGFPE (for traps) and
25798 FE_INVALID, FE_DIVBYZERO, FE_OVERFLOW, FE_UNDERFLOW (for indicators)
25799 can provide LIA-1 notification.
25801 C's signal handlers are compatible with LIA-1. Default handling of SIGFPE can
25802 provide trap-and-terminate behavior, except for those LIA-1 operations implemented by
25803 math library function calls. User-provided signal handlers for SIGFPE allow for trap-
25804 and-resume behavior with the same constraint.
25806 <a name="H.3.1.1" href="#H.3.1.1"><h5>H.3.1.1 Indicators</h5></a>
25808 C's <fenv.h> status flags are compatible with the LIA-1 indicators.
25810 The following mapping is for floating-point types:
25811 undefined FE_INVALID, FE_DIVBYZERO
25812 floating_overflow FE_OVERFLOW
25813 underflow FE_UNDERFLOW
25815 The floating-point indicator interrogation and manipulation operations are:
25816 set_indicators feraiseexcept(i)
25817 clear_indicators feclearexcept(i)
25818 test_indicators fetestexcept(i)
25819 current_indicators fetestexcept(FE_ALL_EXCEPT)
25820 where i is an expression of type int representing a subset of the LIA-1 indicators.
25822 C allows an implementation to provide the following LIA-1 required behavior: at
25823 program termination if any indicator is set the implementation shall send an unambiguous
25824 <!--page 565 indent 4-->
25825 and ''hard to ignore'' message (see LIA-1 subclause <a href="#6.1.2">6.1.2</a>)
25827 LIA-1 does not make the distinction between floating-point and integer for ''undefined''.
25828 This documentation makes that distinction because <fenv.h> covers only the floating-
25831 <a name="H.3.1.2" href="#H.3.1.2"><h5>H.3.1.2 Traps</h5></a>
25833 C is compatible with LIA-1's trap requirements for arithmetic operations, but not for
25834 math library functions (which are not permitted to invoke a user's signal handler for
25835 SIGFPE). An implementation can provide an alternative of notification through
25836 termination with a ''hard-to-ignore'' message (see LIA-1 subclause <a href="#6.1.3">6.1.3</a>).
25838 LIA-1 does not require that traps be precise.
25840 C does require that SIGFPE be the signal corresponding to LIA-1 arithmetic exceptions,
25841 if there is any signal raised for them.
25843 C supports signal handlers for SIGFPE and allows trapping of LIA-1 arithmetic
25844 exceptions. When LIA-1 arithmetic exceptions do trap, C's signal-handler mechanism
25845 allows trap-and-terminate (either default implementation behavior or user replacement for
25846 it) or trap-and-resume, at the programmer's option.
25847 <!--page 566 indent 4-->
25849 <a name="I" href="#I"><h2>Annex I</h2></a>
25853 Common warnings</pre>
25854 An implementation may generate warnings in many situations, none of which are
25855 specified as part of this International Standard. The following are a few of the more
25859 <li> A new struct or union type appears in a function prototype (<a href="#6.2.1">6.2.1</a>, <a href="#6.7.2.3">6.7.2.3</a>).
25860 <li> A block with initialization of an object that has automatic storage duration is jumped
25861 into (<a href="#6.2.4">6.2.4</a>).
25862 <li> An implicit narrowing conversion is encountered, such as the assignment of a long
25863 int or a double to an int, or a pointer to void to a pointer to any type other than
25864 a character type (<a href="#6.3">6.3</a>).
25865 <li> A hexadecimal floating constant cannot be represented exactly in its evaluation format
25866 (<a href="#6.4.4.2">6.4.4.2</a>).
25867 <li> An integer character constant includes more than one character or a wide character
25868 constant includes more than one multibyte character (<a href="#6.4.4.4">6.4.4.4</a>).
25869 <li> The characters /* are found in a comment (<a href="#6.4.7">6.4.7</a>).
25870 <li> An ''unordered'' binary operator (not comma, &&, or ||) contains a side effect to an
25871 lvalue in one operand, and a side effect to, or an access to the value of, the identical
25872 lvalue in the other operand (<a href="#6.5">6.5</a>).
25873 <li> A function is called but no prototype has been supplied (<a href="#6.5.2.2">6.5.2.2</a>).
25874 <li> The arguments in a function call do not agree in number and type with those of the
25875 parameters in a function definition that is not a prototype (<a href="#6.5.2.2">6.5.2.2</a>).
25876 <li> An object is defined but not used (<a href="#6.7">6.7</a>).
25877 <li> A value is given to an object of an enumerated type other than by assignment of an
25878 enumeration constant that is a member of that type, or an enumeration object that has
25879 the same type, or the value of a function that returns the same enumerated type
25880 (<a href="#6.7.2.2">6.7.2.2</a>).
25881 <li> An aggregate has a partly bracketed initialization (<a href="#6.7.8">6.7.8</a>).
25882 <li> A statement cannot be reached (<a href="#6.8">6.8</a>).
25883 <li> A statement with no apparent effect is encountered (<a href="#6.8">6.8</a>).
25884 <li> A constant expression is used as the controlling expression of a selection statement
25885 (<a href="#6.8.4">6.8.4</a>).
25886 <!--page 567 indent 0-->
25887 <li> An incorrectly formed preprocessing group is encountered while skipping a
25888 preprocessing group (<a href="#6.10.1">6.10.1</a>).
25889 <li> An unrecognized #pragma directive is encountered (<a href="#6.10.6">6.10.6</a>).
25890 <!--page 568 indent 4-->
25893 <a name="J" href="#J"><h2>Annex J</h2></a>
25897 Portability issues</pre>
25898 This annex collects some information about portability that appears in this International
25901 <a name="J.1" href="#J.1"><h3>J.1 Unspecified behavior</h3></a>
25903 The following are unspecified:
25905 <li> The manner and timing of static initialization (<a href="#5.1.2">5.1.2</a>).
25906 <li> The termination status returned to the hosted environment if the return type of main
25907 is not compatible with int (<a href="#5.1.2.2.3">5.1.2.2.3</a>).
25908 <li> The behavior of the display device if a printing character is written when the active
25909 position is at the final position of a line (<a href="#5.2.2">5.2.2</a>).
25910 <li> The behavior of the display device if a backspace character is written when the active
25911 position is at the initial position of a line (<a href="#5.2.2">5.2.2</a>).
25912 <li> The behavior of the display device if a horizontal tab character is written when the
25913 active position is at or past the last defined horizontal tabulation position (<a href="#5.2.2">5.2.2</a>).
25914 <li> The behavior of the display device if a vertical tab character is written when the active
25915 position is at or past the last defined vertical tabulation position (<a href="#5.2.2">5.2.2</a>).
25916 <li> How an extended source character that does not correspond to a universal character
25917 name counts toward the significant initial characters in an external identifier (<a href="#5.2.4.1">5.2.4.1</a>).
25918 <li> Many aspects of the representations of types (<a href="#6.2.6">6.2.6</a>).
25919 <li> The value of padding bytes when storing values in structures or unions (<a href="#6.2.6.1">6.2.6.1</a>).
25920 <li> The values of bytes that correspond to union members other than the one last stored
25921 into (<a href="#6.2.6.1">6.2.6.1</a>).
25922 <li> The representation used when storing a value in an object that has more than one
25923 object representation for that value (<a href="#6.2.6.1">6.2.6.1</a>).
25924 <li> The values of any padding bits in integer representations (<a href="#6.2.6.2">6.2.6.2</a>).
25925 <li> Whether certain operators can generate negative zeros and whether a negative zero
25926 becomes a normal zero when stored in an object (<a href="#6.2.6.2">6.2.6.2</a>).
25927 <li> Whether two string literals result in distinct arrays (<a href="#6.4.5">6.4.5</a>).
25928 <li> The order in which subexpressions are evaluated and the order in which side effects
25929 take place, except as specified for the function-call (), &&, ||, ? :, and comma
25930 <!--page 569 indent 0-->
25931 operators (<a href="#6.5">6.5</a>).
25932 <li> The order in which the function designator, arguments, and subexpressions within the
25933 arguments are evaluated in a function call (<a href="#6.5.2.2">6.5.2.2</a>).
25934 <li> The order of side effects among compound literal initialization list expressions
25935 (<a href="#6.5.2.5">6.5.2.5</a>).
25936 <li> The order in which the operands of an assignment operator are evaluated (<a href="#6.5.16">6.5.16</a>).
25937 <li> The alignment of the addressable storage unit allocated to hold a bit-field (<a href="#6.7.2.1">6.7.2.1</a>).
25938 <li> Whether a call to an inline function uses the inline definition or the external definition
25939 of the function (<a href="#6.7.4">6.7.4</a>).
25940 <li> Whether or not a size expression is evaluated when it is part of the operand of a
25941 sizeof operator and changing the value of the size expression would not affect the
25942 result of the operator (<a href="#6.7.6.2">6.7.6.2</a>).
25943 <li> The order in which any side effects occur among the initialization list expressions in
25944 an initializer (<a href="#6.7.9">6.7.9</a>).
25945 <li> The layout of storage for function parameters (<a href="#6.9.1">6.9.1</a>).
25946 <li> When a fully expanded macro replacement list contains a function-like macro name
25947 as its last preprocessing token and the next preprocessing token from the source file is
25948 a (, and the fully expanded replacement of that macro ends with the name of the first
25949 macro and the next preprocessing token from the source file is again a (, whether that
25950 is considered a nested replacement (<a href="#6.10.3">6.10.3</a>).
25951 <li> The order in which # and ## operations are evaluated during macro substitution
25952 (<a href="#6.10.3.2">6.10.3.2</a>, <a href="#6.10.3.3">6.10.3.3</a>).
25953 <li> The state of the floating-point status flags when execution passes from a part of the *
25954 program translated with FENV_ACCESS ''off'' to a part translated with
25955 FENV_ACCESS ''on'' (<a href="#7.6.1">7.6.1</a>).
25956 <li> The order in which feraiseexcept raises floating-point exceptions, except as
25957 stated in <a href="#F.8.6">F.8.6</a> (<a href="#7.6.2.3">7.6.2.3</a>).
25958 <li> Whether math_errhandling is a macro or an identifier with external linkage
25959 (<a href="#7.12">7.12</a>).
25960 <li> The results of the frexp functions when the specified value is not a floating-point
25961 number (<a href="#7.12.6.4">7.12.6.4</a>).
25962 <li> The numeric result of the ilogb functions when the correct value is outside the
25963 range of the return type (<a href="#7.12.6.5">7.12.6.5</a>, <a href="#F.10.3.5">F.10.3.5</a>).
25964 <li> The result of rounding when the value is out of range (<a href="#7.12.9.5">7.12.9.5</a>, <a href="#7.12.9.7">7.12.9.7</a>, <a href="#F.10.6.5">F.10.6.5</a>).
25965 <!--page 570 indent 0-->
25966 <li> The value stored by the remquo functions in the object pointed to by quo when y is
25967 zero (<a href="#7.12.10.3">7.12.10.3</a>).
25968 <li> Whether a comparison macro argument that is represented in a format wider than its
25969 semantic type is converted to the semantic type (<a href="#7.12.14">7.12.14</a>).
25970 <li> Whether setjmp is a macro or an identifier with external linkage (<a href="#7.13">7.13</a>).
25971 <li> Whether va_copy and va_end are macros or identifiers with external linkage
25972 (<a href="#7.16.1">7.16.1</a>).
25973 <li> The hexadecimal digit before the decimal point when a non-normalized floating-point
25974 number is printed with an a or A conversion specifier (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
25975 <li> The value of the file position indicator after a successful call to the ungetc function
25976 for a text stream, or the ungetwc function for any stream, until all pushed-back
25977 characters are read or discarded (<a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.28.3.10">7.28.3.10</a>).
25978 <li> The details of the value stored by the fgetpos function (<a href="#7.21.9.1">7.21.9.1</a>).
25979 <li> The details of the value returned by the ftell function for a text stream (<a href="#7.21.9.4">7.21.9.4</a>).
25980 <li> Whether the strtod, strtof, strtold, wcstod, wcstof, and wcstold
25981 functions convert a minus-signed sequence to a negative number directly or by
25982 negating the value resulting from converting the corresponding unsigned sequence
25983 (<a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>).
25984 <li> The order and contiguity of storage allocated by successive calls to the calloc,
25985 malloc, and realloc functions (<a href="#7.22.3">7.22.3</a>).
25986 <li> The amount of storage allocated by a successful call to the calloc, malloc, or
25987 realloc function when 0 bytes was requested (<a href="#7.22.3">7.22.3</a>).
25988 <li> Which of two elements that compare as equal is matched by the bsearch function
25989 (<a href="#7.22.5.1">7.22.5.1</a>).
25990 <li> The order of two elements that compare as equal in an array sorted by the qsort
25991 function (<a href="#7.22.5.2">7.22.5.2</a>).
25992 <li> The encoding of the calendar time returned by the time function (<a href="#7.26.2.4">7.26.2.4</a>).
25993 <li> The characters stored by the strftime or wcsftime function if any of the time
25994 values being converted is outside the normal range (<a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.5.1">7.28.5.1</a>).
25995 <li> The conversion state after an encoding error occurs (<a href="#7.28.6.3.2">7.28.6.3.2</a>, <a href="#7.28.6.3.3">7.28.6.3.3</a>, <a href="#7.28.6.4.1">7.28.6.4.1</a>,
25996 <a href="#7.28.6.4.2">7.28.6.4.2</a>,
25997 <li> The resulting value when the ''invalid'' floating-point exception is raised during
25998 IEC 60559 floating to integer conversion (<a href="#F.4">F.4</a>).
25999 <!--page 571 indent 4-->
26000 <li> Whether conversion of non-integer IEC 60559 floating values to integer raises the
26001 ''inexact'' floating-point exception (<a href="#F.4">F.4</a>).
26002 <li> Whether or when library functions in <math.h> raise the ''inexact'' floating-point
26003 exception in an IEC 60559 conformant implementation (<a href="#F.10">F.10</a>).
26004 <li> Whether or when library functions in <math.h> raise an undeserved ''underflow''
26005 floating-point exception in an IEC 60559 conformant implementation (<a href="#F.10">F.10</a>).
26006 <li> The exponent value stored by frexp for a NaN or infinity (<a href="#F.10.3.4">F.10.3.4</a>).
26007 <li> The numeric result returned by the lrint, llrint, lround, and llround
26008 functions if the rounded value is outside the range of the return type (<a href="#F.10.6.5">F.10.6.5</a>,
26009 <a href="#F.10.6.7">F.10.6.7</a>).
26010 <li> The sign of one part of the complex result of several math functions for certain
26011 special cases in IEC 60559 compatible implementations (<a href="#G.6.1.1">G.6.1.1</a>, <a href="#G.6.2.2">G.6.2.2</a>, <a href="#G.6.2.3">G.6.2.3</a>,
26012 <a href="#G.6.2.4">G.6.2.4</a>, <a href="#G.6.2.5">G.6.2.5</a>, <a href="#G.6.2.6">G.6.2.6</a>, <a href="#G.6.3.1">G.6.3.1</a>, <a href="#G.6.4.2">G.6.4.2</a>).
26015 <a name="J.2" href="#J.2"><h3>J.2 Undefined behavior</h3></a>
26017 The behavior is undefined in the following circumstances:
26019 <li> A ''shall'' or ''shall not'' requirement that appears outside of a constraint is violated
26021 <li> A nonempty source file does not end in a new-line character which is not immediately
26022 preceded by a backslash character or ends in a partial preprocessing token or
26023 comment (<a href="#5.1.1.2">5.1.1.2</a>).
26024 <li> Token concatenation produces a character sequence matching the syntax of a
26025 universal character name (<a href="#5.1.1.2">5.1.1.2</a>).
26026 <li> A program in a hosted environment does not define a function named main using one
26027 of the specified forms (<a href="#5.1.2.2.1">5.1.2.2.1</a>).
26028 <li> The execution of a program contains a data race (<a href="#5.1.2.4">5.1.2.4</a>).
26029 <li> A character not in the basic source character set is encountered in a source file, except
26030 in an identifier, a character constant, a string literal, a header name, a comment, or a
26031 preprocessing token that is never converted to a token (<a href="#5.2.1">5.2.1</a>).
26032 <li> An identifier, comment, string literal, character constant, or header name contains an
26033 invalid multibyte character or does not begin and end in the initial shift state (<a href="#5.2.1.2">5.2.1.2</a>).
26034 <li> The same identifier has both internal and external linkage in the same translation unit
26035 (<a href="#6.2.2">6.2.2</a>).
26036 <li> An object is referred to outside of its lifetime (<a href="#6.2.4">6.2.4</a>).
26037 <!--page 572 indent 0-->
26038 <li> The value of a pointer to an object whose lifetime has ended is used (<a href="#6.2.4">6.2.4</a>).
26039 <li> The value of an object with automatic storage duration is used while it is
26040 indeterminate (<a href="#6.2.4">6.2.4</a>, <a href="#6.7.9">6.7.9</a>, <a href="#6.8">6.8</a>).
26041 <li> A trap representation is read by an lvalue expression that does not have character type
26042 (<a href="#6.2.6.1">6.2.6.1</a>).
26043 <li> A trap representation is produced by a side effect that modifies any part of the object
26044 using an lvalue expression that does not have character type (<a href="#6.2.6.1">6.2.6.1</a>).
26045 <li> The operands to certain operators are such that they could produce a negative zero
26046 result, but the implementation does not support negative zeros (<a href="#6.2.6.2">6.2.6.2</a>).
26047 <li> Two declarations of the same object or function specify types that are not compatible
26048 (<a href="#6.2.7">6.2.7</a>).
26049 <li> A program requires the formation of a composite type from a variable length array
26050 type whose size is specified by an expression that is not evaluated (<a href="#6.2.7">6.2.7</a>).
26051 <li> Conversion to or from an integer type produces a value outside the range that can be
26052 represented (<a href="#6.3.1.4">6.3.1.4</a>).
26053 <li> Demotion of one real floating type to another produces a value outside the range that
26054 can be represented (<a href="#6.3.1.5">6.3.1.5</a>).
26055 <li> An lvalue does not designate an object when evaluated (<a href="#6.3.2.1">6.3.2.1</a>).
26056 <li> A non-array lvalue with an incomplete type is used in a context that requires the value
26057 of the designated object (<a href="#6.3.2.1">6.3.2.1</a>).
26058 <li> An lvalue designating an object of automatic storage duration that could have been
26059 declared with the register storage class is used in a context that requires the value
26060 of the designated object, but the object is uninitialized. (<a href="#6.3.2.1">6.3.2.1</a>).
26061 <li> An lvalue having array type is converted to a pointer to the initial element of the
26062 array, and the array object has register storage class (<a href="#6.3.2.1">6.3.2.1</a>).
26063 <li> An attempt is made to use the value of a void expression, or an implicit or explicit
26064 conversion (except to void) is applied to a void expression (<a href="#6.3.2.2">6.3.2.2</a>).
26065 <li> Conversion of a pointer to an integer type produces a value outside the range that can
26066 be represented (<a href="#6.3.2.3">6.3.2.3</a>).
26067 <li> Conversion between two pointer types produces a result that is incorrectly aligned
26068 (<a href="#6.3.2.3">6.3.2.3</a>).
26069 <li> A pointer is used to call a function whose type is not compatible with the referenced
26070 type (<a href="#6.3.2.3">6.3.2.3</a>).
26071 <!--page 573 indent 0-->
26072 <li> An unmatched ' or " character is encountered on a logical source line during
26073 tokenization (<a href="#6.4">6.4</a>).
26074 <li> A reserved keyword token is used in translation phase 7 or 8 for some purpose other
26075 than as a keyword (<a href="#6.4.1">6.4.1</a>).
26076 <li> A universal character name in an identifier does not designate a character whose
26077 encoding falls into one of the specified ranges (<a href="#6.4.2.1">6.4.2.1</a>).
26078 <li> The initial character of an identifier is a universal character name designating a digit
26079 (<a href="#6.4.2.1">6.4.2.1</a>).
26080 <li> Two identifiers differ only in nonsignificant characters (<a href="#6.4.2.1">6.4.2.1</a>).
26081 <li> The identifier __func__ is explicitly declared (<a href="#6.4.2.2">6.4.2.2</a>).
26082 <li> The program attempts to modify a string literal (<a href="#6.4.5">6.4.5</a>).
26083 <li> The characters ', \, ", //, or /* occur in the sequence between the < and >
26084 delimiters, or the characters ', \, //, or /* occur in the sequence between the "
26085 delimiters, in a header name preprocessing token (<a href="#6.4.7">6.4.7</a>).
26086 <li> A side effect on a scalar object is unsequenced relative to either a different side effect
26087 on the same scalar object or a value computation using the value of the same scalar
26088 object (<a href="#6.5">6.5</a>).
26089 <li> An exceptional condition occurs during the evaluation of an expression (<a href="#6.5">6.5</a>).
26090 <li> An object has its stored value accessed other than by an lvalue of an allowable type
26091 (<a href="#6.5">6.5</a>).
26092 <li> For a call to a function without a function prototype in scope, the number of *
26093 arguments does not equal the number of parameters (<a href="#6.5.2.2">6.5.2.2</a>).
26094 <li> For call to a function without a function prototype in scope where the function is
26095 defined with a function prototype, either the prototype ends with an ellipsis or the
26096 types of the arguments after promotion are not compatible with the types of the
26097 parameters (<a href="#6.5.2.2">6.5.2.2</a>).
26098 <li> For a call to a function without a function prototype in scope where the function is not
26099 defined with a function prototype, the types of the arguments after promotion are not
26100 compatible with those of the parameters after promotion (with certain exceptions)
26101 (<a href="#6.5.2.2">6.5.2.2</a>).
26102 <li> A function is defined with a type that is not compatible with the type (of the
26103 expression) pointed to by the expression that denotes the called function (<a href="#6.5.2.2">6.5.2.2</a>).
26104 <li> A member of an atomic structure or union is accessed (<a href="#6.5.2.3">6.5.2.3</a>).
26105 <li> The operand of the unary * operator has an invalid value (<a href="#6.5.3.2">6.5.3.2</a>).
26106 <!--page 574 indent 0-->
26107 <li> A pointer is converted to other than an integer or pointer type (<a href="#6.5.4">6.5.4</a>).
26108 <li> The value of the second operand of the / or % operator is zero (<a href="#6.5.5">6.5.5</a>).
26109 <li> Addition or subtraction of a pointer into, or just beyond, an array object and an
26110 integer type produces a result that does not point into, or just beyond, the same array
26111 object (<a href="#6.5.6">6.5.6</a>).
26112 <li> Addition or subtraction of a pointer into, or just beyond, an array object and an
26113 integer type produces a result that points just beyond the array object and is used as
26114 the operand of a unary * operator that is evaluated (<a href="#6.5.6">6.5.6</a>).
26115 <li> Pointers that do not point into, or just beyond, the same array object are subtracted
26116 (<a href="#6.5.6">6.5.6</a>).
26117 <li> An array subscript is out of range, even if an object is apparently accessible with the
26118 given subscript (as in the lvalue expression a[1][7] given the declaration int
26119 a[4][5]) (<a href="#6.5.6">6.5.6</a>).
26120 <li> The result of subtracting two pointers is not representable in an object of type
26121 ptrdiff_t (<a href="#6.5.6">6.5.6</a>).
26122 <li> An expression is shifted by a negative number or by an amount greater than or equal
26123 to the width of the promoted expression (<a href="#6.5.7">6.5.7</a>).
26124 <li> An expression having signed promoted type is left-shifted and either the value of the
26125 expression is negative or the result of shifting would be not be representable in the
26126 promoted type (<a href="#6.5.7">6.5.7</a>).
26127 <li> Pointers that do not point to the same aggregate or union (nor just beyond the same
26128 array object) are compared using relational operators (<a href="#6.5.8">6.5.8</a>).
26129 <li> An object is assigned to an inexactly overlapping object or to an exactly overlapping
26130 object with incompatible type (<a href="#6.5.16.1">6.5.16.1</a>).
26131 <li> An expression that is required to be an integer constant expression does not have an
26132 integer type; has operands that are not integer constants, enumeration constants,
26133 character constants, sizeof expressions whose results are integer constants, or
26134 immediately-cast floating constants; or contains casts (outside operands to sizeof
26135 operators) other than conversions of arithmetic types to integer types (<a href="#6.6">6.6</a>).
26136 <li> A constant expression in an initializer is not, or does not evaluate to, one of the
26137 following: an arithmetic constant expression, a null pointer constant, an address
26138 constant, or an address constant for a complete object type plus or minus an integer
26139 constant expression (<a href="#6.6">6.6</a>).
26140 <li> An arithmetic constant expression does not have arithmetic type; has operands that
26141 are not integer constants, floating constants, enumeration constants, character
26142 constants, or sizeof expressions; or contains casts (outside operands to sizeof
26143 <!--page 575 indent 0-->
26144 operators) other than conversions of arithmetic types to arithmetic types (<a href="#6.6">6.6</a>).
26145 <li> The value of an object is accessed by an array-subscript [], member-access . or ->,
26146 address &, or indirection * operator or a pointer cast in creating an address constant
26147 (<a href="#6.6">6.6</a>).
26148 <li> An identifier for an object is declared with no linkage and the type of the object is
26149 incomplete after its declarator, or after its init-declarator if it has an initializer (<a href="#6.7">6.7</a>).
26150 <li> A function is declared at block scope with an explicit storage-class specifier other
26151 than extern (<a href="#6.7.1">6.7.1</a>).
26152 <li> A structure or union is defined as containing no named members, no anonymous
26153 structures, and no anonymous unions (<a href="#6.7.2.1">6.7.2.1</a>).
26154 <li> An attempt is made to access, or generate a pointer to just past, a flexible array
26155 member of a structure when the referenced object provides no elements for that array
26156 (<a href="#6.7.2.1">6.7.2.1</a>).
26157 <li> When the complete type is needed, an incomplete structure or union type is not
26158 completed in the same scope by another declaration of the tag that defines the content
26159 (<a href="#6.7.2.3">6.7.2.3</a>).
26160 <li> An attempt is made to modify an object defined with a const-qualified type through
26161 use of an lvalue with non-const-qualified type (<a href="#6.7.3">6.7.3</a>).
26162 <li> An attempt is made to refer to an object defined with a volatile-qualified type through
26163 use of an lvalue with non-volatile-qualified type (<a href="#6.7.3">6.7.3</a>).
26164 <li> The specification of a function type includes any type qualifiers (<a href="#6.7.3">6.7.3</a>). *
26165 <li> Two qualified types that are required to be compatible do not have the identically
26166 qualified version of a compatible type (<a href="#6.7.3">6.7.3</a>).
26167 <li> An object which has been modified is accessed through a restrict-qualified pointer to
26168 a const-qualified type, or through a restrict-qualified pointer and another pointer that
26169 are not both based on the same object (<a href="#6.7.3.1">6.7.3.1</a>).
26170 <li> A restrict-qualified pointer is assigned a value based on another restricted pointer
26171 whose associated block neither began execution before the block associated with this
26172 pointer, nor ended before the assignment (<a href="#6.7.3.1">6.7.3.1</a>).
26173 <li> A function with external linkage is declared with an inline function specifier, but is
26174 not also defined in the same translation unit (<a href="#6.7.4">6.7.4</a>).
26175 <li> A function declared with a _Noreturn function specifier returns to its caller (<a href="#6.7.4">6.7.4</a>).
26176 <li> The definition of an object has an alignment specifier and another declaration of that
26177 object has a different alignment specifier (<a href="#6.7.5">6.7.5</a>).
26178 <!--page 576 indent 0-->
26179 <li> Declarations of an object in different translation units have different alignment
26180 specifiers (<a href="#6.7.5">6.7.5</a>).
26181 <li> Two pointer types that are required to be compatible are not identically qualified, or
26182 are not pointers to compatible types (<a href="#6.7.6.1">6.7.6.1</a>).
26183 <li> The size expression in an array declaration is not a constant expression and evaluates
26184 at program execution time to a nonpositive value (<a href="#6.7.6.2">6.7.6.2</a>).
26185 <li> In a context requiring two array types to be compatible, they do not have compatible
26186 element types, or their size specifiers evaluate to unequal values (<a href="#6.7.6.2">6.7.6.2</a>).
26187 <li> A declaration of an array parameter includes the keyword static within the [ and
26188 ] and the corresponding argument does not provide access to the first element of an
26189 array with at least the specified number of elements (<a href="#6.7.6.3">6.7.6.3</a>).
26190 <li> A storage-class specifier or type qualifier modifies the keyword void as a function
26191 parameter type list (<a href="#6.7.6.3">6.7.6.3</a>).
26192 <li> In a context requiring two function types to be compatible, they do not have
26193 compatible return types, or their parameters disagree in use of the ellipsis terminator
26194 or the number and type of parameters (after default argument promotion, when there
26195 is no parameter type list or when one type is specified by a function definition with an
26196 identifier list) (<a href="#6.7.6.3">6.7.6.3</a>).
26197 <li> The value of an unnamed member of a structure or union is used (<a href="#6.7.9">6.7.9</a>).
26198 <li> The initializer for a scalar is neither a single expression nor a single expression
26199 enclosed in braces (<a href="#6.7.9">6.7.9</a>).
26200 <li> The initializer for a structure or union object that has automatic storage duration is
26201 neither an initializer list nor a single expression that has compatible structure or union
26202 type (<a href="#6.7.9">6.7.9</a>).
26203 <li> The initializer for an aggregate or union, other than an array initialized by a string
26204 literal, is not a brace-enclosed list of initializers for its elements or members (<a href="#6.7.9">6.7.9</a>).
26205 <li> An identifier with external linkage is used, but in the program there does not exist
26206 exactly one external definition for the identifier, or the identifier is not used and there
26207 exist multiple external definitions for the identifier (<a href="#6.9">6.9</a>).
26208 <li> A function definition includes an identifier list, but the types of the parameters are not
26209 declared in a following declaration list (<a href="#6.9.1">6.9.1</a>).
26210 <li> An adjusted parameter type in a function definition is not a complete object type
26211 (<a href="#6.9.1">6.9.1</a>).
26212 <li> A function that accepts a variable number of arguments is defined without a
26213 parameter type list that ends with the ellipsis notation (<a href="#6.9.1">6.9.1</a>).
26214 <!--page 577 indent 0-->
26215 <li> The } that terminates a function is reached, and the value of the function call is used
26216 by the caller (<a href="#6.9.1">6.9.1</a>).
26217 <li> An identifier for an object with internal linkage and an incomplete type is declared
26218 with a tentative definition (<a href="#6.9.2">6.9.2</a>).
26219 <li> The token defined is generated during the expansion of a #if or #elif
26220 preprocessing directive, or the use of the defined unary operator does not match
26221 one of the two specified forms prior to macro replacement (<a href="#6.10.1">6.10.1</a>).
26222 <li> The #include preprocessing directive that results after expansion does not match
26223 one of the two header name forms (<a href="#6.10.2">6.10.2</a>).
26224 <li> The character sequence in an #include preprocessing directive does not start with a
26225 letter (<a href="#6.10.2">6.10.2</a>).
26226 <li> There are sequences of preprocessing tokens within the list of macro arguments that
26227 would otherwise act as preprocessing directives (<a href="#6.10.3">6.10.3</a>).
26228 <li> The result of the preprocessing operator # is not a valid character string literal
26229 (<a href="#6.10.3.2">6.10.3.2</a>).
26230 <li> The result of the preprocessing operator ## is not a valid preprocessing token
26231 (<a href="#6.10.3.3">6.10.3.3</a>).
26232 <li> The #line preprocessing directive that results after expansion does not match one of
26233 the two well-defined forms, or its digit sequence specifies zero or a number greater
26234 than 2147483647 (<a href="#6.10.4">6.10.4</a>).
26235 <li> A non-STDC #pragma preprocessing directive that is documented as causing
26236 translation failure or some other form of undefined behavior is encountered (<a href="#6.10.6">6.10.6</a>).
26237 <li> A #pragma STDC preprocessing directive does not match one of the well-defined
26238 forms (<a href="#6.10.6">6.10.6</a>).
26239 <li> The name of a predefined macro, or the identifier defined, is the subject of a
26240 #define or #undef preprocessing directive (<a href="#6.10.8">6.10.8</a>).
26241 <li> An attempt is made to copy an object to an overlapping object by use of a library
26242 function, other than as explicitly allowed (e.g., memmove) (clause 7).
26243 <li> A file with the same name as one of the standard headers, not provided as part of the
26244 implementation, is placed in any of the standard places that are searched for included
26245 source files (<a href="#7.1.2">7.1.2</a>).
26246 <li> A header is included within an external declaration or definition (<a href="#7.1.2">7.1.2</a>).
26247 <li> A function, object, type, or macro that is specified as being declared or defined by
26248 some standard header is used before any header that declares or defines it is included
26249 (<a href="#7.1.2">7.1.2</a>).
26250 <!--page 578 indent 0-->
26251 <li> A standard header is included while a macro is defined with the same name as a
26252 keyword (<a href="#7.1.2">7.1.2</a>).
26253 <li> The program attempts to declare a library function itself, rather than via a standard
26254 header, but the declaration does not have external linkage (<a href="#7.1.2">7.1.2</a>).
26255 <li> The program declares or defines a reserved identifier, other than as allowed by <a href="#7.1.4">7.1.4</a>
26256 (<a href="#7.1.3">7.1.3</a>).
26257 <li> The program removes the definition of a macro whose name begins with an
26258 underscore and either an uppercase letter or another underscore (<a href="#7.1.3">7.1.3</a>).
26259 <li> An argument to a library function has an invalid value or a type not expected by a
26260 function with variable number of arguments (<a href="#7.1.4">7.1.4</a>).
26261 <li> The pointer passed to a library function array parameter does not have a value such
26262 that all address computations and object accesses are valid (<a href="#7.1.4">7.1.4</a>).
26263 <li> The macro definition of assert is suppressed in order to access an actual function
26264 (<a href="#7.2">7.2</a>).
26265 <li> The argument to the assert macro does not have a scalar type (<a href="#7.2">7.2</a>).
26266 <li> The CX_LIMITED_RANGE, FENV_ACCESS, or FP_CONTRACT pragma is used in
26267 any context other than outside all external declarations or preceding all explicit
26268 declarations and statements inside a compound statement (<a href="#7.3.4">7.3.4</a>, <a href="#7.6.1">7.6.1</a>, <a href="#7.12.2">7.12.2</a>).
26269 <li> The value of an argument to a character handling function is neither equal to the value
26270 of EOF nor representable as an unsigned char (<a href="#7.4">7.4</a>).
26271 <li> A macro definition of errno is suppressed in order to access an actual object, or the
26272 program defines an identifier with the name errno (<a href="#7.5">7.5</a>).
26273 <li> Part of the program tests floating-point status flags, sets floating-point control modes,
26274 or runs under non-default mode settings, but was translated with the state for the
26275 FENV_ACCESS pragma ''off'' (<a href="#7.6.1">7.6.1</a>).
26276 <li> The exception-mask argument for one of the functions that provide access to the
26277 floating-point status flags has a nonzero value not obtained by bitwise OR of the
26278 floating-point exception macros (<a href="#7.6.2">7.6.2</a>).
26279 <li> The fesetexceptflag function is used to set floating-point status flags that were
26280 not specified in the call to the fegetexceptflag function that provided the value
26281 of the corresponding fexcept_t object (<a href="#7.6.2.4">7.6.2.4</a>).
26282 <li> The argument to fesetenv or feupdateenv is neither an object set by a call to
26283 fegetenv or feholdexcept, nor is it an environment macro (<a href="#7.6.4.3">7.6.4.3</a>, <a href="#7.6.4.4">7.6.4.4</a>).
26284 <li> The value of the result of an integer arithmetic or conversion function cannot be
26285 represented (<a href="#7.8.2.1">7.8.2.1</a>, <a href="#7.8.2.2">7.8.2.2</a>, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.22.6.1">7.22.6.1</a>, <a href="#7.22.6.2">7.22.6.2</a>, <a href="#7.22.1">7.22.1</a>).
26286 <!--page 579 indent 0-->
26287 <li> The program modifies the string pointed to by the value returned by the setlocale
26288 function (<a href="#7.11.1.1">7.11.1.1</a>).
26289 <li> The program modifies the structure pointed to by the value returned by the
26290 localeconv function (<a href="#7.11.2.1">7.11.2.1</a>).
26291 <li> A macro definition of math_errhandling is suppressed or the program defines
26292 an identifier with the name math_errhandling (<a href="#7.12">7.12</a>).
26293 <li> An argument to a floating-point classification or comparison macro is not of real
26294 floating type (<a href="#7.12.3">7.12.3</a>, <a href="#7.12.14">7.12.14</a>).
26295 <li> A macro definition of setjmp is suppressed in order to access an actual function, or
26296 the program defines an external identifier with the name setjmp (<a href="#7.13">7.13</a>).
26297 <li> An invocation of the setjmp macro occurs other than in an allowed context
26298 (<a href="#7.13.2.1">7.13.2.1</a>).
26299 <li> The longjmp function is invoked to restore a nonexistent environment (<a href="#7.13.2.1">7.13.2.1</a>).
26300 <li> After a longjmp, there is an attempt to access the value of an object of automatic
26301 storage duration that does not have volatile-qualified type, local to the function
26302 containing the invocation of the corresponding setjmp macro, that was changed
26303 between the setjmp invocation and longjmp call (<a href="#7.13.2.1">7.13.2.1</a>).
26304 <li> The program specifies an invalid pointer to a signal handler function (<a href="#7.14.1.1">7.14.1.1</a>).
26305 <li> A signal handler returns when the signal corresponded to a computational exception
26306 (<a href="#7.14.1.1">7.14.1.1</a>).
26307 <li> A signal occurs as the result of calling the abort or raise function, and the signal
26308 handler calls the raise function (<a href="#7.14.1.1">7.14.1.1</a>).
26309 <li> A signal occurs other than as the result of calling the abort or raise function, and
26310 the signal handler refers to an object with static or thread storage duration that is not a
26311 lock-free atomic object other than by assigning a value to an object declared as
26312 volatile sig_atomic_t, or calls any function in the standard library other
26313 than the abort function, the _Exit function, the quick_exit function, or the
26314 signal function (for the same signal number) (<a href="#7.14.1.1">7.14.1.1</a>).
26315 <li> The value of errno is referred to after a signal occurred other than as the result of
26316 calling the abort or raise function and the corresponding signal handler obtained
26317 a SIG_ERR return from a call to the signal function (<a href="#7.14.1.1">7.14.1.1</a>).
26318 <li> A signal is generated by an asynchronous signal handler (<a href="#7.14.1.1">7.14.1.1</a>).
26319 <li> A function with a variable number of arguments attempts to access its varying
26320 arguments other than through a properly declared and initialized va_list object, or
26321 before the va_start macro is invoked (<a href="#7.16">7.16</a>, <a href="#7.16.1.1">7.16.1.1</a>, <a href="#7.16.1.4">7.16.1.4</a>).
26322 <!--page 580 indent 0-->
26323 <li> The macro va_arg is invoked using the parameter ap that was passed to a function
26324 that invoked the macro va_arg with the same parameter (<a href="#7.16">7.16</a>).
26325 <li> A macro definition of va_start, va_arg, va_copy, or va_end is suppressed in
26326 order to access an actual function, or the program defines an external identifier with
26327 the name va_copy or va_end (<a href="#7.16.1">7.16.1</a>).
26328 <li> The va_start or va_copy macro is invoked without a corresponding invocation
26329 of the va_end macro in the same function, or vice versa (<a href="#7.16.1">7.16.1</a>, <a href="#7.16.1.2">7.16.1.2</a>, <a href="#7.16.1.3">7.16.1.3</a>,
26330 <a href="#7.16.1.4">7.16.1.4</a>).
26331 <li> The type parameter to the va_arg macro is not such that a pointer to an object of
26332 that type can be obtained simply by postfixing a * (<a href="#7.16.1.1">7.16.1.1</a>).
26333 <li> The va_arg macro is invoked when there is no actual next argument, or with a
26334 specified type that is not compatible with the promoted type of the actual next
26335 argument, with certain exceptions (<a href="#7.16.1.1">7.16.1.1</a>).
26336 <li> The va_copy or va_start macro is called to initialize a va_list that was
26337 previously initialized by either macro without an intervening invocation of the
26338 va_end macro for the same va_list (<a href="#7.16.1.2">7.16.1.2</a>, <a href="#7.16.1.4">7.16.1.4</a>).
26339 <li> The parameter parmN of a va_start macro is declared with the register
26340 storage class, with a function or array type, or with a type that is not compatible with
26341 the type that results after application of the default argument promotions (<a href="#7.16.1.4">7.16.1.4</a>).
26342 <li> The member designator parameter of an offsetof macro is an invalid right
26343 operand of the . operator for the type parameter, or designates a bit-field (<a href="#7.19">7.19</a>).
26344 <li> The argument in an instance of one of the integer-constant macros is not a decimal,
26345 octal, or hexadecimal constant, or it has a value that exceeds the limits for the
26346 corresponding type (<a href="#7.20.4">7.20.4</a>).
26347 <li> A byte input/output function is applied to a wide-oriented stream, or a wide character
26348 input/output function is applied to a byte-oriented stream (<a href="#7.21.2">7.21.2</a>).
26349 <li> Use is made of any portion of a file beyond the most recent wide character written to
26350 a wide-oriented stream (<a href="#7.21.2">7.21.2</a>).
26351 <li> The value of a pointer to a FILE object is used after the associated file is closed
26352 (<a href="#7.21.3">7.21.3</a>).
26353 <li> The stream for the fflush function points to an input stream or to an update stream
26354 in which the most recent operation was input (<a href="#7.21.5.2">7.21.5.2</a>).
26355 <li> The string pointed to by the mode argument in a call to the fopen function does not
26356 exactly match one of the specified character sequences (<a href="#7.21.5.3">7.21.5.3</a>).
26357 <li> An output operation on an update stream is followed by an input operation without an
26358 intervening call to the fflush function or a file positioning function, or an input
26359 <!--page 581 indent 0-->
26360 operation on an update stream is followed by an output operation with an intervening
26361 call to a file positioning function (<a href="#7.21.5.3">7.21.5.3</a>).
26362 <li> An attempt is made to use the contents of the array that was supplied in a call to the
26363 setvbuf function (<a href="#7.21.5.6">7.21.5.6</a>).
26364 <li> There are insufficient arguments for the format in a call to one of the formatted
26365 input/output functions, or an argument does not have an appropriate type (<a href="#7.21.6.1">7.21.6.1</a>,
26366 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26367 <li> The format in a call to one of the formatted input/output functions or to the
26368 strftime or wcsftime function is not a valid multibyte character sequence that
26369 begins and ends in its initial shift state (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>,
26370 <a href="#7.28.5.1">7.28.5.1</a>).
26371 <li> In a call to one of the formatted output functions, a precision appears with a
26372 conversion specifier other than those described (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26373 <li> A conversion specification for a formatted output function uses an asterisk to denote
26374 an argument-supplied field width or precision, but the corresponding argument is not
26375 provided (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26376 <li> A conversion specification for a formatted output function uses a # or 0 flag with a
26377 conversion specifier other than those described (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26378 <li> A conversion specification for one of the formatted input/output functions uses a
26379 length modifier with a conversion specifier other than those described (<a href="#7.21.6.1">7.21.6.1</a>,
26380 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26381 <li> An s conversion specifier is encountered by one of the formatted output functions,
26382 and the argument is missing the null terminator (unless a precision is specified that
26383 does not require null termination) (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26384 <li> An n conversion specification for one of the formatted input/output functions includes
26385 any flags, an assignment-suppressing character, a field width, or a precision (<a href="#7.21.6.1">7.21.6.1</a>,
26386 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26387 <li> A % conversion specifier is encountered by one of the formatted input/output
26388 functions, but the complete conversion specification is not exactly %% (<a href="#7.21.6.1">7.21.6.1</a>,
26389 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26390 <li> An invalid conversion specification is found in the format for one of the formatted
26391 input/output functions, or the strftime or wcsftime function (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>,
26392 <a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#7.28.5.1">7.28.5.1</a>).
26393 <li> The number of characters transmitted by a formatted output function is greater than
26394 INT_MAX (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.3">7.21.6.3</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.10">7.21.6.10</a>).
26395 <!--page 582 indent 0-->
26396 <li> The result of a conversion by one of the formatted input functions cannot be
26397 represented in the corresponding object, or the receiving object does not have an
26398 appropriate type (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26399 <li> A c, s, or [ conversion specifier is encountered by one of the formatted input
26400 functions, and the array pointed to by the corresponding argument is not large enough
26401 to accept the input sequence (and a null terminator if the conversion specifier is s or
26402 [) (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26403 <li> A c, s, or [ conversion specifier with an l qualifier is encountered by one of the
26404 formatted input functions, but the input is not a valid multibyte character sequence
26405 that begins in the initial shift state (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26406 <li> The input item for a %p conversion by one of the formatted input functions is not a
26407 value converted earlier during the same program execution (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26408 <li> The vfprintf, vfscanf, vprintf, vscanf, vsnprintf, vsprintf,
26409 vsscanf, vfwprintf, vfwscanf, vswprintf, vswscanf, vwprintf, or
26410 vwscanf function is called with an improperly initialized va_list argument, or
26411 the argument is used (other than in an invocation of va_end) after the function
26412 returns (<a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.9">7.21.6.9</a>, <a href="#7.21.6.10">7.21.6.10</a>, <a href="#7.21.6.11">7.21.6.11</a>, <a href="#7.21.6.12">7.21.6.12</a>, <a href="#7.21.6.13">7.21.6.13</a>, <a href="#7.21.6.14">7.21.6.14</a>,
26413 <a href="#7.28.2.5">7.28.2.5</a>, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.7">7.28.2.7</a>, <a href="#7.28.2.8">7.28.2.8</a>, <a href="#7.28.2.9">7.28.2.9</a>, <a href="#7.28.2.10">7.28.2.10</a>).
26414 <li> The contents of the array supplied in a call to the fgets or fgetws function are
26415 used after a read error occurred (<a href="#7.21.7.2">7.21.7.2</a>, <a href="#7.28.3.2">7.28.3.2</a>).
26416 <li> The file position indicator for a binary stream is used after a call to the ungetc
26417 function where its value was zero before the call (<a href="#7.21.7.10">7.21.7.10</a>).
26418 <li> The file position indicator for a stream is used after an error occurred during a call to
26419 the fread or fwrite function (<a href="#7.21.8.1">7.21.8.1</a>, <a href="#7.21.8.2">7.21.8.2</a>).
26420 <li> A partial element read by a call to the fread function is used (<a href="#7.21.8.1">7.21.8.1</a>).
26421 <li> The fseek function is called for a text stream with a nonzero offset and either the
26422 offset was not returned by a previous successful call to the ftell function on a
26423 stream associated with the same file or whence is not SEEK_SET (<a href="#7.21.9.2">7.21.9.2</a>).
26424 <li> The fsetpos function is called to set a position that was not returned by a previous
26425 successful call to the fgetpos function on a stream associated with the same file
26426 (<a href="#7.21.9.3">7.21.9.3</a>).
26427 <li> A non-null pointer returned by a call to the calloc, malloc, or realloc function
26428 with a zero requested size is used to access an object (<a href="#7.22.3">7.22.3</a>).
26429 <li> The value of a pointer that refers to space deallocated by a call to the free or
26430 realloc function is used (<a href="#7.22.3">7.22.3</a>).
26431 <!--page 583 indent 0-->
26432 <li> The alignment requested of the aligned_alloc function is not valid or not
26433 supported by the implementation, or the size requested is not an integral multiple of
26434 the alignment (<a href="#7.22.3.1">7.22.3.1</a>).
26435 <li> The pointer argument to the free or realloc function does not match a pointer
26436 earlier returned by a memory management function, or the space has been deallocated
26437 by a call to free or realloc (<a href="#7.22.3.3">7.22.3.3</a>, <a href="#7.22.3.5">7.22.3.5</a>).
26438 <li> The value of the object allocated by the malloc function is used (<a href="#7.22.3.4">7.22.3.4</a>).
26439 <li> The value of any bytes in a new object allocated by the realloc function beyond
26440 the size of the old object are used (<a href="#7.22.3.5">7.22.3.5</a>).
26441 <li> The program calls the exit or quick_exit function more than once, or calls both
26442 functions (<a href="#7.22.4.4">7.22.4.4</a>, <a href="#7.22.4.7">7.22.4.7</a>).
26443 <li> During the call to a function registered with the atexit or at_quick_exit
26444 function, a call is made to the longjmp function that would terminate the call to the
26445 registered function (<a href="#7.22.4.4">7.22.4.4</a>, <a href="#7.22.4.7">7.22.4.7</a>).
26446 <li> The string set up by the getenv or strerror function is modified by the program
26447 (<a href="#7.22.4.6">7.22.4.6</a>, <a href="#7.23.6.2">7.23.6.2</a>).
26448 <li> A command is executed through the system function in a way that is documented as
26449 causing termination or some other form of undefined behavior (<a href="#7.22.4.8">7.22.4.8</a>).
26450 <li> A searching or sorting utility function is called with an invalid pointer argument, even
26451 if the number of elements is zero (<a href="#7.22.5">7.22.5</a>).
26452 <li> The comparison function called by a searching or sorting utility function alters the
26453 contents of the array being searched or sorted, or returns ordering values
26454 inconsistently (<a href="#7.22.5">7.22.5</a>).
26455 <li> The array being searched by the bsearch function does not have its elements in
26456 proper order (<a href="#7.22.5.1">7.22.5.1</a>).
26457 <li> The current conversion state is used by a multibyte/wide character conversion
26458 function after changing the LC_CTYPE category (<a href="#7.22.7">7.22.7</a>).
26459 <li> A string or wide string utility function is instructed to access an array beyond the end
26460 of an object (<a href="#7.23.1">7.23.1</a>, <a href="#7.28.4">7.28.4</a>).
26461 <li> A string or wide string utility function is called with an invalid pointer argument, even
26462 if the length is zero (<a href="#7.23.1">7.23.1</a>, <a href="#7.28.4">7.28.4</a>).
26463 <li> The contents of the destination array are used after a call to the strxfrm,
26464 strftime, wcsxfrm, or wcsftime function in which the specified length was
26465 too small to hold the entire null-terminated result (<a href="#7.23.4.5">7.23.4.5</a>, <a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.4.4.4">7.28.4.4.4</a>,
26466 <a href="#7.28.5.1">7.28.5.1</a>).
26467 <!--page 584 indent 4-->
26468 <li> The first argument in the very first call to the strtok or wcstok is a null pointer
26469 (<a href="#7.23.5.8">7.23.5.8</a>, <a href="#7.28.4.5.7">7.28.4.5.7</a>).
26470 <li> The type of an argument to a type-generic macro is not compatible with the type of
26471 the corresponding parameter of the selected function (<a href="#7.24">7.24</a>).
26472 <li> A complex argument is supplied for a generic parameter of a type-generic macro that
26473 has no corresponding complex function (<a href="#7.24">7.24</a>).
26474 <li> At least one field of the broken-down time passed to asctime contains a value
26475 outside its normal range, or the calculated year exceeds four digits or is less than the
26476 year 1000 (<a href="#7.26.3.1">7.26.3.1</a>).
26477 <li> The argument corresponding to an s specifier without an l qualifier in a call to the
26478 fwprintf function does not point to a valid multibyte character sequence that
26479 begins in the initial shift state (<a href="#7.28.2.11">7.28.2.11</a>).
26480 <li> In a call to the wcstok function, the object pointed to by ptr does not have the
26481 value stored by the previous call for the same wide string (<a href="#7.28.4.5.7">7.28.4.5.7</a>).
26482 <li> An mbstate_t object is used inappropriately (<a href="#7.28.6">7.28.6</a>).
26483 <li> The value of an argument of type wint_t to a wide character classification or case
26484 mapping function is neither equal to the value of WEOF nor representable as a
26485 wchar_t (<a href="#7.29.1">7.29.1</a>).
26486 <li> The iswctype function is called using a different LC_CTYPE category from the
26487 one in effect for the call to the wctype function that returned the description
26488 (<a href="#7.29.2.2.1">7.29.2.2.1</a>).
26489 <li> The towctrans function is called using a different LC_CTYPE category from the
26490 one in effect for the call to the wctrans function that returned the description
26491 (<a href="#7.29.3.2.1">7.29.3.2.1</a>).
26494 <a name="J.3" href="#J.3"><h3>J.3 Implementation-defined behavior</h3></a>
26496 A conforming implementation is required to document its choice of behavior in each of
26497 the areas listed in this subclause. The following are implementation-defined:
26498 <!--page 585 indent 4-->
26500 <a name="J.3.1" href="#J.3.1"><h4>J.3.1 Translation</h4></a>
26503 <li> How a diagnostic is identified (<a href="#3.10">3.10</a>, <a href="#5.1.1.3">5.1.1.3</a>).
26504 <li> Whether each nonempty sequence of white-space characters other than new-line is
26505 retained or replaced by one space character in translation phase 3 (<a href="#5.1.1.2">5.1.1.2</a>).
26508 <a name="J.3.2" href="#J.3.2"><h4>J.3.2 Environment</h4></a>
26511 <li> The mapping between physical source file multibyte characters and the source
26512 character set in translation phase 1 (<a href="#5.1.1.2">5.1.1.2</a>).
26513 <li> The name and type of the function called at program startup in a freestanding
26514 environment (<a href="#5.1.2.1">5.1.2.1</a>).
26515 <li> The effect of program termination in a freestanding environment (<a href="#5.1.2.1">5.1.2.1</a>).
26516 <li> An alternative manner in which the main function may be defined (<a href="#5.1.2.2.1">5.1.2.2.1</a>).
26517 <li> The values given to the strings pointed to by the argv argument to main (<a href="#5.1.2.2.1">5.1.2.2.1</a>).
26518 <li> What constitutes an interactive device (<a href="#5.1.2.3">5.1.2.3</a>).
26519 <li> Whether a program can have more than one thread of execution in a freestanding
26520 environment (<a href="#5.1.2.4">5.1.2.4</a>).
26521 <li> The set of signals, their semantics, and their default handling (<a href="#7.14">7.14</a>).
26522 <li> Signal values other than SIGFPE, SIGILL, and SIGSEGV that correspond to a
26523 computational exception (<a href="#7.14.1.1">7.14.1.1</a>).
26524 <li> Signals for which the equivalent of signal(sig, SIG_IGN); is executed at
26525 program startup (<a href="#7.14.1.1">7.14.1.1</a>).
26526 <li> The set of environment names and the method for altering the environment list used
26527 by the getenv function (<a href="#7.22.4.6">7.22.4.6</a>).
26528 <li> The manner of execution of the string by the system function (<a href="#7.22.4.8">7.22.4.8</a>).
26531 <a name="J.3.3" href="#J.3.3"><h4>J.3.3 Identifiers</h4></a>
26534 <li> Which additional multibyte characters may appear in identifiers and their
26535 correspondence to universal character names (<a href="#6.4.2">6.4.2</a>).
26536 <li> The number of significant initial characters in an identifier (<a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2">6.4.2</a>).
26537 <!--page 586 indent 4-->
26540 <a name="J.3.4" href="#J.3.4"><h4>J.3.4 Characters</h4></a>
26543 <li> The number of bits in a byte (<a href="#3.6">3.6</a>).
26544 <li> The values of the members of the execution character set (<a href="#5.2.1">5.2.1</a>).
26545 <li> The unique value of the member of the execution character set produced for each of
26546 the standard alphabetic escape sequences (<a href="#5.2.2">5.2.2</a>).
26547 <li> The value of a char object into which has been stored any character other than a
26548 member of the basic execution character set (<a href="#6.2.5">6.2.5</a>).
26549 <li> Which of signed char or unsigned char has the same range, representation,
26550 and behavior as ''plain'' char (<a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>).
26551 <li> The mapping of members of the source character set (in character constants and string
26552 literals) to members of the execution character set (<a href="#6.4.4.4">6.4.4.4</a>, <a href="#5.1.1.2">5.1.1.2</a>).
26553 <li> The value of an integer character constant containing more than one character or
26554 containing a character or escape sequence that does not map to a single-byte
26555 execution character (<a href="#6.4.4.4">6.4.4.4</a>).
26556 <li> The value of a wide character constant containing more than one multibyte character
26557 or a single multibyte character that maps to multiple members of the extended
26558 execution character set, or containing a multibyte character or escape sequence not
26559 represented in the extended execution character set (<a href="#6.4.4.4">6.4.4.4</a>).
26560 <li> The current locale used to convert a wide character constant consisting of a single
26561 multibyte character that maps to a member of the extended execution character set
26562 into a corresponding wide character code (<a href="#6.4.4.4">6.4.4.4</a>).
26563 <li> Whether differently-prefixed wide string literal tokens can be concatenated and, if so,
26564 the treatment of the resulting multibyte character sequence (<a href="#6.4.5">6.4.5</a>).
26565 <li> The current locale used to convert a wide string literal into corresponding wide
26566 character codes (<a href="#6.4.5">6.4.5</a>).
26567 <li> The value of a string literal containing a multibyte character or escape sequence not
26568 represented in the execution character set (<a href="#6.4.5">6.4.5</a>).
26569 <li> The encoding of any of wchar_t, char16_t, and char32_t where the
26570 corresponding standard encoding macro (__STDC_ISO_10646__,
26571 __STDC_UTF_16__, or __STDC_UTF_32__) is not defined (<a href="#6.10.8.2">6.10.8.2</a>).
26572 <!--page 587 indent 4-->
26575 <a name="J.3.5" href="#J.3.5"><h4>J.3.5 Integers</h4></a>
26578 <li> Any extended integer types that exist in the implementation (<a href="#6.2.5">6.2.5</a>).
26579 <li> Whether signed integer types are represented using sign and magnitude, two's
26580 complement, or ones' complement, and whether the extraordinary value is a trap
26581 representation or an ordinary value (<a href="#6.2.6.2">6.2.6.2</a>).
26582 <li> The rank of any extended integer type relative to another extended integer type with
26583 the same precision (<a href="#6.3.1.1">6.3.1.1</a>).
26584 <li> The result of, or the signal raised by, converting an integer to a signed integer type
26585 when the value cannot be represented in an object of that type (<a href="#6.3.1.3">6.3.1.3</a>).
26586 <li> The results of some bitwise operations on signed integers (<a href="#6.5">6.5</a>).
26589 <a name="J.3.6" href="#J.3.6"><h4>J.3.6 Floating point</h4></a>
26592 <li> The accuracy of the floating-point operations and of the library functions in
26593 <math.h> and <complex.h> that return floating-point results (<a href="#5.2.4.2.2">5.2.4.2.2</a>).
26594 <li> The accuracy of the conversions between floating-point internal representations and
26595 string representations performed by the library functions in <stdio.h>,
26596 <stdlib.h>, and <wchar.h> (<a href="#5.2.4.2.2">5.2.4.2.2</a>).
26597 <li> The rounding behaviors characterized by non-standard values of FLT_ROUNDS
26598 (<a href="#5.2.4.2.2">5.2.4.2.2</a>).
26599 <li> The evaluation methods characterized by non-standard negative values of
26600 FLT_EVAL_METHOD (<a href="#5.2.4.2.2">5.2.4.2.2</a>).
26601 <li> The direction of rounding when an integer is converted to a floating-point number that
26602 cannot exactly represent the original value (<a href="#6.3.1.4">6.3.1.4</a>).
26603 <li> The direction of rounding when a floating-point number is converted to a narrower
26604 floating-point number (<a href="#6.3.1.5">6.3.1.5</a>).
26605 <li> How the nearest representable value or the larger or smaller representable value
26606 immediately adjacent to the nearest representable value is chosen for certain floating
26607 constants (<a href="#6.4.4.2">6.4.4.2</a>).
26608 <li> Whether and how floating expressions are contracted when not disallowed by the
26609 FP_CONTRACT pragma (<a href="#6.5">6.5</a>).
26610 <li> The default state for the FENV_ACCESS pragma (<a href="#7.6.1">7.6.1</a>).
26611 <li> Additional floating-point exceptions, rounding modes, environments, and
26612 classifications, and their macro names (<a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>).
26613 <li> The default state for the FP_CONTRACT pragma (<a href="#7.12.2">7.12.2</a>).
26614 <!--page 588 indent 4-->
26617 <a name="J.3.7" href="#J.3.7"><h4>J.3.7 Arrays and pointers</h4></a>
26620 <li> The result of converting a pointer to an integer or vice versa (<a href="#6.3.2.3">6.3.2.3</a>).
26621 <li> The size of the result of subtracting two pointers to elements of the same array
26622 (<a href="#6.5.6">6.5.6</a>).
26625 <a name="J.3.8" href="#J.3.8"><h4>J.3.8 Hints</h4></a>
26628 <li> The extent to which suggestions made by using the register storage-class
26629 specifier are effective (<a href="#6.7.1">6.7.1</a>).
26630 <li> The extent to which suggestions made by using the inline function specifier are
26631 effective (<a href="#6.7.4">6.7.4</a>).
26634 <a name="J.3.9" href="#J.3.9"><h4>J.3.9 Structures, unions, enumerations, and bit-fields</h4></a>
26637 <li> Whether a ''plain'' int bit-field is treated as a signed int bit-field or as an
26638 unsigned int bit-field (<a href="#6.7.2">6.7.2</a>, <a href="#6.7.2.1">6.7.2.1</a>).
26639 <li> Allowable bit-field types other than _Bool, signed int, and unsigned int
26640 (<a href="#6.7.2.1">6.7.2.1</a>).
26641 <li> Whether atomic types are permitted for bit-fields (<a href="#6.7.2.1">6.7.2.1</a>).
26642 <li> Whether a bit-field can straddle a storage-unit boundary (<a href="#6.7.2.1">6.7.2.1</a>).
26643 <li> The order of allocation of bit-fields within a unit (<a href="#6.7.2.1">6.7.2.1</a>).
26644 <li> The alignment of non-bit-field members of structures (<a href="#6.7.2.1">6.7.2.1</a>). This should present
26645 no problem unless binary data written by one implementation is read by another.
26646 <li> The integer type compatible with each enumerated type (<a href="#6.7.2.2">6.7.2.2</a>).
26649 <a name="J.3.10" href="#J.3.10"><h4>J.3.10 Qualifiers</h4></a>
26652 <li> What constitutes an access to an object that has volatile-qualified type (<a href="#6.7.3">6.7.3</a>).
26655 <a name="J.3.11" href="#J.3.11"><h4>J.3.11 Preprocessing directives</h4></a>
26658 <li> The locations within #pragma directives where header name preprocessing tokens
26659 are recognized (<a href="#6.4">6.4</a>, <a href="#6.4.7">6.4.7</a>).
26660 <li> How sequences in both forms of header names are mapped to headers or external
26661 source file names (<a href="#6.4.7">6.4.7</a>).
26662 <li> Whether the value of a character constant in a constant expression that controls
26663 conditional inclusion matches the value of the same character constant in the
26664 execution character set (<a href="#6.10.1">6.10.1</a>).
26665 <li> Whether the value of a single-character character constant in a constant expression
26666 that controls conditional inclusion may have a negative value (<a href="#6.10.1">6.10.1</a>).
26667 <!--page 589 indent 4-->
26668 <li> The places that are searched for an included < > delimited header, and how the places
26669 are specified or the header is identified (<a href="#6.10.2">6.10.2</a>).
26670 <li> How the named source file is searched for in an included " " delimited header
26671 (<a href="#6.10.2">6.10.2</a>).
26672 <li> The method by which preprocessing tokens (possibly resulting from macro
26673 expansion) in a #include directive are combined into a header name (<a href="#6.10.2">6.10.2</a>).
26674 <li> The nesting limit for #include processing (<a href="#6.10.2">6.10.2</a>).
26675 <li> Whether the # operator inserts a \ character before the \ character that begins a
26676 universal character name in a character constant or string literal (<a href="#6.10.3.2">6.10.3.2</a>).
26677 <li> The behavior on each recognized non-STDC #pragma directive (<a href="#6.10.6">6.10.6</a>).
26678 <li> The definitions for __DATE__ and __TIME__ when respectively, the date and
26679 time of translation are not available (<a href="#6.10.8.1">6.10.8.1</a>).
26682 <a name="J.3.12" href="#J.3.12"><h4>J.3.12 Library functions</h4></a>
26685 <li> Any library facilities available to a freestanding program, other than the minimal set
26686 required by clause 4 (<a href="#5.1.2.1">5.1.2.1</a>).
26687 <li> The format of the diagnostic printed by the assert macro (<a href="#7.2.1.1">7.2.1.1</a>).
26688 <li> The representation of the floating-point status flags stored by the
26689 fegetexceptflag function (<a href="#7.6.2.2">7.6.2.2</a>).
26690 <li> Whether the feraiseexcept function raises the ''inexact'' floating-point
26691 exception in addition to the ''overflow'' or ''underflow'' floating-point exception
26692 (<a href="#7.6.2.3">7.6.2.3</a>).
26693 <li> Strings other than "C" and "" that may be passed as the second argument to the
26694 setlocale function (<a href="#7.11.1.1">7.11.1.1</a>).
26695 <li> The types defined for float_t and double_t when the value of the
26696 FLT_EVAL_METHOD macro is less than 0 (<a href="#7.12">7.12</a>).
26697 <li> Domain errors for the mathematics functions, other than those required by this
26698 International Standard (<a href="#7.12.1">7.12.1</a>).
26699 <li> The values returned by the mathematics functions on domain errors or pole errors
26700 (<a href="#7.12.1">7.12.1</a>).
26701 <li> The values returned by the mathematics functions on underflow range errors, whether
26702 errno is set to the value of the macro ERANGE when the integer expression
26703 math_errhandling & MATH_ERRNO is nonzero, and whether the ''underflow''
26704 floating-point exception is raised when the integer expression math_errhandling
26705 & MATH_ERREXCEPT is nonzero. (<a href="#7.12.1">7.12.1</a>).
26706 <!--page 590 indent 0-->
26707 <li> Whether a domain error occurs or zero is returned when an fmod function has a
26708 second argument of zero (<a href="#7.12.10.1">7.12.10.1</a>).
26709 <li> Whether a domain error occurs or zero is returned when a remainder function has
26710 a second argument of zero (<a href="#7.12.10.2">7.12.10.2</a>).
26711 <li> The base-2 logarithm of the modulus used by the remquo functions in reducing the
26712 quotient (<a href="#7.12.10.3">7.12.10.3</a>).
26713 <li> Whether a domain error occurs or zero is returned when a remquo function has a
26714 second argument of zero (<a href="#7.12.10.3">7.12.10.3</a>).
26715 <li> Whether the equivalent of signal(sig, SIG_DFL); is executed prior to the call
26716 of a signal handler, and, if not, the blocking of signals that is performed (<a href="#7.14.1.1">7.14.1.1</a>).
26717 <li> The null pointer constant to which the macro NULL expands (<a href="#7.19">7.19</a>).
26718 <li> Whether the last line of a text stream requires a terminating new-line character
26719 (<a href="#7.21.2">7.21.2</a>).
26720 <li> Whether space characters that are written out to a text stream immediately before a
26721 new-line character appear when read in (<a href="#7.21.2">7.21.2</a>).
26722 <li> The number of null characters that may be appended to data written to a binary
26723 stream (<a href="#7.21.2">7.21.2</a>).
26724 <li> Whether the file position indicator of an append-mode stream is initially positioned at
26725 the beginning or end of the file (<a href="#7.21.3">7.21.3</a>).
26726 <li> Whether a write on a text stream causes the associated file to be truncated beyond that
26727 point (<a href="#7.21.3">7.21.3</a>).
26728 <li> The characteristics of file buffering (<a href="#7.21.3">7.21.3</a>).
26729 <li> Whether a zero-length file actually exists (<a href="#7.21.3">7.21.3</a>).
26730 <li> The rules for composing valid file names (<a href="#7.21.3">7.21.3</a>).
26731 <li> Whether the same file can be simultaneously open multiple times (<a href="#7.21.3">7.21.3</a>).
26732 <li> The nature and choice of encodings used for multibyte characters in files (<a href="#7.21.3">7.21.3</a>).
26733 <li> The effect of the remove function on an open file (<a href="#7.21.4.1">7.21.4.1</a>).
26734 <li> The effect if a file with the new name exists prior to a call to the rename function
26735 (<a href="#7.21.4.2">7.21.4.2</a>).
26736 <li> Whether an open temporary file is removed upon abnormal program termination
26737 (<a href="#7.21.4.3">7.21.4.3</a>).
26738 <li> Which changes of mode are permitted (if any), and under what circumstances
26739 (<a href="#7.21.5.4">7.21.5.4</a>).
26740 <!--page 591 indent 0-->
26741 <li> The style used to print an infinity or NaN, and the meaning of any n-char or n-wchar
26742 sequence printed for a NaN (<a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26743 <li> The output for %p conversion in the fprintf or fwprintf function (<a href="#7.21.6.1">7.21.6.1</a>,
26744 <a href="#7.28.2.1">7.28.2.1</a>).
26745 <li> The interpretation of a - character that is neither the first nor the last character, nor
26746 the second where a ^ character is the first, in the scanlist for %[ conversion in the
26747 fscanf or fwscanf function (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>).
26748 <li> The set of sequences matched by a %p conversion and the interpretation of the
26749 corresponding input item in the fscanf or fwscanf function (<a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>).
26750 <li> The value to which the macro errno is set by the fgetpos, fsetpos, or ftell
26751 functions on failure (<a href="#7.21.9.1">7.21.9.1</a>, <a href="#7.21.9.3">7.21.9.3</a>, <a href="#7.21.9.4">7.21.9.4</a>).
26752 <li> The meaning of any n-char or n-wchar sequence in a string representing a NaN that is
26753 converted by the strtod, strtof, strtold, wcstod, wcstof, or wcstold
26754 function (<a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>).
26755 <li> Whether or not the strtod, strtof, strtold, wcstod, wcstof, or wcstold
26756 function sets errno to ERANGE when underflow occurs (<a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>).
26757 <li> Whether the calloc, malloc, and realloc functions return a null pointer or a
26758 pointer to an allocated object when the size requested is zero (<a href="#7.22.3">7.22.3</a>).
26759 <li> Whether open streams with unwritten buffered data are flushed, open streams are
26760 closed, or temporary files are removed when the abort or _Exit function is called
26761 (<a href="#7.22.4.1">7.22.4.1</a>, <a href="#7.22.4.5">7.22.4.5</a>).
26762 <li> The termination status returned to the host environment by the abort, exit,
26763 _Exit, or quick_exit function (<a href="#7.22.4.1">7.22.4.1</a>, <a href="#7.22.4.4">7.22.4.4</a>, <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a>).
26764 <li> The value returned by the system function when its argument is not a null pointer
26765 (<a href="#7.22.4.8">7.22.4.8</a>).
26766 <li> The local time zone and Daylight Saving Time (<a href="#7.26.1">7.26.1</a>).
26767 <li> The range and precision of times representable in clock_t and time_t (<a href="#7.26">7.26</a>).
26768 <li> The era for the clock function (<a href="#7.26.2.1">7.26.2.1</a>).
26769 <li> The replacement string for the %Z specifier to the strftime, and wcsftime
26770 functions in the "C" locale (<a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.5.1">7.28.5.1</a>).
26771 <li> Whether the functions in <math.h> honor the rounding direction mode in an
26772 IEC 60559 conformant implementation, unless explicitly specified otherwise (<a href="#F.10">F.10</a>).
26773 <!--page 592 indent 4-->
26776 <a name="J.3.13" href="#J.3.13"><h4>J.3.13 Architecture</h4></a>
26779 <li> The values or expressions assigned to the macros specified in the headers
26780 <float.h>, <limits.h>, and <stdint.h> (<a href="#5.2.4.2">5.2.4.2</a>, <a href="#7.20.2">7.20.2</a>, <a href="#7.20.3">7.20.3</a>).
26781 <li> The result of attempting to indirectly access an object with automatic or thread
26782 storage duration from a thread other than the one with which it is associated (<a href="#6.2.4">6.2.4</a>).
26783 <li> The number, order, and encoding of bytes in any object (when not explicitly specified
26784 in this International Standard) (<a href="#6.2.6.1">6.2.6.1</a>).
26785 <li> Whether any extended alignments are supported and the contexts in which they are
26786 supported (<a href="#6.2.8">6.2.8</a>).
26787 <li> Valid alignment values other than those returned by an alignof expression for
26788 fundamental types, if any (<a href="#6.2.8">6.2.8</a>).
26789 <li> The value of the result of the sizeof and alignof operators (<a href="#6.5.3.4">6.5.3.4</a>).
26792 <a name="J.4" href="#J.4"><h3>J.4 Locale-specific behavior</h3></a>
26794 The following characteristics of a hosted environment are locale-specific and are required
26795 to be documented by the implementation:
26797 <li> Additional members of the source and execution character sets beyond the basic
26798 character set (<a href="#5.2.1">5.2.1</a>).
26799 <li> The presence, meaning, and representation of additional multibyte characters in the
26800 execution character set beyond the basic character set (<a href="#5.2.1.2">5.2.1.2</a>).
26801 <li> The shift states used for the encoding of multibyte characters (<a href="#5.2.1.2">5.2.1.2</a>).
26802 <li> The direction of writing of successive printing characters (<a href="#5.2.2">5.2.2</a>).
26803 <li> The decimal-point character (<a href="#7.1.1">7.1.1</a>).
26804 <li> The set of printing characters (<a href="#7.4">7.4</a>, <a href="#7.29.2">7.29.2</a>).
26805 <li> The set of control characters (<a href="#7.4">7.4</a>, <a href="#7.29.2">7.29.2</a>).
26806 <li> The sets of characters tested for by the isalpha, isblank, islower, ispunct,
26807 isspace, isupper, iswalpha, iswblank, iswlower, iswpunct,
26808 iswspace, or iswupper functions (<a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.3">7.4.1.3</a>, <a href="#7.4.1.7">7.4.1.7</a>, <a href="#7.4.1.9">7.4.1.9</a>, <a href="#7.4.1.10">7.4.1.10</a>,
26809 <a href="#7.4.1.11">7.4.1.11</a>, <a href="#7.29.2.1.2">7.29.2.1.2</a>, <a href="#7.29.2.1.3">7.29.2.1.3</a>, <a href="#7.29.2.1.7">7.29.2.1.7</a>, <a href="#7.29.2.1.9">7.29.2.1.9</a>, <a href="#7.29.2.1.10">7.29.2.1.10</a>, <a href="#7.29.2.1.11">7.29.2.1.11</a>).
26810 <li> The native environment (<a href="#7.11.1.1">7.11.1.1</a>).
26811 <li> Additional subject sequences accepted by the numeric conversion functions (<a href="#7.22.1">7.22.1</a>,
26812 <a href="#7.28.4.1">7.28.4.1</a>).
26813 <li> The collation sequence of the execution character set (<a href="#7.23.4.3">7.23.4.3</a>, <a href="#7.28.4.4.2">7.28.4.4.2</a>).
26814 <!--page 593 indent 4-->
26815 <li> The contents of the error message strings set up by the strerror function
26816 (<a href="#7.23.6.2">7.23.6.2</a>).
26817 <li> The formats for time and date (<a href="#7.26.3.5">7.26.3.5</a>, <a href="#7.28.5.1">7.28.5.1</a>).
26818 <li> Character mappings that are supported by the towctrans function (<a href="#7.29.1">7.29.1</a>).
26819 <li> Character classifications that are supported by the iswctype function (<a href="#7.29.1">7.29.1</a>).
26822 <a name="J.5" href="#J.5"><h3>J.5 Common extensions</h3></a>
26824 The following extensions are widely used in many systems, but are not portable to all
26825 implementations. The inclusion of any extension that may cause a strictly conforming
26826 program to become invalid renders an implementation nonconforming. Examples of such
26827 extensions are new keywords, extra library functions declared in standard headers, or
26828 predefined macros with names that do not begin with an underscore.
26830 <a name="J.5.1" href="#J.5.1"><h4>J.5.1 Environment arguments</h4></a>
26832 In a hosted environment, the main function receives a third argument, char *envp[],
26833 that points to a null-terminated array of pointers to char, each of which points to a string
26834 that provides information about the environment for this execution of the program
26835 (<a href="#5.1.2.2.1">5.1.2.2.1</a>).
26837 <a name="J.5.2" href="#J.5.2"><h4>J.5.2 Specialized identifiers</h4></a>
26839 Characters other than the underscore _, letters, and digits, that are not part of the basic
26840 source character set (such as the dollar sign $, or characters in national character sets)
26841 may appear in an identifier (<a href="#6.4.2">6.4.2</a>).
26843 <a name="J.5.3" href="#J.5.3"><h4>J.5.3 Lengths and cases of identifiers</h4></a>
26845 All characters in identifiers (with or without external linkage) are significant (<a href="#6.4.2">6.4.2</a>).
26847 <a name="J.5.4" href="#J.5.4"><h4>J.5.4 Scopes of identifiers</h4></a>
26849 A function identifier, or the identifier of an object the declaration of which contains the
26850 keyword extern, has file scope (<a href="#6.2.1">6.2.1</a>).
26852 <a name="J.5.5" href="#J.5.5"><h4>J.5.5 Writable string literals</h4></a>
26854 String literals are modifiable (in which case, identical string literals should denote distinct
26855 objects) (<a href="#6.4.5">6.4.5</a>).
26856 <!--page 594 indent 4-->
26858 <a name="J.5.6" href="#J.5.6"><h4>J.5.6 Other arithmetic types</h4></a>
26860 Additional arithmetic types, such as __int128 or double double, and their
26861 appropriate conversions are defined (<a href="#6.2.5">6.2.5</a>, <a href="#6.3.1">6.3.1</a>). Additional floating types may have
26862 more range or precision than long double, may be used for evaluating expressions of
26863 other floating types, and may be used to define float_t or double_t.
26865 <a name="J.5.7" href="#J.5.7"><h4>J.5.7 Function pointer casts</h4></a>
26867 A pointer to an object or to void may be cast to a pointer to a function, allowing data to
26868 be invoked as a function (<a href="#6.5.4">6.5.4</a>).
26870 A pointer to a function may be cast to a pointer to an object or to void, allowing a
26871 function to be inspected or modified (for example, by a debugger) (<a href="#6.5.4">6.5.4</a>).
26873 <a name="J.5.8" href="#J.5.8"><h4>J.5.8 Extended bit-field types</h4></a>
26875 A bit-field may be declared with a type other than _Bool, unsigned int, or
26876 signed int, with an appropriate maximum width (<a href="#6.7.2.1">6.7.2.1</a>).
26878 <a name="J.5.9" href="#J.5.9"><h4>J.5.9 The fortran keyword</h4></a>
26880 The fortran function specifier may be used in a function declaration to indicate that
26881 calls suitable for FORTRAN should be generated, or that a different representation for the
26882 external name is to be generated (<a href="#6.7.4">6.7.4</a>).
26884 <a name="J.5.10" href="#J.5.10"><h4>J.5.10 The asm keyword</h4></a>
26886 The asm keyword may be used to insert assembly language directly into the translator
26887 output (<a href="#6.8">6.8</a>). The most common implementation is via a statement of the form:
26889 asm ( character-string-literal );</pre>
26891 <a name="J.5.11" href="#J.5.11"><h4>J.5.11 Multiple external definitions</h4></a>
26893 There may be more than one external definition for the identifier of an object, with or
26894 without the explicit use of the keyword extern; if the definitions disagree, or more than
26895 one is initialized, the behavior is undefined (<a href="#6.9.2">6.9.2</a>).
26897 <a name="J.5.12" href="#J.5.12"><h4>J.5.12 Predefined macro names</h4></a>
26899 Macro names that do not begin with an underscore, describing the translation and
26900 execution environments, are defined by the implementation before translation begins
26901 (<a href="#6.10.8">6.10.8</a>).
26902 <!--page 595 indent 4-->
26904 <a name="J.5.13" href="#J.5.13"><h4>J.5.13 Floating-point status flags</h4></a>
26906 If any floating-point status flags are set on normal termination after all calls to functions
26907 registered by the atexit function have been made (see <a href="#7.22.4.4">7.22.4.4</a>), the implementation
26908 writes some diagnostics indicating the fact to the stderr stream, if it is still open,
26910 <a name="J.5.14" href="#J.5.14"><h4>J.5.14 Extra arguments for signal handlers</h4></a>
26912 Handlers for specific signals are called with extra arguments in addition to the signal
26913 number (<a href="#7.14.1.1">7.14.1.1</a>).
26915 <a name="J.5.15" href="#J.5.15"><h4>J.5.15 Additional stream types and file-opening modes</h4></a>
26917 Additional mappings from files to streams are supported (<a href="#7.21.2">7.21.2</a>).
26919 Additional file-opening modes may be specified by characters appended to the mode
26920 argument of the fopen function (<a href="#7.21.5.3">7.21.5.3</a>).
26922 <a name="J.5.16" href="#J.5.16"><h4>J.5.16 Defined file position indicator</h4></a>
26924 The file position indicator is decremented by each successful call to the ungetc or
26925 ungetwc function for a text stream, except if its value was zero before a call (<a href="#7.21.7.10">7.21.7.10</a>,
26926 <a href="#7.28.3.10">7.28.3.10</a>).
26928 <a name="J.5.17" href="#J.5.17"><h4>J.5.17 Math error reporting</h4></a>
26930 Functions declared in <complex.h> and <math.h> raise SIGFPE to report errors
26931 instead of, or in addition to, setting errno or raising floating-point exceptions (<a href="#7.3">7.3</a>,
26932 <a href="#7.12">7.12</a>).
26933 <!--page 596 indent 4-->
26935 <a name="K" href="#K"><h2>Annex K</h2></a>
26938 Bounds-checking interfaces</pre>
26940 <a name="K.1" href="#K.1"><h3>K.1 Background</h3></a>
26942 Traditionally, the C Library has contained many functions that trust the programmer to
26943 provide output character arrays big enough to hold the result being produced. Not only
26944 do these functions not check that the arrays are big enough, they frequently lack the
26945 information needed to perform such checks. While it is possible to write safe, robust, and
26946 error-free code using the existing library, the library tends to promote programming styles
26947 that lead to mysterious failures if a result is too big for the provided array.
26949 A common programming style is to declare character arrays large enough to handle most
26950 practical cases. However, if these arrays are not large enough to handle the resulting
26951 strings, data can be written past the end of the array overwriting other data and program
26952 structures. The program never gets any indication that a problem exists, and so never has
26953 a chance to recover or to fail gracefully.
26955 Worse, this style of programming has compromised the security of computers and
26956 networks. Buffer overflows can often be exploited to run arbitrary code with the
26957 permissions of the vulnerable (defective) program.
26959 If the programmer writes runtime checks to verify lengths before calling library
26960 functions, then those runtime checks frequently duplicate work done inside the library
26961 functions, which discover string lengths as a side effect of doing their job.
26963 This annex provides alternative library functions that promote safer, more secure
26964 programming. The alternative functions verify that output buffers are large enough for
26965 the intended result and return a failure indicator if they are not. Data is never written past
26966 the end of an array. All string results are null terminated.
26968 This annex also addresses another problem that complicates writing robust code:
26969 functions that are not reentrant because they return pointers to static objects owned by the
26970 function. Such functions can be troublesome since a previously returned result can
26971 change if the function is called again, perhaps by another thread.
26972 <!--page 597 indent 4-->
26974 <a name="K.2" href="#K.2"><h3>K.2 Scope</h3></a>
26976 This annex specifies a series of optional extensions that can be useful in the mitigation of
26977 security vulnerabilities in programs, and comprise new functions, macros, and types
26978 declared or defined in existing standard headers.
26980 An implementation that defines __STDC_LIB_EXT1__ shall conform to the
26981 specifications in this annex.<sup><a href="#note367"><b>367)</b></a></sup>
26983 Subclause <a href="#K.3">K.3</a> should be read as if it were merged into the parallel structure of named
26984 subclauses of clause 7.
26987 <p><a name="note367">367)</a> Implementations that do not define __STDC_LIB_EXT1__ are not required to conform to these
26991 <a name="K.3" href="#K.3"><h3>K.3 Library</h3></a>
26993 <a name="K.3.1" href="#K.3.1"><h4>K.3.1 Introduction</h4></a>
26995 <a name="K.3.1.1" href="#K.3.1.1"><h5>K.3.1.1 Standard headers</h5></a>
26997 The functions, macros, and types declared or defined in <a href="#K.3">K.3</a> and its subclauses are not
26998 declared or defined by their respective headers if __STDC_WANT_LIB_EXT1__ is
26999 defined as a macro which expands to the integer constant 0 at the point in the source file
27000 where the appropriate header is first included.
27002 The functions, macros, and types declared or defined in <a href="#K.3">K.3</a> and its subclauses are
27003 declared and defined by their respective headers if __STDC_WANT_LIB_EXT1__ is
27004 defined as a macro which expands to the integer constant 1 at the point in the source file
27005 where the appropriate header is first included.<sup><a href="#note368"><b>368)</b></a></sup>
27007 It is implementation-defined whether the functions, macros, and types declared or defined
27008 in <a href="#K.3">K.3</a> and its subclauses are declared or defined by their respective headers if
27009 __STDC_WANT_LIB_EXT1__ is not defined as a macro at the point in the source file
27010 where the appropriate header is first included.<sup><a href="#note369"><b>369)</b></a></sup>
27012 Within a preprocessing translation unit, __STDC_WANT_LIB_EXT1__ shall be
27013 defined identically for all inclusions of any headers from subclause <a href="#K.3">K.3</a>. If
27014 __STDC_WANT_LIB_EXT1__ is defined differently for any such inclusion, the
27015 implementation shall issue a diagnostic as if a preprocessor error directive were used.
27018 <!--page 598 indent 4-->
27021 <p><a name="note368">368)</a> Future revisions of this International Standard may define meanings for other values of
27022 __STDC_WANT_LIB_EXT1__.
27024 <p><a name="note369">369)</a> Subclause <a href="#7.1.3">7.1.3</a> reserves certain names and patterns of names that an implementation may use in
27025 headers. All other names are not reserved, and a conforming implementation is not permitted to use
27026 them. While some of the names defined in <a href="#K.3">K.3</a> and its subclauses are reserved, others are not. If an
27027 unreserved name is defined in a header when __STDC_WANT_LIB_EXT1__ is defined as 0, the
27028 implementation is not conforming.
27031 <a name="K.3.1.2" href="#K.3.1.2"><h5>K.3.1.2 Reserved identifiers</h5></a>
27033 Each macro name in any of the following subclauses is reserved for use as specified if it
27034 is defined by any of its associated headers when included; unless explicitly stated
27035 otherwise (see <a href="#7.1.4">7.1.4</a>).
27037 All identifiers with external linkage in any of the following subclauses are reserved for
27038 use as identifiers with external linkage if any of them are used by the program. None of
27039 them are reserved if none of them are used.
27041 Each identifier with file scope listed in any of the following subclauses is reserved for use
27042 as a macro name and as an identifier with file scope in the same name space if it is
27043 defined by any of its associated headers when included.
27045 <a name="K.3.1.3" href="#K.3.1.3"><h5>K.3.1.3 Use of errno</h5></a>
27047 An implementation may set errno for the functions defined in this annex, but is not
27050 <a name="K.3.1.4" href="#K.3.1.4"><h5>K.3.1.4 Runtime-constraint violations</h5></a>
27052 Most functions in this annex include as part of their specification a list of runtime-
27053 constraints. These runtime-constraints are requirements on the program using the
27054 library.<sup><a href="#note370"><b>370)</b></a></sup>
27056 Implementations shall verify that the runtime-constraints for a function are not violated
27057 by the program. If a runtime-constraint is violated, the implementation shall call the
27058 currently registered runtime-constraint handler (see set_constraint_handler_s
27059 in <stdlib.h>). Multiple runtime-constraint violations in the same call to a library
27060 function result in only one call to the runtime-constraint handler. It is unspecified which
27061 one of the multiple runtime-constraint violations cause the handler to be called.
27063 If the runtime-constraints section for a function states an action to be performed when a
27064 runtime-constraint violation occurs, the function shall perform the action before calling
27065 the runtime-constraint handler. If the runtime-constraints section lists actions that are
27066 prohibited when a runtime-constraint violation occurs, then such actions are prohibited to
27067 the function both before calling the handler and after the handler returns.
27069 The runtime-constraint handler might not return. If the handler does return, the library
27070 function whose runtime-constraint was violated shall return some indication of failure as
27071 given by the returns section in the function's specification.
27075 <!--page 599 indent 4-->
27078 <p><a name="note370">370)</a> Although runtime-constraints replace many cases of undefined behavior, undefined behavior still
27079 exists in this annex. Implementations are free to detect any case of undefined behavior and treat it as a
27080 runtime-constraint violation by calling the runtime-constraint handler. This license comes directly
27081 from the definition of undefined behavior.
27084 <a name="K.3.2" href="#K.3.2"><h4>K.3.2 Errors <errno.h></h4></a>
27086 The header <errno.h> defines a type.
27091 which is type int.<sup><a href="#note371"><b>371)</b></a></sup>
27094 <p><a name="note371">371)</a> As a matter of programming style, errno_t may be used as the type of something that deals only
27095 with the values that might be found in errno. For example, a function which returns the value of
27096 errno might be declared as having the return type errno_t.
27099 <a name="K.3.3" href="#K.3.3"><h4>K.3.3 Common definitions <stddef.h></h4></a>
27101 The header <stddef.h> defines a type.
27106 which is the type size_t.<sup><a href="#note372"><b>372)</b></a></sup>
27109 <p><a name="note372">372)</a> See the description of the RSIZE_MAX macro in <stdint.h>.
27112 <a name="K.3.4" href="#K.3.4"><h4>K.3.4 Integer types <stdint.h></h4></a>
27114 The header <stdint.h> defines a macro.
27119 which expands to a value<sup><a href="#note373"><b>373)</b></a></sup> of type size_t. Functions that have parameters of type
27120 rsize_t consider it a runtime-constraint violation if the values of those parameters are
27121 greater than RSIZE_MAX.
27122 Recommended practice
27124 Extremely large object sizes are frequently a sign that an object's size was calculated
27125 incorrectly. For example, negative numbers appear as very large positive numbers when
27126 converted to an unsigned type like size_t. Also, some implementations do not support
27127 objects as large as the maximum value that can be represented by type size_t.
27129 For those reasons, it is sometimes beneficial to restrict the range of object sizes to detect
27130 programming errors. For implementations targeting machines with large address spaces,
27131 it is recommended that RSIZE_MAX be defined as the smaller of the size of the largest
27132 object supported or (SIZE_MAX >> 1), even if this limit is smaller than the size of
27133 some legitimate, but very large, objects. Implementations targeting machines with small
27134 address spaces may wish to define RSIZE_MAX as SIZE_MAX, which means that there
27136 <!--page 600 indent 4-->
27137 is no object size that is considered a runtime-constraint violation.
27140 <p><a name="note373">373)</a> The macro RSIZE_MAX need not expand to a constant expression.
27143 <a name="K.3.5" href="#K.3.5"><h4>K.3.5 Input/output <stdio.h></h4></a>
27145 The header <stdio.h> defines several macros and two types.
27150 which expands to an integer constant expression that is the size needed for an array of
27151 char large enough to hold a temporary file name string generated by the tmpnam_s
27155 which expands to an integer constant expression that is the maximum number of unique
27156 file names that can be generated by the tmpnam_s function.
27161 which is type int; and
27164 which is the type size_t.
27166 <a name="K.3.5.1" href="#K.3.5.1"><h5>K.3.5.1 Operations on files</h5></a>
27168 <a name="K.3.5.1.1" href="#K.3.5.1.1"><h5>K.3.5.1.1 The tmpfile_s function</h5></a>
27172 #define __STDC_WANT_LIB_EXT1__ 1
27173 #include <stdio.h>
27174 errno_t tmpfile_s(FILE * restrict * restrict streamptr);</pre>
27175 Runtime-constraints
27177 streamptr shall not be a null pointer.
27179 If there is a runtime-constraint violation, tmpfile_s does not attempt to create a file.
27180 <h6>Description</h6>
27182 The tmpfile_s function creates a temporary binary file that is different from any other
27183 existing file and that will automatically be removed when it is closed or at program
27184 termination. If the program terminates abnormally, whether an open temporary file is
27185 removed is implementation-defined. The file is opened for update with "wb+" mode
27186 with the meaning that mode has in the fopen_s function (including the mode's effect
27187 on exclusive access and file permissions).
27188 <!--page 601 indent 4-->
27190 If the file was created successfully, then the pointer to FILE pointed to by streamptr
27191 will be set to the pointer to the object controlling the opened file. Otherwise, the pointer
27192 to FILE pointed to by streamptr will be set to a null pointer.
27193 Recommended practice
27194 It should be possible to open at least TMP_MAX_S temporary files during the lifetime of
27195 the program (this limit may be shared with tmpnam_s) and there should be no limit on
27196 the number simultaneously open other than this limit and any limit on the number of open
27200 The tmpfile_s function returns zero if it created the file. If it did not create the file or
27201 there was a runtime-constraint violation, tmpfile_s returns a nonzero value.
27203 <a name="K.3.5.1.2" href="#K.3.5.1.2"><h5>K.3.5.1.2 The tmpnam_s function</h5></a>
27207 #define __STDC_WANT_LIB_EXT1__ 1
27208 #include <stdio.h>
27209 errno_t tmpnam_s(char *s, rsize_t maxsize);</pre>
27210 Runtime-constraints
27212 s shall not be a null pointer. maxsize shall be less than or equal to RSIZE_MAX.
27213 maxsize shall be greater than the length of the generated file name string.
27214 <h6>Description</h6>
27216 The tmpnam_s function generates a string that is a valid file name and that is not the
27217 same as the name of an existing file.<sup><a href="#note374"><b>374)</b></a></sup> The function is potentially capable of generating
27218 TMP_MAX_S different strings, but any or all of them may already be in use by existing
27219 files and thus not be suitable return values. The lengths of these strings shall be less than
27220 the value of the L_tmpnam_s macro.
27222 The tmpnam_s function generates a different string each time it is called.
27224 It is assumed that s points to an array of at least maxsize characters. This array will be
27225 set to generated string, as specified below.
27229 <!--page 602 indent 5-->
27231 The implementation shall behave as if no library function except tmpnam calls the
27232 tmpnam_s function.<sup><a href="#note375"><b>375)</b></a></sup>
27233 Recommended practice
27235 After a program obtains a file name using the tmpnam_s function and before the
27236 program creates a file with that name, the possibility exists that someone else may create
27237 a file with that same name. To avoid this race condition, the tmpfile_s function
27238 should be used instead of tmpnam_s when possible. One situation that requires the use
27239 of the tmpnam_s function is when the program needs to create a temporary directory
27240 rather than a temporary file.
27243 If no suitable string can be generated, or if there is a runtime-constraint violation, the
27244 tmpnam_s function writes a null character to s[0] (only if s is not null and maxsize
27245 is greater than zero) and returns a nonzero value.
27247 Otherwise, the tmpnam_s function writes the string in the array pointed to by s and
27249 Environmental limits
27251 The value of the macro TMP_MAX_S shall be at least 25.
27254 <p><a name="note374">374)</a> Files created using strings generated by the tmpnam_s function are temporary only in the sense that
27255 their names should not collide with those generated by conventional naming rules for the
27256 implementation. It is still necessary to use the remove function to remove such files when their use
27257 is ended, and before program termination. Implementations should take care in choosing the patterns
27258 used for names returned by tmpnam_s. For example, making a thread id part of the names avoids the
27259 race condition and possible conflict when multiple programs run simultaneously by the same user
27260 generate the same temporary file names.
27262 <p><a name="note375">375)</a> An implementation may have tmpnam call tmpnam_s (perhaps so there is only one naming
27263 convention for temporary files), but this is not required.
27266 <a name="K.3.5.2" href="#K.3.5.2"><h5>K.3.5.2 File access functions</h5></a>
27268 <a name="K.3.5.2.1" href="#K.3.5.2.1"><h5>K.3.5.2.1 The fopen_s function</h5></a>
27272 #define __STDC_WANT_LIB_EXT1__ 1
27273 #include <stdio.h>
27274 errno_t fopen_s(FILE * restrict * restrict streamptr,
27275 const char * restrict filename,
27276 const char * restrict mode);</pre>
27277 Runtime-constraints
27279 None of streamptr, filename, or mode shall be a null pointer.
27281 If there is a runtime-constraint violation, fopen_s does not attempt to open a file.
27282 Furthermore, if streamptr is not a null pointer, fopen_s sets *streamptr to the
27288 <!--page 603 indent 4-->
27289 <h6>Description</h6>
27291 The fopen_s function opens the file whose name is the string pointed to by
27292 filename, and associates a stream with it.
27294 The mode string shall be as described for fopen, with the addition that modes starting
27295 with the character 'w' or 'a' may be preceded by the character 'u', see below:
27296 uw truncate to zero length or create text file for writing, default
27299 uwx create text file for writing, default permissions
27300 ua append; open or create text file for writing at end-of-file, default
27303 uwb truncate to zero length or create binary file for writing, default
27306 uwbx create binary file for writing, default permissions
27307 uab append; open or create binary file for writing at end-of-file, default
27310 uw+ truncate to zero length or create text file for update, default
27313 uw+x create text file for update, default permissions
27314 ua+ append; open or create text file for update, writing at end-of-file,
27316 default permissions</pre>
27317 uw+b or uwb+ truncate to zero length or create binary file for update, default
27320 uw+bx or uwb+x create binary file for update, default permissions
27321 ua+b or uab+ append; open or create binary file for update, writing at end-of-file,
27324 default permissions</pre>
27325 Opening a file with exclusive mode ('x' as the last character in the mode argument)
27326 fails if the file already exists or cannot be created.
27328 To the extent that the underlying system supports the concepts, files opened for writing
27329 shall be opened with exclusive (also known as non-shared) access. If the file is being
27330 created, and the first character of the mode string is not 'u', to the extent that the
27331 underlying system supports it, the file shall have a file permission that prevents other
27332 users on the system from accessing the file. If the file is being created and first character
27333 of the mode string is 'u', then by the time the file has been closed, it shall have the
27334 system default file access permissions.<sup><a href="#note376"><b>376)</b></a></sup>
27336 If the file was opened successfully, then the pointer to FILE pointed to by streamptr
27337 will be set to the pointer to the object controlling the opened file. Otherwise, the pointer
27340 <!--page 604 indent 4-->
27341 to FILE pointed to by streamptr will be set to a null pointer.
27344 The fopen_s function returns zero if it opened the file. If it did not open the file or if
27345 there was a runtime-constraint violation, fopen_s returns a nonzero value.
27348 <p><a name="note376">376)</a> These are the same permissions that the file would have been created with by fopen.
27351 <a name="K.3.5.2.2" href="#K.3.5.2.2"><h5>K.3.5.2.2 The freopen_s function</h5></a>
27355 #define __STDC_WANT_LIB_EXT1__ 1
27356 #include <stdio.h>
27357 errno_t freopen_s(FILE * restrict * restrict newstreamptr,
27358 const char * restrict filename,
27359 const char * restrict mode,
27360 FILE * restrict stream);</pre>
27361 Runtime-constraints
27363 None of newstreamptr, mode, and stream shall be a null pointer.
27365 If there is a runtime-constraint violation, freopen_s neither attempts to close any file
27366 associated with stream nor attempts to open a file. Furthermore, if newstreamptr is
27367 not a null pointer, fopen_s sets *newstreamptr to the null pointer.
27368 <h6>Description</h6>
27370 The freopen_s function opens the file whose name is the string pointed to by
27371 filename and associates the stream pointed to by stream with it. The mode
27372 argument has the same meaning as in the fopen_s function (including the mode's effect
27373 on exclusive access and file permissions).
27375 If filename is a null pointer, the freopen_s function attempts to change the mode of
27376 the stream to that specified by mode, as if the name of the file currently associated with
27377 the stream had been used. It is implementation-defined which changes of mode are
27378 permitted (if any), and under what circumstances.
27380 The freopen_s function first attempts to close any file that is associated with stream.
27381 Failure to close the file is ignored. The error and end-of-file indicators for the stream are
27384 If the file was opened successfully, then the pointer to FILE pointed to by
27385 newstreamptr will be set to the value of stream. Otherwise, the pointer to FILE
27386 pointed to by newstreamptr will be set to a null pointer.
27389 The freopen_s function returns zero if it opened the file. If it did not open the file or
27390 there was a runtime-constraint violation, freopen_s returns a nonzero value.
27391 <!--page 605 indent 4-->
27393 <a name="K.3.5.3" href="#K.3.5.3"><h5>K.3.5.3 Formatted input/output functions</h5></a>
27395 Unless explicitly stated otherwise, if the execution of a function described in this
27396 subclause causes copying to take place between objects that overlap, the objects take on
27397 unspecified values.
27399 <a name="K.3.5.3.1" href="#K.3.5.3.1"><h5>K.3.5.3.1 The fprintf_s function</h5></a>
27403 #define __STDC_WANT_LIB_EXT1__ 1
27404 #include <stdio.h>
27405 int fprintf_s(FILE * restrict stream,
27406 const char * restrict format, ...);</pre>
27407 Runtime-constraints
27409 Neither stream nor format shall be a null pointer. The %n specifier<sup><a href="#note377"><b>377)</b></a></sup> (modified or
27410 not by flags, field width, or precision) shall not appear in the string pointed to by
27411 format. Any argument to fprintf_s corresponding to a %s specifier shall not be a
27414 If there is a runtime-constraint violation,<sup><a href="#note378"><b>378)</b></a></sup> the fprintf_s function does not attempt
27415 to produce further output, and it is unspecified to what extent fprintf_s produced
27416 output before discovering the runtime-constraint violation.
27417 <h6>Description</h6>
27419 The fprintf_s function is equivalent to the fprintf function except for the explicit
27420 runtime-constraints listed above.
27423 The fprintf_s function returns the number of characters transmitted, or a negative
27424 value if an output error, encoding error, or runtime-constraint violation occurred.
27429 <!--page 606 indent 4-->
27432 <p><a name="note377">377)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27433 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27434 format string was %%n.
27436 <p><a name="note378">378)</a> Because an implementation may treat any undefined behavior as a runtime-constraint violation, an
27437 implementation may treat any unsupported specifiers in the string pointed to by format as a runtime-
27438 constraint violation.
27441 <a name="K.3.5.3.2" href="#K.3.5.3.2"><h5>K.3.5.3.2 The fscanf_s function</h5></a>
27445 #define __STDC_WANT_LIB_EXT1__ 1
27446 #include <stdio.h>
27447 int fscanf_s(FILE * restrict stream,
27448 const char * restrict format, ...);</pre>
27449 Runtime-constraints
27451 Neither stream nor format shall be a null pointer. Any argument indirected though in
27452 order to store converted input shall not be a null pointer.
27454 If there is a runtime-constraint violation,<sup><a href="#note379"><b>379)</b></a></sup> the fscanf_s function does not attempt to
27455 perform further input, and it is unspecified to what extent fscanf_s performed input
27456 before discovering the runtime-constraint violation.
27457 <h6>Description</h6>
27459 The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion
27460 specifiers apply to a pair of arguments (unless assignment suppression is indicated by a
27461 *). The first of these arguments is the same as for fscanf. That argument is
27462 immediately followed in the argument list by the second argument, which has type
27463 rsize_t and gives the number of elements in the array pointed to by the first argument
27464 of the pair. If the first argument points to a scalar object, it is considered to be an array of
27465 one element.<sup><a href="#note380"><b>380)</b></a></sup>
27467 A matching failure occurs if the number of elements in a receiving object is insufficient to
27468 hold the converted input (including any trailing null character).
27471 The fscanf_s function returns the value of the macro EOF if an input failure occurs
27472 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27474 <!--page 607 indent 4-->
27475 fscanf_s function returns the number of input items assigned, which can be fewer than
27476 provided for, or even zero, in the event of an early matching failure.
27478 EXAMPLE 1 The call:
27480 #define __STDC_WANT_LIB_EXT1__ 1
27481 #include <stdio.h>
27483 int n, i; float x; char name[50];
27484 n = fscanf_s(stdin, "%d%f%s", &i, &x, name, (rsize_t) 50);</pre>
27485 with the input line:
27487 25 54.32E-1 thompson</pre>
27488 will assign to n the value 3, to i the value 25, to x the value 5.432, and to name the sequence
27492 EXAMPLE 2 The call:
27494 #define __STDC_WANT_LIB_EXT1__ 1
27495 #include <stdio.h>
27498 n = fscanf_s(stdin, "%s", s, sizeof s);</pre>
27499 with the input line:
27502 will assign to n the value 0 since a matching failure occurred because the sequence hello\0 requires an
27503 array of six characters to store it.
27507 <p><a name="note379">379)</a> Because an implementation may treat any undefined behavior as a runtime-constraint violation, an
27508 implementation may treat any unsupported specifiers in the string pointed to by format as a runtime-
27509 constraint violation.
27511 <p><a name="note380">380)</a> If the format is known at translation time, an implementation may issue a diagnostic for any argument
27512 used to store the result from a c, s, or [ conversion specifier if that argument is not followed by an
27513 argument of a type compatible with rsize_t. A limited amount of checking may be done if even if
27514 the format is not known at translation time. For example, an implementation may issue a diagnostic
27515 for each argument after format that has of type pointer to one of char, signed char,
27516 unsigned char, or void that is not followed by an argument of a type compatible with
27517 rsize_t. The diagnostic could warn that unless the pointer is being used with a conversion specifier
27518 using the hh length modifier, a length argument must follow the pointer argument. Another useful
27519 diagnostic could flag any non-pointer argument following format that did not have a type
27520 compatible with rsize_t.
27523 <a name="K.3.5.3.3" href="#K.3.5.3.3"><h5>K.3.5.3.3 The printf_s function</h5></a>
27527 #define __STDC_WANT_LIB_EXT1__ 1
27528 #include <stdio.h>
27529 int printf_s(const char * restrict format, ...);</pre>
27530 Runtime-constraints
27532 format shall not be a null pointer. The %n specifier<sup><a href="#note381"><b>381)</b></a></sup> (modified or not by flags, field
27533 width, or precision) shall not appear in the string pointed to by format. Any argument
27534 to printf_s corresponding to a %s specifier shall not be a null pointer.
27536 If there is a runtime-constraint violation, the printf_s function does not attempt to
27537 produce further output, and it is unspecified to what extent printf_s produced output
27538 before discovering the runtime-constraint violation.
27541 <!--page 608 indent 4-->
27542 <h6>Description</h6>
27544 The printf_s function is equivalent to the printf function except for the explicit
27545 runtime-constraints listed above.
27548 The printf_s function returns the number of characters transmitted, or a negative
27549 value if an output error, encoding error, or runtime-constraint violation occurred.
27552 <p><a name="note381">381)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27553 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27554 format string was %%n.
27557 <a name="K.3.5.3.4" href="#K.3.5.3.4"><h5>K.3.5.3.4 The scanf_s function</h5></a>
27561 #define __STDC_WANT_LIB_EXT1__ 1
27562 #include <stdio.h>
27563 int scanf_s(const char * restrict format, ...);</pre>
27564 Runtime-constraints
27566 format shall not be a null pointer. Any argument indirected though in order to store
27567 converted input shall not be a null pointer.
27569 If there is a runtime-constraint violation, the scanf_s function does not attempt to
27570 perform further input, and it is unspecified to what extent scanf_s performed input
27571 before discovering the runtime-constraint violation.
27572 <h6>Description</h6>
27574 The scanf_s function is equivalent to fscanf_s with the argument stdin
27575 interposed before the arguments to scanf_s.
27578 The scanf_s function returns the value of the macro EOF if an input failure occurs
27579 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27580 scanf_s function returns the number of input items assigned, which can be fewer than
27581 provided for, or even zero, in the event of an early matching failure.
27583 <a name="K.3.5.3.5" href="#K.3.5.3.5"><h5>K.3.5.3.5 The snprintf_s function</h5></a>
27587 #define __STDC_WANT_LIB_EXT1__ 1
27588 #include <stdio.h>
27589 int snprintf_s(char * restrict s, rsize_t n,
27590 const char * restrict format, ...);</pre>
27591 Runtime-constraints
27593 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
27594 than RSIZE_MAX. The %n specifier<sup><a href="#note382"><b>382)</b></a></sup> (modified or not by flags, field width, or
27595 precision) shall not appear in the string pointed to by format. Any argument to
27596 <!--page 609 indent 4-->
27597 snprintf_s corresponding to a %s specifier shall not be a null pointer. No encoding
27600 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
27601 than zero and less than RSIZE_MAX, then the snprintf_s function sets s[0] to the
27603 <h6>Description</h6>
27605 The snprintf_s function is equivalent to the snprintf function except for the
27606 explicit runtime-constraints listed above.
27608 The snprintf_s function, unlike sprintf_s, will truncate the result to fit within the
27609 array pointed to by s.
27612 The snprintf_s function returns the number of characters that would have been
27613 written had n been sufficiently large, not counting the terminating null character, or a
27614 negative value if a runtime-constraint violation occurred. Thus, the null-terminated
27615 output has been completely written if and only if the returned value is nonnegative and
27619 <p><a name="note382">382)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27620 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27621 format string was %%n.
27624 <a name="K.3.5.3.6" href="#K.3.5.3.6"><h5>K.3.5.3.6 The sprintf_s function</h5></a>
27628 #define __STDC_WANT_LIB_EXT1__ 1
27629 #include <stdio.h>
27630 int sprintf_s(char * restrict s, rsize_t n,
27631 const char * restrict format, ...);</pre>
27632 Runtime-constraints
27634 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
27635 than RSIZE_MAX. The number of characters (including the trailing null) required for the
27636 result to be written to the array pointed to by s shall not be greater than n. The %n
27637 specifier<sup><a href="#note383"><b>383)</b></a></sup> (modified or not by flags, field width, or precision) shall not appear in the
27638 string pointed to by format. Any argument to sprintf_s corresponding to a %s
27639 specifier shall not be a null pointer. No encoding error shall occur.
27643 <!--page 610 indent 4-->
27645 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
27646 than zero and less than RSIZE_MAX, then the sprintf_s function sets s[0] to the
27648 <h6>Description</h6>
27650 The sprintf_s function is equivalent to the sprintf function except for the
27651 parameter n and the explicit runtime-constraints listed above.
27653 The sprintf_s function, unlike snprintf_s, treats a result too big for the array
27654 pointed to by s as a runtime-constraint violation.
27657 If no runtime-constraint violation occurred, the sprintf_s function returns the number
27658 of characters written in the array, not counting the terminating null character. If an
27659 encoding error occurred, sprintf_s returns a negative value. If any other runtime-
27660 constraint violation occurred, sprintf_s returns zero.
27663 <p><a name="note383">383)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27664 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27665 format string was %%n.
27668 <a name="K.3.5.3.7" href="#K.3.5.3.7"><h5>K.3.5.3.7 The sscanf_s function</h5></a>
27672 #define __STDC_WANT_LIB_EXT1__ 1
27673 #include <stdio.h>
27674 int sscanf_s(const char * restrict s,
27675 const char * restrict format, ...);</pre>
27676 Runtime-constraints
27678 Neither s nor format shall be a null pointer. Any argument indirected though in order
27679 to store converted input shall not be a null pointer.
27681 If there is a runtime-constraint violation, the sscanf_s function does not attempt to
27682 perform further input, and it is unspecified to what extent sscanf_s performed input
27683 before discovering the runtime-constraint violation.
27684 <h6>Description</h6>
27686 The sscanf_s function is equivalent to fscanf_s, except that input is obtained from
27687 a string (specified by the argument s) rather than from a stream. Reaching the end of the
27688 string is equivalent to encountering end-of-file for the fscanf_s function. If copying
27689 takes place between objects that overlap, the objects take on unspecified values.
27692 The sscanf_s function returns the value of the macro EOF if an input failure occurs
27693 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27694 sscanf_s function returns the number of input items assigned, which can be fewer than
27695 provided for, or even zero, in the event of an early matching failure.
27696 <!--page 611 indent 4-->
27698 <a name="K.3.5.3.8" href="#K.3.5.3.8"><h5>K.3.5.3.8 The vfprintf_s function</h5></a>
27702 #define __STDC_WANT_LIB_EXT1__ 1
27703 #include <stdarg.h>
27704 #include <stdio.h>
27705 int vfprintf_s(FILE * restrict stream,
27706 const char * restrict format,
27707 va_list arg);</pre>
27708 Runtime-constraints
27710 Neither stream nor format shall be a null pointer. The %n specifier<sup><a href="#note384"><b>384)</b></a></sup> (modified or
27711 not by flags, field width, or precision) shall not appear in the string pointed to by
27712 format. Any argument to vfprintf_s corresponding to a %s specifier shall not be a
27715 If there is a runtime-constraint violation, the vfprintf_s function does not attempt to
27716 produce further output, and it is unspecified to what extent vfprintf_s produced
27717 output before discovering the runtime-constraint violation.
27718 <h6>Description</h6>
27720 The vfprintf_s function is equivalent to the vfprintf function except for the
27721 explicit runtime-constraints listed above.
27724 The vfprintf_s function returns the number of characters transmitted, or a negative
27725 value if an output error, encoding error, or runtime-constraint violation occurred.
27728 <p><a name="note384">384)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27729 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27730 format string was %%n.
27733 <a name="K.3.5.3.9" href="#K.3.5.3.9"><h5>K.3.5.3.9 The vfscanf_s function</h5></a>
27737 #define __STDC_WANT_LIB_EXT1__ 1
27738 #include <stdarg.h>
27739 #include <stdio.h>
27740 int vfscanf_s(FILE * restrict stream,
27741 const char * restrict format,
27742 va_list arg);</pre>
27747 <!--page 612 indent 4-->
27748 Runtime-constraints
27750 Neither stream nor format shall be a null pointer. Any argument indirected though in
27751 order to store converted input shall not be a null pointer.
27753 If there is a runtime-constraint violation, the vfscanf_s function does not attempt to
27754 perform further input, and it is unspecified to what extent vfscanf_s performed input
27755 before discovering the runtime-constraint violation.
27756 <h6>Description</h6>
27758 The vfscanf_s function is equivalent to fscanf_s, with the variable argument list
27759 replaced by arg, which shall have been initialized by the va_start macro (and
27760 possibly subsequent va_arg calls). The vfscanf_s function does not invoke the
27761 va_end macro.<sup><a href="#note385"><b>385)</b></a></sup>
27764 The vfscanf_s function returns the value of the macro EOF if an input failure occurs
27765 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27766 vfscanf_s function returns the number of input items assigned, which can be fewer
27767 than provided for, or even zero, in the event of an early matching failure.
27770 <p><a name="note385">385)</a> As the functions vfprintf_s, vfscanf_s, vprintf_s, vscanf_s, vsnprintf_s,
27771 vsprintf_s, and vsscanf_s invoke the va_arg macro, the value of arg after the return is
27775 <a name="K.3.5.3.10" href="#K.3.5.3.10"><h5>K.3.5.3.10 The vprintf_s function</h5></a>
27779 #define __STDC_WANT_LIB_EXT1__ 1
27780 #include <stdarg.h>
27781 #include <stdio.h>
27782 int vprintf_s(const char * restrict format,
27783 va_list arg);</pre>
27784 Runtime-constraints
27786 format shall not be a null pointer. The %n specifier<sup><a href="#note386"><b>386)</b></a></sup> (modified or not by flags, field
27787 width, or precision) shall not appear in the string pointed to by format. Any argument
27788 to vprintf_s corresponding to a %s specifier shall not be a null pointer.
27790 If there is a runtime-constraint violation, the vprintf_s function does not attempt to
27791 produce further output, and it is unspecified to what extent vprintf_s produced output
27792 before discovering the runtime-constraint violation.
27794 <!--page 613 indent 4-->
27795 <h6>Description</h6>
27797 The vprintf_s function is equivalent to the vprintf function except for the explicit
27798 runtime-constraints listed above.
27801 The vprintf_s function returns the number of characters transmitted, or a negative
27802 value if an output error, encoding error, or runtime-constraint violation occurred.
27805 <p><a name="note386">386)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27806 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27807 format string was %%n.
27810 <a name="K.3.5.3.11" href="#K.3.5.3.11"><h5>K.3.5.3.11 The vscanf_s function</h5></a>
27814 #define __STDC_WANT_LIB_EXT1__ 1
27815 #include <stdarg.h>
27816 #include <stdio.h>
27817 int vscanf_s(const char * restrict format,
27818 va_list arg);</pre>
27819 Runtime-constraints
27821 format shall not be a null pointer. Any argument indirected though in order to store
27822 converted input shall not be a null pointer.
27824 If there is a runtime-constraint violation, the vscanf_s function does not attempt to
27825 perform further input, and it is unspecified to what extent vscanf_s performed input
27826 before discovering the runtime-constraint violation.
27827 <h6>Description</h6>
27829 The vscanf_s function is equivalent to scanf_s, with the variable argument list
27830 replaced by arg, which shall have been initialized by the va_start macro (and
27831 possibly subsequent va_arg calls). The vscanf_s function does not invoke the
27832 va_end macro.<sup><a href="#note387"><b>387)</b></a></sup>
27835 The vscanf_s function returns the value of the macro EOF if an input failure occurs
27836 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27837 vscanf_s function returns the number of input items assigned, which can be fewer than
27838 provided for, or even zero, in the event of an early matching failure.
27843 <!--page 614 indent 4-->
27846 <p><a name="note387">387)</a> As the functions vfprintf_s, vfscanf_s, vprintf_s, vscanf_s, vsnprintf_s,
27847 vsprintf_s, and vsscanf_s invoke the va_arg macro, the value of arg after the return is
27851 <a name="K.3.5.3.12" href="#K.3.5.3.12"><h5>K.3.5.3.12 The vsnprintf_s function</h5></a>
27855 #define __STDC_WANT_LIB_EXT1__ 1
27856 #include <stdarg.h>
27857 #include <stdio.h>
27858 int vsnprintf_s(char * restrict s, rsize_t n,
27859 const char * restrict format,
27860 va_list arg);</pre>
27861 Runtime-constraints
27863 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
27864 than RSIZE_MAX. The %n specifier<sup><a href="#note388"><b>388)</b></a></sup> (modified or not by flags, field width, or
27865 precision) shall not appear in the string pointed to by format. Any argument to
27866 vsnprintf_s corresponding to a %s specifier shall not be a null pointer. No encoding
27869 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
27870 than zero and less than RSIZE_MAX, then the vsnprintf_s function sets s[0] to the
27872 <h6>Description</h6>
27874 The vsnprintf_s function is equivalent to the vsnprintf function except for the
27875 explicit runtime-constraints listed above.
27877 The vsnprintf_s function, unlike vsprintf_s, will truncate the result to fit within
27878 the array pointed to by s.
27881 The vsnprintf_s function returns the number of characters that would have been
27882 written had n been sufficiently large, not counting the terminating null character, or a
27883 negative value if a runtime-constraint violation occurred. Thus, the null-terminated
27884 output has been completely written if and only if the returned value is nonnegative and
27890 <!--page 615 indent 4-->
27893 <p><a name="note388">388)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27894 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27895 format string was %%n.
27898 <a name="K.3.5.3.13" href="#K.3.5.3.13"><h5>K.3.5.3.13 The vsprintf_s function</h5></a>
27902 #define __STDC_WANT_LIB_EXT1__ 1
27903 #include <stdarg.h>
27904 #include <stdio.h>
27905 int vsprintf_s(char * restrict s, rsize_t n,
27906 const char * restrict format,
27907 va_list arg);</pre>
27908 Runtime-constraints
27910 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
27911 than RSIZE_MAX. The number of characters (including the trailing null) required for the
27912 result to be written to the array pointed to by s shall not be greater than n. The %n
27913 specifier<sup><a href="#note389"><b>389)</b></a></sup> (modified or not by flags, field width, or precision) shall not appear in the
27914 string pointed to by format. Any argument to vsprintf_s corresponding to a %s
27915 specifier shall not be a null pointer. No encoding error shall occur.
27917 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
27918 than zero and less than RSIZE_MAX, then the vsprintf_s function sets s[0] to the
27920 <h6>Description</h6>
27922 The vsprintf_s function is equivalent to the vsprintf function except for the
27923 parameter n and the explicit runtime-constraints listed above.
27925 The vsprintf_s function, unlike vsnprintf_s, treats a result too big for the array
27926 pointed to by s as a runtime-constraint violation.
27929 If no runtime-constraint violation occurred, the vsprintf_s function returns the
27930 number of characters written in the array, not counting the terminating null character. If
27931 an encoding error occurred, vsprintf_s returns a negative value. If any other
27932 runtime-constraint violation occurred, vsprintf_s returns zero.
27937 <!--page 616 indent 4-->
27940 <p><a name="note389">389)</a> It is not a runtime-constraint violation for the characters %n to appear in sequence in the string pointed
27941 at by format when those characters are not a interpreted as a %n specifier. For example, if the entire
27942 format string was %%n.
27945 <a name="K.3.5.3.14" href="#K.3.5.3.14"><h5>K.3.5.3.14 The vsscanf_s function</h5></a>
27949 #define __STDC_WANT_LIB_EXT1__ 1
27950 #include <stdarg.h>
27951 #include <stdio.h>
27952 int vsscanf_s(const char * restrict s,
27953 const char * restrict format,
27954 va_list arg);</pre>
27955 Runtime-constraints
27957 Neither s nor format shall be a null pointer. Any argument indirected though in order
27958 to store converted input shall not be a null pointer.
27960 If there is a runtime-constraint violation, the vsscanf_s function does not attempt to
27961 perform further input, and it is unspecified to what extent vsscanf_s performed input
27962 before discovering the runtime-constraint violation.
27963 <h6>Description</h6>
27965 The vsscanf_s function is equivalent to sscanf_s, with the variable argument list
27966 replaced by arg, which shall have been initialized by the va_start macro (and
27967 possibly subsequent va_arg calls). The vsscanf_s function does not invoke the
27968 va_end macro.<sup><a href="#note390"><b>390)</b></a></sup>
27971 The vsscanf_s function returns the value of the macro EOF if an input failure occurs
27972 before any conversion or if there is a runtime-constraint violation. Otherwise, the
27973 vscanf_s function returns the number of input items assigned, which can be fewer than
27974 provided for, or even zero, in the event of an early matching failure.
27977 <p><a name="note390">390)</a> As the functions vfprintf_s, vfscanf_s, vprintf_s, vscanf_s, vsnprintf_s,
27978 vsprintf_s, and vsscanf_s invoke the va_arg macro, the value of arg after the return is
27982 <a name="K.3.5.4" href="#K.3.5.4"><h5>K.3.5.4 Character input/output functions</h5></a>
27984 <a name="K.3.5.4.1" href="#K.3.5.4.1"><h5>K.3.5.4.1 The gets_s function</h5></a>
27988 #define __STDC_WANT_LIB_EXT1__ 1
27989 #include <stdio.h>
27990 char *gets_s(char *s, rsize_t n);</pre>
27995 <!--page 617 indent 4-->
27996 Runtime-constraints
27998 s shall not be a null pointer. n shall neither be equal to zero nor be greater than
27999 RSIZE_MAX. A new-line character, end-of-file, or read error shall occur within reading
28000 n-1 characters from stdin.<sup><a href="#note391"><b>391)</b></a></sup>
28002 If there is a runtime-constraint violation, s[0] is set to the null character, and characters
28003 are read and discarded from stdin until a new-line character is read, or end-of-file or a
28005 <h6>Description</h6>
28007 The gets_s function reads at most one less than the number of characters specified by n
28008 from the stream pointed to by stdin, into the array pointed to by s. No additional
28009 characters are read after a new-line character (which is discarded) or after end-of-file.
28010 The discarded new-line character does not count towards number of characters read. A
28011 null character is written immediately after the last character read into the array.
28013 If end-of-file is encountered and no characters have been read into the array, or if a read
28014 error occurs during the operation, then s[0] is set to the null character, and the other
28015 elements of s take unspecified values.
28016 Recommended practice
28018 The fgets function allows properly-written programs to safely process input lines too
28019 long to store in the result array. In general this requires that callers of fgets pay
28020 attention to the presence or absence of a new-line character in the result array. Consider
28021 using fgets (along with any needed processing based on new-line characters) instead of
28025 The gets_s function returns s if successful. If there was a runtime-constraint violation,
28026 or if end-of-file is encountered and no characters have been read into the array, or if a
28027 read error occurs during the operation, then a null pointer is returned.
28032 <!--page 618 indent 4-->
28035 <p><a name="note391">391)</a> The gets_s function, unlike the historical gets function, makes it a runtime-constraint violation for
28036 a line of input to overflow the buffer to store it. Unlike the fgets function, gets_s maintains a
28037 one-to-one relationship between input lines and successful calls to gets_s. Programs that use gets
28038 expect such a relationship.
28041 <a name="K.3.6" href="#K.3.6"><h4>K.3.6 General utilities <stdlib.h></h4></a>
28043 The header <stdlib.h> defines three types.
28048 which is type int; and
28051 which is the type size_t; and
28053 constraint_handler_t</pre>
28054 which has the following definition
28056 typedef void (*constraint_handler_t)(
28057 const char * restrict msg,
28058 void * restrict ptr,
28059 errno_t error);</pre>
28061 <a name="K.3.6.1" href="#K.3.6.1"><h5>K.3.6.1 Runtime-constraint handling</h5></a>
28063 <a name="K.3.6.1.1" href="#K.3.6.1.1"><h5>K.3.6.1.1 The set_constraint_handler_s function</h5></a>
28067 #define __STDC_WANT_LIB_EXT1__ 1
28068 #include <stdlib.h>
28069 constraint_handler_t set_constraint_handler_s(
28070 constraint_handler_t handler);</pre>
28071 <h6>Description</h6>
28073 The set_constraint_handler_s function sets the runtime-constraint handler to
28074 be handler. The runtime-constraint handler is the function to be called when a library
28075 function detects a runtime-constraint violation. Only the most recent handler registered
28076 with set_constraint_handler_s is called when a runtime-constraint violation
28079 When the handler is called, it is passed the following arguments in the following order:
28081 <li> A pointer to a character string describing the runtime-constraint violation.
28082 <li> A null pointer or a pointer to an implementation defined object.
28083 <li> If the function calling the handler has a return type declared as errno_t, the
28084 return value of the function is passed. Otherwise, a positive value of type
28086 <!--page 619 indent 4-->
28089 The implementation has a default constraint handler that is used if no calls to the
28090 set_constraint_handler_s function have been made. The behavior of the
28091 default handler is implementation-defined, and it may cause the program to exit or abort.
28093 If the handler argument to set_constraint_handler_s is a null pointer, the
28094 implementation default handler becomes the current constraint handler.
28097 The set_constraint_handler_s function returns a pointer to the previously
28098 registered handler.<sup><a href="#note392"><b>392)</b></a></sup>
28101 <p><a name="note392">392)</a> If the previous handler was registered by calling set_constraint_handler_s with a null
28102 pointer argument, a pointer to the implementation default handler is returned (not NULL).
28105 <a name="K.3.6.1.2" href="#K.3.6.1.2"><h5>K.3.6.1.2 The abort_handler_s function</h5></a>
28109 #define __STDC_WANT_LIB_EXT1__ 1
28110 #include <stdlib.h>
28111 void abort_handler_s(
28112 const char * restrict msg,
28113 void * restrict ptr,
28114 errno_t error);</pre>
28115 <h6>Description</h6>
28117 A pointer to the abort_handler_s function shall be a suitable argument to the
28118 set_constraint_handler_s function.
28120 The abort_handler_s function writes a message on the standard error stream in an
28121 implementation-defined format. The message shall include the string pointed to by msg.
28122 The abort_handler_s function then calls the abort function.<sup><a href="#note393"><b>393)</b></a></sup>
28125 The abort_handler_s function does not return to its caller.
28130 <!--page 620 indent 4-->
28133 <p><a name="note393">393)</a> Many implementations invoke a debugger when the abort function is called.
28136 <a name="K.3.6.1.3" href="#K.3.6.1.3"><h5>K.3.6.1.3 The ignore_handler_s function</h5></a>
28140 #define __STDC_WANT_LIB_EXT1__ 1
28141 #include <stdlib.h>
28142 void ignore_handler_s(
28143 const char * restrict msg,
28144 void * restrict ptr,
28145 errno_t error);</pre>
28146 <h6>Description</h6>
28148 A pointer to the ignore_handler_s function shall be a suitable argument to the
28149 set_constraint_handler_s function.
28151 The ignore_handler_s function simply returns to its caller.<sup><a href="#note394"><b>394)</b></a></sup>
28154 The ignore_handler_s function returns no value.
28157 <p><a name="note394">394)</a> If the runtime-constraint handler is set to the ignore_handler_s function, any library function in
28158 which a runtime-constraint violation occurs will return to its caller. The caller can determine whether
28159 a runtime-constraint violation occurred based on the library function's specification (usually, the
28160 library function returns a nonzero errno_t).
28163 <a name="K.3.6.2" href="#K.3.6.2"><h5>K.3.6.2 Communication with the environment</h5></a>
28165 <a name="K.3.6.2.1" href="#K.3.6.2.1"><h5>K.3.6.2.1 The getenv_s function</h5></a>
28169 #define __STDC_WANT_LIB_EXT1__ 1
28170 #include <stdlib.h>
28171 errno_t getenv_s(size_t * restrict len,
28172 char * restrict value, rsize_t maxsize,
28173 const char * restrict name);</pre>
28174 Runtime-constraints
28176 name shall not be a null pointer. maxsize shall neither equal zero nor be greater than
28177 RSIZE_MAX. If maxsize is not equal to zero, then value shall not be a null pointer.
28179 If there is a runtime-constraint violation, the integer pointed to by len is set to 0 (if len
28180 is not null), and the environment list is not searched.
28181 <h6>Description</h6>
28183 The getenv_s function searches an environment list, provided by the host environment,
28184 for a string that matches the string pointed to by name.
28187 <!--page 621 indent 4-->
28189 If that name is found then getenv_s performs the following actions. If len is not a
28190 null pointer, the length of the string associated with the matched list member is stored in
28191 the integer pointed to by len. If the length of the associated string is less than maxsize,
28192 then the associated string is copied to the array pointed to by value.
28194 If that name is not found then getenv_s performs the following actions. If len is not
28195 a null pointer, zero is stored in the integer pointed to by len. If maxsize is greater than
28196 zero, then value[0] is set to the null character.
28198 The set of environment names and the method for altering the environment list are
28199 implementation-defined.
28202 The getenv_s function returns zero if the specified name is found and the associated
28203 string was successfully stored in value. Otherwise, a nonzero value is returned.
28205 <a name="K.3.6.3" href="#K.3.6.3"><h5>K.3.6.3 Searching and sorting utilities</h5></a>
28207 These utilities make use of a comparison function to search or sort arrays of unspecified
28208 type. Where an argument declared as size_t nmemb specifies the length of the array
28209 for a function, if nmemb has the value zero on a call to that function, then the comparison
28210 function is not called, a search finds no matching element, sorting performs no
28211 rearrangement, and the pointer to the array may be null.
28213 The implementation shall ensure that the second argument of the comparison function
28214 (when called from bsearch_s), or both arguments (when called from qsort_s), are
28215 pointers to elements of the array.<sup><a href="#note395"><b>395)</b></a></sup> The first argument when called from bsearch_s
28218 The comparison function shall not alter the contents of either the array or search key. The
28219 implementation may reorder elements of the array between calls to the comparison
28220 function, but shall not otherwise alter the contents of any individual element.
28222 When the same objects (consisting of size bytes, irrespective of their current positions
28223 in the array) are passed more than once to the comparison function, the results shall be
28224 consistent with one another. That is, for qsort_s they shall define a total ordering on
28225 the array, and for bsearch_s the same object shall always compare the same way with
28231 <!--page 622 indent 4-->
28233 A sequence point occurs immediately before and immediately after each call to the
28234 comparison function, and also between any call to the comparison function and any
28235 movement of the objects passed as arguments to that call.
28238 <p><a name="note395">395)</a> That is, if the value passed is p, then the following expressions are always valid and nonzero:
28241 ((char *)p - (char *)base) % size == 0
28242 (char *)p >= (char *)base
28243 (char *)p < (char *)base + nmemb * size</pre>
28246 <a name="K.3.6.3.1" href="#K.3.6.3.1"><h5>K.3.6.3.1 The bsearch_s function</h5></a>
28250 #define __STDC_WANT_LIB_EXT1__ 1
28251 #include <stdlib.h>
28252 void *bsearch_s(const void *key, const void *base,
28253 rsize_t nmemb, rsize_t size,
28254 int (*compar)(const void *k, const void *y,
28256 void *context);</pre>
28257 Runtime-constraints
28259 Neither nmemb nor size shall be greater than RSIZE_MAX. If nmemb is not equal to
28260 zero, then none of key, base, or compar shall be a null pointer.
28262 If there is a runtime-constraint violation, the bsearch_s function does not search the
28264 <h6>Description</h6>
28266 The bsearch_s function searches an array of nmemb objects, the initial element of
28267 which is pointed to by base, for an element that matches the object pointed to by key.
28268 The size of each element of the array is specified by size.
28270 The comparison function pointed to by compar is called with three arguments. The first
28271 two point to the key object and to an array element, in that order. The function shall
28272 return an integer less than, equal to, or greater than zero if the key object is considered,
28273 respectively, to be less than, to match, or to be greater than the array element. The array
28274 shall consist of: all the elements that compare less than, all the elements that compare
28275 equal to, and all the elements that compare greater than the key object, in that order.<sup><a href="#note396"><b>396)</b></a></sup>
28276 The third argument to the comparison function is the context argument passed to
28277 bsearch_s. The sole use of context by bsearch_s is to pass it to the comparison
28278 function.<sup><a href="#note397"><b>397)</b></a></sup>
28283 <!--page 623 indent 4-->
28286 The bsearch_s function returns a pointer to a matching element of the array, or a null
28287 pointer if no match is found or there is a runtime-constraint violation. If two elements
28288 compare as equal, which element is matched is unspecified.
28291 <p><a name="note396">396)</a> In practice, this means that the entire array has been sorted according to the comparison function.
28293 <p><a name="note397">397)</a> The context argument is for the use of the comparison function in performing its duties. For
28294 example, it might specify a collating sequence used by the comparison function.
28297 <a name="K.3.6.3.2" href="#K.3.6.3.2"><h5>K.3.6.3.2 The qsort_s function</h5></a>
28301 #define __STDC_WANT_LIB_EXT1__ 1
28302 #include <stdlib.h>
28303 errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size,
28304 int (*compar)(const void *x, const void *y,
28306 void *context);</pre>
28307 Runtime-constraints
28309 Neither nmemb nor size shall be greater than RSIZE_MAX. If nmemb is not equal to
28310 zero, then neither base nor compar shall be a null pointer.
28312 If there is a runtime-constraint violation, the qsort_s function does not sort the array.
28313 <h6>Description</h6>
28315 The qsort_s function sorts an array of nmemb objects, the initial element of which is
28316 pointed to by base. The size of each object is specified by size.
28318 The contents of the array are sorted into ascending order according to a comparison
28319 function pointed to by compar, which is called with three arguments. The first two
28320 point to the objects being compared. The function shall return an integer less than, equal
28321 to, or greater than zero if the first argument is considered to be respectively less than,
28322 equal to, or greater than the second. The third argument to the comparison function is the
28323 context argument passed to qsort_s. The sole use of context by qsort_s is to
28324 pass it to the comparison function.<sup><a href="#note398"><b>398)</b></a></sup>
28326 If two elements compare as equal, their relative order in the resulting sorted array is
28330 The qsort_s function returns zero if there was no runtime-constraint violation.
28331 Otherwise, a nonzero value is returned.
28336 <!--page 624 indent 4-->
28339 <p><a name="note398">398)</a> The context argument is for the use of the comparison function in performing its duties. For
28340 example, it might specify a collating sequence used by the comparison function.
28343 <a name="K.3.6.4" href="#K.3.6.4"><h5>K.3.6.4 Multibyte/wide character conversion functions</h5></a>
28345 The behavior of the multibyte character functions is affected by the LC_CTYPE category
28346 of the current locale. For a state-dependent encoding, each function is placed into its
28347 initial conversion state by a call for which its character pointer argument, s, is a null
28348 pointer. Subsequent calls with s as other than a null pointer cause the internal conversion
28349 state of the function to be altered as necessary. A call with s as a null pointer causes
28350 these functions to set the int pointed to by their status argument to a nonzero value if
28351 encodings have state dependency, and zero otherwise.<sup><a href="#note399"><b>399)</b></a></sup> Changing the LC_CTYPE
28352 category causes the conversion state of these functions to be indeterminate.
28355 <p><a name="note399">399)</a> If the locale employs special bytes to change the shift state, these bytes do not produce separate wide
28356 character codes, but are grouped with an adjacent multibyte character.
28359 <a name="K.3.6.4.1" href="#K.3.6.4.1"><h5>K.3.6.4.1 The wctomb_s function</h5></a>
28363 #define __STDC_WANT_LIB_EXT1__ 1
28364 #include <stdlib.h>
28365 errno_t wctomb_s(int * restrict status,
28369 Runtime-constraints
28371 Let n denote the number of bytes needed to represent the multibyte character
28372 corresponding to the wide character given by wc (including any shift sequences).
28374 If s is not a null pointer, then smax shall not be less than n, and smax shall not be
28375 greater than RSIZE_MAX. If s is a null pointer, then smax shall equal zero.
28377 If there is a runtime-constraint violation, wctomb_s does not modify the int pointed to
28378 by status, and if s is not a null pointer, no more than smax elements in the array
28379 pointed to by s will be accessed.
28380 <h6>Description</h6>
28382 The wctomb_s function determines n and stores the multibyte character representation
28383 of wc in the array whose first element is pointed to by s (if s is not a null pointer). The
28384 number of characters stored never exceeds MB_CUR_MAX or smax. If wc is a null wide
28385 character, a null byte is stored, preceded by any shift sequence needed to restore the
28386 initial shift state, and the function is left in the initial conversion state.
28388 The implementation shall behave as if no library function calls the wctomb_s function.
28393 <!--page 625 indent 5-->
28395 If s is a null pointer, the wctomb_s function stores into the int pointed to by status a
28396 nonzero or zero value, if multibyte character encodings, respectively, do or do not have
28397 state-dependent encodings.
28399 If s is not a null pointer, the wctomb_s function stores into the int pointed to by
28400 status either n or -1 if wc, respectively, does or does not correspond to a valid
28401 multibyte character.
28403 In no case will the int pointed to by status be set to a value greater than the
28407 The wctomb_s function returns zero if successful, and a nonzero value if there was a
28408 runtime-constraint violation or wc did not correspond to a valid multibyte character.
28410 <a name="K.3.6.5" href="#K.3.6.5"><h5>K.3.6.5 Multibyte/wide string conversion functions</h5></a>
28412 The behavior of the multibyte string functions is affected by the LC_CTYPE category of
28413 the current locale.
28415 <a name="K.3.6.5.1" href="#K.3.6.5.1"><h5>K.3.6.5.1 The mbstowcs_s function</h5></a>
28419 #include <stdlib.h>
28420 errno_t mbstowcs_s(size_t * restrict retval,
28421 wchar_t * restrict dst, rsize_t dstmax,
28422 const char * restrict src, rsize_t len);</pre>
28423 Runtime-constraints
28425 Neither retval nor src shall be a null pointer. If dst is not a null pointer, then
28426 neither len nor dstmax shall be greater than RSIZE_MAX. If dst is a null pointer,
28427 then dstmax shall equal zero. If dst is not a null pointer, then dstmax shall not equal
28428 zero. If dst is not a null pointer and len is not less than dstmax, then a null character
28429 shall occur within the first dstmax multibyte characters of the array pointed to by src.
28431 If there is a runtime-constraint violation, then mbstowcs_s does the following. If
28432 retval is not a null pointer, then mbstowcs_s sets *retval to (size_t)(-1). If
28433 dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
28434 then mbstowcs_s sets dst[0] to the null wide character.
28435 <h6>Description</h6>
28437 The mbstowcs_s function converts a sequence of multibyte characters that begins in
28438 the initial shift state from the array pointed to by src into a sequence of corresponding
28439 wide characters. If dst is not a null pointer, the converted characters are stored into the
28440 array pointed to by dst. Conversion continues up to and including a terminating null
28441 character, which is also stored. Conversion stops earlier in two cases: when a sequence of
28442 <!--page 626 indent 4-->
28443 bytes is encountered that does not form a valid multibyte character, or (if dst is not a
28444 null pointer) when len wide characters have been stored into the array pointed to by
28445 dst.<sup><a href="#note400"><b>400)</b></a></sup> If dst is not a null pointer and no null wide character was stored into the array
28446 pointed to by dst, then dst[len] is set to the null wide character. Each conversion
28447 takes place as if by a call to the mbrtowc function.
28449 Regardless of whether dst is or is not a null pointer, if the input conversion encounters a
28450 sequence of bytes that do not form a valid multibyte character, an encoding error occurs:
28451 the mbstowcs_s function stores the value (size_t)(-1) into *retval.
28452 Otherwise, the mbstowcs_s function stores into *retval the number of multibyte
28453 characters successfully converted, not including the terminating null character (if any).
28455 All elements following the terminating null wide character (if any) written by
28456 mbstowcs_s in the array of dstmax wide characters pointed to by dst take
28457 unspecified values when mbstowcs_s returns.<sup><a href="#note401"><b>401)</b></a></sup>
28459 If copying takes place between objects that overlap, the objects take on unspecified
28463 The mbstowcs_s function returns zero if no runtime-constraint violation and no
28464 encoding error occurred. Otherwise, a nonzero value is returned.
28467 <p><a name="note400">400)</a> Thus, the value of len is ignored if dst is a null pointer.
28469 <p><a name="note401">401)</a> This allows an implementation to attempt converting the multibyte string before discovering a
28470 terminating null character did not occur where required.
28473 <a name="K.3.6.5.2" href="#K.3.6.5.2"><h5>K.3.6.5.2 The wcstombs_s function</h5></a>
28477 #include <stdlib.h>
28478 errno_t wcstombs_s(size_t * restrict retval,
28479 char * restrict dst, rsize_t dstmax,
28480 const wchar_t * restrict src, rsize_t len);</pre>
28481 Runtime-constraints
28483 Neither retval nor src shall be a null pointer. If dst is not a null pointer, then
28484 neither len nor dstmax shall be greater than RSIZE_MAX. If dst is a null pointer,
28485 then dstmax shall equal zero. If dst is not a null pointer, then dstmax shall not equal
28486 zero. If dst is not a null pointer and len is not less than dstmax, then the conversion
28487 shall have been stopped (see below) because a terminating null wide character was
28488 reached or because an encoding error occurred.
28493 <!--page 627 indent 4-->
28495 If there is a runtime-constraint violation, then wcstombs_s does the following. If
28496 retval is not a null pointer, then wcstombs_s sets *retval to (size_t)(-1). If
28497 dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
28498 then wcstombs_s sets dst[0] to the null character.
28499 <h6>Description</h6>
28501 The wcstombs_s function converts a sequence of wide characters from the array
28502 pointed to by src into a sequence of corresponding multibyte characters that begins in
28503 the initial shift state. If dst is not a null pointer, the converted characters are then stored
28504 into the array pointed to by dst. Conversion continues up to and including a terminating
28505 null wide character, which is also stored. Conversion stops earlier in two cases:
28507 <li> when a wide character is reached that does not correspond to a valid multibyte
28509 <li> (if dst is not a null pointer) when the next multibyte character would exceed the
28510 limit of n total bytes to be stored into the array pointed to by dst. If the wide
28511 character being converted is the null wide character, then n is the lesser of len or
28512 dstmax. Otherwise, n is the lesser of len or dstmax-1.
28514 If the conversion stops without converting a null wide character and dst is not a null
28515 pointer, then a null character is stored into the array pointed to by dst immediately
28516 following any multibyte characters already stored. Each conversion takes place as if by a
28517 call to the wcrtomb function.<sup><a href="#note402"><b>402)</b></a></sup>
28519 Regardless of whether dst is or is not a null pointer, if the input conversion encounters a
28520 wide character that does not correspond to a valid multibyte character, an encoding error
28521 occurs: the wcstombs_s function stores the value (size_t)(-1) into *retval.
28522 Otherwise, the wcstombs_s function stores into *retval the number of bytes in the
28523 resulting multibyte character sequence, not including the terminating null character (if
28526 All elements following the terminating null character (if any) written by wcstombs_s
28527 in the array of dstmax elements pointed to by dst take unspecified values when
28528 wcstombs_s returns.<sup><a href="#note403"><b>403)</b></a></sup>
28530 If copying takes place between objects that overlap, the objects take on unspecified
28534 <!--page 628 indent 4-->
28537 The wcstombs_s function returns zero if no runtime-constraint violation and no
28538 encoding error occurred. Otherwise, a nonzero value is returned.
28541 <p><a name="note402">402)</a> If conversion stops because a terminating null wide character has been reached, the bytes stored
28542 include those necessary to reach the initial shift state immediately before the null byte. However, if
28543 the conversion stops before a terminating null wide character has been reached, the result will be null
28544 terminated, but might not end in the initial shift state.
28546 <p><a name="note403">403)</a> When len is not less than dstmax, the implementation might fill the array before discovering a
28547 runtime-constraint violation.
28550 <a name="K.3.7" href="#K.3.7"><h4>K.3.7 String handling <string.h></h4></a>
28552 The header <string.h> defines two types.
28557 which is type int; and
28560 which is the type size_t.
28562 <a name="K.3.7.1" href="#K.3.7.1"><h5>K.3.7.1 Copying functions</h5></a>
28564 <a name="K.3.7.1.1" href="#K.3.7.1.1"><h5>K.3.7.1.1 The memcpy_s function</h5></a>
28568 #define __STDC_WANT_LIB_EXT1__ 1
28569 #include <string.h>
28570 errno_t memcpy_s(void * restrict s1, rsize_t s1max,
28571 const void * restrict s2, rsize_t n);</pre>
28572 Runtime-constraints
28574 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
28575 RSIZE_MAX. n shall not be greater than s1max. Copying shall not take place between
28576 objects that overlap.
28578 If there is a runtime-constraint violation, the memcpy_s function stores zeros in the first
28579 s1max characters of the object pointed to by s1 if s1 is not a null pointer and s1max is
28580 not greater than RSIZE_MAX.
28581 <h6>Description</h6>
28583 The memcpy_s function copies n characters from the object pointed to by s2 into the
28584 object pointed to by s1.
28587 The memcpy_s function returns zero if there was no runtime-constraint violation.
28588 Otherwise, a nonzero value is returned.
28589 <!--page 629 indent 4-->
28591 <a name="K.3.7.1.2" href="#K.3.7.1.2"><h5>K.3.7.1.2 The memmove_s function</h5></a>
28595 #define __STDC_WANT_LIB_EXT1__ 1
28596 #include <string.h>
28597 errno_t memmove_s(void *s1, rsize_t s1max,
28598 const void *s2, rsize_t n);</pre>
28599 Runtime-constraints
28601 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
28602 RSIZE_MAX. n shall not be greater than s1max.
28604 If there is a runtime-constraint violation, the memmove_s function stores zeros in the
28605 first s1max characters of the object pointed to by s1 if s1 is not a null pointer and
28606 s1max is not greater than RSIZE_MAX.
28607 <h6>Description</h6>
28609 The memmove_s function copies n characters from the object pointed to by s2 into the
28610 object pointed to by s1. This copying takes place as if the n characters from the object
28611 pointed to by s2 are first copied into a temporary array of n characters that does not
28612 overlap the objects pointed to by s1 or s2, and then the n characters from the temporary
28613 array are copied into the object pointed to by s1.
28616 The memmove_s function returns zero if there was no runtime-constraint violation.
28617 Otherwise, a nonzero value is returned.
28619 <a name="K.3.7.1.3" href="#K.3.7.1.3"><h5>K.3.7.1.3 The strcpy_s function</h5></a>
28623 #define __STDC_WANT_LIB_EXT1__ 1
28624 #include <string.h>
28625 errno_t strcpy_s(char * restrict s1,
28627 const char * restrict s2);</pre>
28628 Runtime-constraints
28630 Neither s1 nor s2 shall be a null pointer. s1max shall not be greater than RSIZE_MAX.
28631 s1max shall not equal zero. s1max shall be greater than strnlen_s(s2, s1max).
28632 Copying shall not take place between objects that overlap.
28634 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
28635 greater than zero and not greater than RSIZE_MAX, then strcpy_s sets s1[0] to the
28637 <!--page 630 indent 4-->
28638 <h6>Description</h6>
28640 The strcpy_s function copies the string pointed to by s2 (including the terminating
28641 null character) into the array pointed to by s1.
28643 All elements following the terminating null character (if any) written by strcpy_s in
28644 the array of s1max characters pointed to by s1 take unspecified values when
28645 strcpy_s returns.<sup><a href="#note404"><b>404)</b></a></sup>
28648 The strcpy_s function returns zero<sup><a href="#note405"><b>405)</b></a></sup> if there was no runtime-constraint violation.
28649 Otherwise, a nonzero value is returned.
28652 <p><a name="note404">404)</a> This allows an implementation to copy characters from s2 to s1 while simultaneously checking if
28653 any of those characters are null. Such an approach might write a character to every element of s1
28654 before discovering that the first element should be set to the null character.
28656 <p><a name="note405">405)</a> A zero return value implies that all of the requested characters from the string pointed to by s2 fit
28657 within the array pointed to by s1 and that the result in s1 is null terminated.
28660 <a name="K.3.7.1.4" href="#K.3.7.1.4"><h5>K.3.7.1.4 The strncpy_s function</h5></a>
28664 #define __STDC_WANT_LIB_EXT1__ 1
28665 #include <string.h>
28666 errno_t strncpy_s(char * restrict s1,
28668 const char * restrict s2,
28670 Runtime-constraints
28672 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
28673 RSIZE_MAX. s1max shall not equal zero. If n is not less than s1max, then s1max
28674 shall be greater than strnlen_s(s2, s1max). Copying shall not take place between
28675 objects that overlap.
28677 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
28678 greater than zero and not greater than RSIZE_MAX, then strncpy_s sets s1[0] to the
28680 <h6>Description</h6>
28682 The strncpy_s function copies not more than n successive characters (characters that
28683 follow a null character are not copied) from the array pointed to by s2 to the array
28684 pointed to by s1. If no null character was copied from s2, then s1[n] is set to a null
28688 <!--page 631 indent 4-->
28690 All elements following the terminating null character (if any) written by strncpy_s in
28691 the array of s1max characters pointed to by s1 take unspecified values when
28692 strncpy_s returns.<sup><a href="#note406"><b>406)</b></a></sup>
28695 The strncpy_s function returns zero<sup><a href="#note407"><b>407)</b></a></sup> if there was no runtime-constraint violation.
28696 Otherwise, a nonzero value is returned.
28698 EXAMPLE 1 The strncpy_s function can be used to copy a string without the danger that the result
28699 will not be null terminated or that characters will be written past the end of the destination array.
28701 #define __STDC_WANT_LIB_EXT1__ 1
28702 #include <string.h>
28704 char src1[100] = "hello";
28705 char src2[7] = {'g', 'o', 'o', 'd', 'b', 'y', 'e'};
28706 char dst1[6], dst2[5], dst3[5];
28708 r1 = strncpy_s(dst1, 6, src1, 100);
28709 r2 = strncpy_s(dst2, 5, src2, 7);
28710 r3 = strncpy_s(dst3, 5, src2, 4);</pre>
28711 The first call will assign to r1 the value zero and to dst1 the sequence hello\0.
28712 The second call will assign to r2 a nonzero value and to dst2 the sequence \0.
28713 The third call will assign to r3 the value zero and to dst3 the sequence good\0.
28717 <p><a name="note406">406)</a> This allows an implementation to copy characters from s2 to s1 while simultaneously checking if
28718 any of those characters are null. Such an approach might write a character to every element of s1
28719 before discovering that the first element should be set to the null character.
28721 <p><a name="note407">407)</a> A zero return value implies that all of the requested characters from the string pointed to by s2 fit
28722 within the array pointed to by s1 and that the result in s1 is null terminated.
28725 <a name="K.3.7.2" href="#K.3.7.2"><h5>K.3.7.2 Concatenation functions</h5></a>
28727 <a name="K.3.7.2.1" href="#K.3.7.2.1"><h5>K.3.7.2.1 The strcat_s function</h5></a>
28731 #define __STDC_WANT_LIB_EXT1__ 1
28732 #include <string.h>
28733 errno_t strcat_s(char * restrict s1,
28735 const char * restrict s2);</pre>
28736 Runtime-constraints
28738 Let m denote the value s1max - strnlen_s(s1, s1max) upon entry to
28744 <!--page 632 indent 4-->
28746 Neither s1 nor s2 shall be a null pointer. s1max shall not be greater than RSIZE_MAX.
28747 s1max shall not equal zero. m shall not equal zero.<sup><a href="#note408"><b>408)</b></a></sup> m shall be greater than
28748 strnlen_s(s2, m). Copying shall not take place between objects that overlap.
28750 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
28751 greater than zero and not greater than RSIZE_MAX, then strcat_s sets s1[0] to the
28753 <h6>Description</h6>
28755 The strcat_s function appends a copy of the string pointed to by s2 (including the
28756 terminating null character) to the end of the string pointed to by s1. The initial character
28757 from s2 overwrites the null character at the end of s1.
28759 All elements following the terminating null character (if any) written by strcat_s in
28760 the array of s1max characters pointed to by s1 take unspecified values when
28761 strcat_s returns.<sup><a href="#note409"><b>409)</b></a></sup>
28764 The strcat_s function returns zero<sup><a href="#note410"><b>410)</b></a></sup> if there was no runtime-constraint violation.
28765 Otherwise, a nonzero value is returned.
28768 <p><a name="note408">408)</a> Zero means that s1 was not null terminated upon entry to strcat_s.
28770 <p><a name="note409">409)</a> This allows an implementation to append characters from s2 to s1 while simultaneously checking if
28771 any of those characters are null. Such an approach might write a character to every element of s1
28772 before discovering that the first element should be set to the null character.
28774 <p><a name="note410">410)</a> A zero return value implies that all of the requested characters from the string pointed to by s2 were
28775 appended to the string pointed to by s1 and that the result in s1 is null terminated.
28778 <a name="K.3.7.2.2" href="#K.3.7.2.2"><h5>K.3.7.2.2 The strncat_s function</h5></a>
28782 #define __STDC_WANT_LIB_EXT1__ 1
28783 #include <string.h>
28784 errno_t strncat_s(char * restrict s1,
28786 const char * restrict s2,
28788 Runtime-constraints
28790 Let m denote the value s1max - strnlen_s(s1, s1max) upon entry to
28793 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
28794 RSIZE_MAX. s1max shall not equal zero. m shall not equal zero.<sup><a href="#note411"><b>411)</b></a></sup> If n is not less
28797 <!--page 633 indent 4-->
28798 than m, then m shall be greater than strnlen_s(s2, m). Copying shall not take
28799 place between objects that overlap.
28801 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
28802 greater than zero and not greater than RSIZE_MAX, then strncat_s sets s1[0] to the
28804 <h6>Description</h6>
28806 The strncat_s function appends not more than n successive characters (characters
28807 that follow a null character are not copied) from the array pointed to by s2 to the end of
28808 the string pointed to by s1. The initial character from s2 overwrites the null character at
28809 the end of s1. If no null character was copied from s2, then s1[s1max-m+n] is set to
28812 All elements following the terminating null character (if any) written by strncat_s in
28813 the array of s1max characters pointed to by s1 take unspecified values when
28814 strncat_s returns.<sup><a href="#note412"><b>412)</b></a></sup>
28817 The strncat_s function returns zero<sup><a href="#note413"><b>413)</b></a></sup> if there was no runtime-constraint violation.
28818 Otherwise, a nonzero value is returned.
28820 EXAMPLE 1 The strncat_s function can be used to copy a string without the danger that the result
28821 will not be null terminated or that characters will be written past the end of the destination array.
28823 #define __STDC_WANT_LIB_EXT1__ 1
28824 #include <string.h>
28826 char s1[100] = "good";
28827 char s2[6] = "hello";
28828 char s3[6] = "hello";
28829 char s4[7] = "abc";
28830 char s5[1000] = "bye";
28831 int r1, r2, r3, r4;
28832 r1 = strncat_s(s1, 100, s5, 1000);
28833 r2 = strncat_s(s2, 6, "", 1);
28834 r3 = strncat_s(s3, 6, "X", 2);
28835 r4 = strncat_s(s4, 7, "defghijklmn", 3);</pre>
28836 After the first call r1 will have the value zero and s1 will contain the sequence goodbye\0.
28840 <!--page 634 indent 4-->
28841 After the second call r2 will have the value zero and s2 will contain the sequence hello\0.
28842 After the third call r3 will have a nonzero value and s3 will contain the sequence \0.
28843 After the fourth call r4 will have the value zero and s4 will contain the sequence abcdef\0.
28847 <p><a name="note411">411)</a> Zero means that s1 was not null terminated upon entry to strncat_s.
28849 <p><a name="note412">412)</a> This allows an implementation to append characters from s2 to s1 while simultaneously checking if
28850 any of those characters are null. Such an approach might write a character to every element of s1
28851 before discovering that the first element should be set to the null character.
28853 <p><a name="note413">413)</a> A zero return value implies that all of the requested characters from the string pointed to by s2 were
28854 appended to the string pointed to by s1 and that the result in s1 is null terminated.
28857 <a name="K.3.7.3" href="#K.3.7.3"><h5>K.3.7.3 Search functions</h5></a>
28859 <a name="K.3.7.3.1" href="#K.3.7.3.1"><h5>K.3.7.3.1 The strtok_s function</h5></a>
28863 #define __STDC_WANT_LIB_EXT1__ 1
28864 #include <string.h>
28865 char *strtok_s(char * restrict s1,
28866 rsize_t * restrict s1max,
28867 const char * restrict s2,
28868 char ** restrict ptr);</pre>
28869 Runtime-constraints
28871 None of s1max, s2, or ptr shall be a null pointer. If s1 is a null pointer, then *ptr
28872 shall not be a null pointer. The value of *s1max shall not be greater than RSIZE_MAX.
28873 The end of the token found shall occur within the first *s1max characters of s1 for the
28874 first call, and shall occur within the first *s1max characters of where searching resumes
28875 on subsequent calls.
28877 If there is a runtime-constraint violation, the strtok_s function does not indirect
28878 through the s1 or s2 pointers, and does not store a value in the object pointed to by ptr.
28879 <h6>Description</h6>
28881 A sequence of calls to the strtok_s function breaks the string pointed to by s1 into a
28882 sequence of tokens, each of which is delimited by a character from the string pointed to
28883 by s2. The fourth argument points to a caller-provided char pointer into which the
28884 strtok_s function stores information necessary for it to continue scanning the same
28887 The first call in a sequence has a non-null first argument and s1max points to an object
28888 whose value is the number of elements in the character array pointed to by the first
28889 argument. The first call stores an initial value in the object pointed to by ptr and
28890 updates the value pointed to by s1max to reflect the number of elements that remain in
28891 relation to ptr. Subsequent calls in the sequence have a null first argument and the
28892 objects pointed to by s1max and ptr are required to have the values stored by the
28893 previous call in the sequence, which are then updated. The separator string pointed to by
28894 s2 may be different from call to call.
28896 The first call in the sequence searches the string pointed to by s1 for the first character
28897 that is not contained in the current separator string pointed to by s2. If no such character
28898 is found, then there are no tokens in the string pointed to by s1 and the strtok_s
28899 function returns a null pointer. If such a character is found, it is the start of the first token.
28900 <!--page 635 indent 5-->
28902 The strtok_s function then searches from there for the first character in s1 that is
28903 contained in the current separator string. If no such character is found, the current token
28904 extends to the end of the string pointed to by s1, and subsequent searches in the same
28905 string for a token return a null pointer. If such a character is found, it is overwritten by a
28906 null character, which terminates the current token.
28908 In all cases, the strtok_s function stores sufficient information in the pointer pointed
28909 to by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
28910 value for ptr, shall start searching just past the element overwritten by a null character
28914 The strtok_s function returns a pointer to the first character of a token, or a null
28915 pointer if there is no token or there is a runtime-constraint violation.
28919 #define __STDC_WANT_LIB_EXT1__ 1
28920 #include <string.h>
28921 static char str1[] = "?a???b,,,#c";
28922 static char str2[] = "\t \t";
28923 char *t, *ptr1, *ptr2;
28924 rsize_t max1 = sizeof(str1);
28925 rsize_t max2 = sizeof(str2);
28926 t = strtok_s(str1, &max1, "?", &ptr1); // t points to the token "a"
28927 t = strtok_s(NULL, &max1, ",", &ptr1); // t points to the token "??b"
28928 t = strtok_s(str2, &max2, " \t", &ptr2); // t is a null pointer
28929 t = strtok_s(NULL, &max1, "#,", &ptr1); // t points to the token "c"
28930 t = strtok_s(NULL, &max1, "?", &ptr1); // t is a null pointer</pre>
28933 <a name="K.3.7.4" href="#K.3.7.4"><h5>K.3.7.4 Miscellaneous functions</h5></a>
28935 <a name="K.3.7.4.1" href="#K.3.7.4.1"><h5>K.3.7.4.1 The memset_s function</h5></a>
28939 #define __STDC_WANT_LIB_EXT1__ 1
28940 #include <string.h>
28941 errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)</pre>
28942 Runtime-constraints
28944 s shall not be a null pointer. Neither smax nor n shall be greater than RSIZE_MAX. n
28945 shall not be greater than smax.
28947 If there is a runtime-constraint violation, then if s is not a null pointer and smax is not
28948 greater than RSIZE_MAX, the memset_s function stores the value of c (converted to an
28949 unsigned char) into each of the first smax characters of the object pointed to by s.
28950 <!--page 636 indent 4-->
28951 <h6>Description</h6>
28953 The memset_s function copies the value of c (converted to an unsigned char) into
28954 each of the first n characters of the object pointed to by s. Unlike memset, any call to
28955 the memset_s function shall be evaluated strictly according to the rules of the abstract
28956 machine as described in (<a href="#5.1.2.3">5.1.2.3</a>). That is, any call to the memset_s function shall
28957 assume that the memory indicated by s and n may be accessible in the future and thus
28958 must contain the values indicated by c.
28961 The memset_s function returns zero if there was no runtime-constraint violation.
28962 Otherwise, a nonzero value is returned.
28964 <a name="K.3.7.4.2" href="#K.3.7.4.2"><h5>K.3.7.4.2 The strerror_s function</h5></a>
28968 #define __STDC_WANT_LIB_EXT1__ 1
28969 #include <string.h>
28970 errno_t strerror_s(char *s, rsize_t maxsize,
28971 errno_t errnum);</pre>
28972 Runtime-constraints
28974 s shall not be a null pointer. maxsize shall not be greater than RSIZE_MAX.
28975 maxsize shall not equal zero.
28977 If there is a runtime-constraint violation, then the array (if any) pointed to by s is not
28979 <h6>Description</h6>
28981 The strerror_s function maps the number in errnum to a locale-specific message
28982 string. Typically, the values for errnum come from errno, but strerror_s shall
28983 map any value of type int to a message.
28985 If the length of the desired string is less than maxsize, then the string is copied to the
28986 array pointed to by s.
28988 Otherwise, if maxsize is greater than zero, then maxsize-1 characters are copied
28989 from the string to the array pointed to by s and then s[maxsize-1] is set to the null
28990 character. Then, if maxsize is greater than 3, then s[maxsize-2],
28991 s[maxsize-3], and s[maxsize-4] are set to the character period (.).
28994 The strerror_s function returns zero if the length of the desired string was less than
28995 maxsize and there was no runtime-constraint violation. Otherwise, the strerror_s
28996 function returns a nonzero value.
28997 <!--page 637 indent 4-->
28999 <a name="K.3.7.4.3" href="#K.3.7.4.3"><h5>K.3.7.4.3 The strerrorlen_s function</h5></a>
29003 #define __STDC_WANT_LIB_EXT1__ 1
29004 #include <string.h>
29005 size_t strerrorlen_s(errno_t errnum);</pre>
29006 <h6>Description</h6>
29008 The strerrorlen_s function calculates the length of the (untruncated) locale-specific
29009 message string that the strerror_s function maps to errnum.
29012 The strerrorlen_s function returns the number of characters (not including the null
29013 character) in the full message string.
29015 <a name="K.3.7.4.4" href="#K.3.7.4.4"><h5>K.3.7.4.4 The strnlen_s function</h5></a>
29019 #define __STDC_WANT_LIB_EXT1__ 1
29020 #include <string.h>
29021 size_t strnlen_s(const char *s, size_t maxsize);</pre>
29022 <h6>Description</h6>
29024 The strnlen_s function computes the length of the string pointed to by s.
29027 If s is a null pointer,<sup><a href="#note414"><b>414)</b></a></sup> then the strnlen_s function returns zero.
29029 Otherwise, the strnlen_s function returns the number of characters that precede the
29030 terminating null character. If there is no null character in the first maxsize characters of
29031 s then strnlen_s returns maxsize. At most the first maxsize characters of s shall
29032 be accessed by strnlen_s.
29037 <!--page 638 indent 4-->
29040 <p><a name="note414">414)</a> Note that the strnlen_s function has no runtime-constraints. This lack of runtime-constraints
29041 along with the values returned for a null pointer or an unterminated string argument make
29042 strnlen_s useful in algorithms that gracefully handle such exceptional data.
29045 <a name="K.3.8" href="#K.3.8"><h4>K.3.8 Date and time <time.h></h4></a>
29047 The header <time.h> defines two types.
29052 which is type int; and
29055 which is the type size_t.
29057 <a name="K.3.8.1" href="#K.3.8.1"><h5>K.3.8.1 Components of time</h5></a>
29059 A broken-down time is normalized if the values of the members of the tm structure are in
29060 their normal rages.<sup><a href="#note415"><b>415)</b></a></sup>
29063 <p><a name="note415">415)</a> The normal ranges are defined in <a href="#7.26.1">7.26.1</a>.
29066 <a name="K.3.8.2" href="#K.3.8.2"><h5>K.3.8.2 Time conversion functions</h5></a>
29068 Like the strftime function, the asctime_s and ctime_s functions do not return a
29069 pointer to a static object, and other library functions are permitted to call them.
29071 <a name="K.3.8.2.1" href="#K.3.8.2.1"><h5>K.3.8.2.1 The asctime_s function</h5></a>
29075 #define __STDC_WANT_LIB_EXT1__ 1
29076 #include <time.h>
29077 errno_t asctime_s(char *s, rsize_t maxsize,
29078 const struct tm *timeptr);</pre>
29079 Runtime-constraints
29081 Neither s nor timeptr shall be a null pointer. maxsize shall not be less than 26 and
29082 shall not be greater than RSIZE_MAX. The broken-down time pointed to by timeptr
29083 shall be normalized. The calendar year represented by the broken-down time pointed to
29084 by timeptr shall not be less than calendar year 0 and shall not be greater than calendar
29087 If there is a runtime-constraint violation, there is no attempt to convert the time, and
29088 s[0] is set to a null character if s is not a null pointer and maxsize is not zero and is
29089 not greater than RSIZE_MAX.
29090 <h6>Description</h6>
29092 The asctime_s function converts the normalized broken-down time in the structure
29093 pointed to by timeptr into a 26 character (including the null character) string in the
29096 <!--page 639 indent 4-->
29099 Sun Sep 16 01:03:52 1973\n\0</pre>
29100 The fields making up this string are (in order):
29102 <li> The name of the day of the week represented by timeptr->tm_wday using the
29103 following three character weekday names: Sun, Mon, Tue, Wed, Thu, Fri, and Sat.
29104 <li> The character space.
29105 <li> The name of the month represented by timeptr->tm_mon using the following
29106 three character month names: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct,
29108 <li> The character space.
29109 <li> The value of timeptr->tm_mday as if printed using the fprintf format
29111 <li> The character space.
29112 <li> The value of timeptr->tm_hour as if printed using the fprintf format
29114 <li> The character colon.
29115 <li> The value of timeptr->tm_min as if printed using the fprintf format
29117 <li> The character colon.
29118 <li> The value of timeptr->tm_sec as if printed using the fprintf format
29120 <li> The character space.
29121 <li> The value of timeptr->tm_year + 1900 as if printed using the fprintf
29123 <li> The character new line.
29124 <li> The null character.
29126 Recommended practice
29127 The strftime function allows more flexible formatting and supports locale-specific
29128 behavior. If you do not require the exact form of the result string produced by the
29129 asctime_s function, consider using the strftime function instead.
29132 The asctime_s function returns zero if the time was successfully converted and stored
29133 into the array pointed to by s. Otherwise, it returns a nonzero value.
29134 <!--page 640 indent 4-->
29136 <a name="K.3.8.2.2" href="#K.3.8.2.2"><h5>K.3.8.2.2 The ctime_s function</h5></a>
29140 #define __STDC_WANT_LIB_EXT1__ 1
29141 #include <time.h>
29142 errno_t ctime_s(char *s, rsize_t maxsize,
29143 const time_t *timer);</pre>
29144 Runtime-constraints
29146 Neither s nor timer shall be a null pointer. maxsize shall not be less than 26 and
29147 shall not be greater than RSIZE_MAX.
29149 If there is a runtime-constraint violation, s[0] is set to a null character if s is not a null
29150 pointer and maxsize is not equal zero and is not greater than RSIZE_MAX.
29151 <h6>Description</h6>
29153 The ctime_s function converts the calendar time pointed to by timer to local time in
29154 the form of a string. It is equivalent to
29156 asctime_s(s, maxsize, localtime_s(timer))</pre>
29157 Recommended practice
29158 The strftime function allows more flexible formatting and supports locale-specific
29159 behavior. If you do not require the exact form of the result string produced by the
29160 ctime_s function, consider using the strftime function instead.
29163 The ctime_s function returns zero if the time was successfully converted and stored
29164 into the array pointed to by s. Otherwise, it returns a nonzero value.
29166 <a name="K.3.8.2.3" href="#K.3.8.2.3"><h5>K.3.8.2.3 The gmtime_s function</h5></a>
29170 #define __STDC_WANT_LIB_EXT1__ 1
29171 #include <time.h>
29172 struct tm *gmtime_s(const time_t * restrict timer,
29173 struct tm * restrict result);</pre>
29174 Runtime-constraints
29176 Neither timer nor result shall be a null pointer.
29178 If there is a runtime-constraint violation, there is no attempt to convert the time.
29179 <h6>Description</h6>
29181 The gmtime_s function converts the calendar time pointed to by timer into a broken-
29182 down time, expressed as UTC. The broken-down time is stored in the structure pointed
29183 <!--page 641 indent 4-->
29187 The gmtime_s function returns result, or a null pointer if the specified time cannot
29188 be converted to UTC or there is a runtime-constraint violation.
29190 <a name="K.3.8.2.4" href="#K.3.8.2.4"><h5>K.3.8.2.4 The localtime_s function</h5></a>
29194 #define __STDC_WANT_LIB_EXT1__ 1
29195 #include <time.h>
29196 struct tm *localtime_s(const time_t * restrict timer,
29197 struct tm * restrict result);</pre>
29198 Runtime-constraints
29200 Neither timer nor result shall be a null pointer.
29202 If there is a runtime-constraint violation, there is no attempt to convert the time.
29203 <h6>Description</h6>
29205 The localtime_s function converts the calendar time pointed to by timer into a
29206 broken-down time, expressed as local time. The broken-down time is stored in the
29207 structure pointed to by result.
29210 The localtime_s function returns result, or a null pointer if the specified time
29211 cannot be converted to local time or there is a runtime-constraint violation.
29213 <a name="K.3.9" href="#K.3.9"><h4>K.3.9 Extended multibyte and wide character utilities <wchar.h></h4></a>
29215 The header <wchar.h> defines two types.
29220 which is type int; and
29223 which is the type size_t.
29225 Unless explicitly stated otherwise, if the execution of a function described in this
29226 subclause causes copying to take place between objects that overlap, the objects take on
29227 unspecified values.
29228 <!--page 642 indent 4-->
29230 <a name="K.3.9.1" href="#K.3.9.1"><h5>K.3.9.1 Formatted wide character input/output functions</h5></a>
29232 <a name="K.3.9.1.1" href="#K.3.9.1.1"><h5>K.3.9.1.1 The fwprintf_s function</h5></a>
29236 #define __STDC_WANT_LIB_EXT1__ 1
29237 #include <wchar.h>
29238 int fwprintf_s(FILE * restrict stream,
29239 const wchar_t * restrict format, ...);</pre>
29240 Runtime-constraints
29242 Neither stream nor format shall be a null pointer. The %n specifier<sup><a href="#note416"><b>416)</b></a></sup> (modified or
29243 not by flags, field width, or precision) shall not appear in the wide string pointed to by
29244 format. Any argument to fwprintf_s corresponding to a %s specifier shall not be a
29247 If there is a runtime-constraint violation, the fwprintf_s function does not attempt to
29248 produce further output, and it is unspecified to what extent fwprintf_s produced
29249 output before discovering the runtime-constraint violation.
29250 <h6>Description</h6>
29252 The fwprintf_s function is equivalent to the fwprintf function except for the
29253 explicit runtime-constraints listed above.
29256 The fwprintf_s function returns the number of wide characters transmitted, or a
29257 negative value if an output error, encoding error, or runtime-constraint violation occurred.
29260 <p><a name="note416">416)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29261 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29262 example, if the entire format string was L"%%n".
29265 <a name="K.3.9.1.2" href="#K.3.9.1.2"><h5>K.3.9.1.2 The fwscanf_s function</h5></a>
29269 #define __STDC_WANT_LIB_EXT1__ 1
29270 #include <stdio.h>
29271 #include <wchar.h>
29272 int fwscanf_s(FILE * restrict stream,
29273 const wchar_t * restrict format, ...);</pre>
29274 Runtime-constraints
29276 Neither stream nor format shall be a null pointer. Any argument indirected though in
29277 order to store converted input shall not be a null pointer.
29280 <!--page 643 indent 4-->
29282 If there is a runtime-constraint violation, the fwscanf_s function does not attempt to
29283 perform further input, and it is unspecified to what extent fwscanf_s performed input
29284 before discovering the runtime-constraint violation.
29285 <h6>Description</h6>
29287 The fwscanf_s function is equivalent to fwscanf except that the c, s, and [
29288 conversion specifiers apply to a pair of arguments (unless assignment suppression is
29289 indicated by a *). The first of these arguments is the same as for fwscanf. That
29290 argument is immediately followed in the argument list by the second argument, which has
29291 type size_t and gives the number of elements in the array pointed to by the first
29292 argument of the pair. If the first argument points to a scalar object, it is considered to be
29293 an array of one element.<sup><a href="#note417"><b>417)</b></a></sup>
29295 A matching failure occurs if the number of elements in a receiving object is insufficient to
29296 hold the converted input (including any trailing null character).
29299 The fwscanf_s function returns the value of the macro EOF if an input failure occurs
29300 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29301 fwscanf_s function returns the number of input items assigned, which can be fewer
29302 than provided for, or even zero, in the event of an early matching failure.
29305 <p><a name="note417">417)</a> If the format is known at translation time, an implementation may issue a diagnostic for any argument
29306 used to store the result from a c, s, or [ conversion specifier if that argument is not followed by an
29307 argument of a type compatible with rsize_t. A limited amount of checking may be done if even if
29308 the format is not known at translation time. For example, an implementation may issue a diagnostic
29309 for each argument after format that has of type pointer to one of char, signed char,
29310 unsigned char, or void that is not followed by an argument of a type compatible with
29311 rsize_t. The diagnostic could warn that unless the pointer is being used with a conversion specifier
29312 using the hh length modifier, a length argument must follow the pointer argument. Another useful
29313 diagnostic could flag any non-pointer argument following format that did not have a type
29314 compatible with rsize_t.
29317 <a name="K.3.9.1.3" href="#K.3.9.1.3"><h5>K.3.9.1.3 The snwprintf_s function</h5></a>
29321 #define __STDC_WANT_LIB_EXT1__ 1
29322 #include <wchar.h>
29323 int snwprintf_s(wchar_t * restrict s,
29325 const wchar_t * restrict format, ...);</pre>
29326 Runtime-constraints
29328 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
29329 than RSIZE_MAX. The %n specifier<sup><a href="#note418"><b>418)</b></a></sup> (modified or not by flags, field width, or
29331 <!--page 644 indent 4-->
29332 precision) shall not appear in the wide string pointed to by format. Any argument to
29333 snwprintf_s corresponding to a %s specifier shall not be a null pointer. No encoding
29336 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
29337 than zero and less than RSIZE_MAX, then the snwprintf_s function sets s[0] to the
29338 null wide character.
29339 <h6>Description</h6>
29341 The snwprintf_s function is equivalent to the swprintf function except for the
29342 explicit runtime-constraints listed above.
29344 The snwprintf_s function, unlike swprintf_s, will truncate the result to fit within
29345 the array pointed to by s.
29348 The snwprintf_s function returns the number of wide characters that would have
29349 been written had n been sufficiently large, not counting the terminating wide null
29350 character, or a negative value if a runtime-constraint violation occurred. Thus, the null-
29351 terminated output has been completely written if and only if the returned value is
29352 nonnegative and less than n.
29355 <p><a name="note418">418)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29356 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29357 example, if the entire format string was L"%%n".
29360 <a name="K.3.9.1.4" href="#K.3.9.1.4"><h5>K.3.9.1.4 The swprintf_s function</h5></a>
29364 #define __STDC_WANT_LIB_EXT1__ 1
29365 #include <wchar.h>
29366 int swprintf_s(wchar_t * restrict s, rsize_t n,
29367 const wchar_t * restrict format, ...);</pre>
29368 Runtime-constraints
29370 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
29371 than RSIZE_MAX. The number of wide characters (including the trailing null) required
29372 for the result to be written to the array pointed to by s shall not be greater than n. The %n
29373 specifier<sup><a href="#note419"><b>419)</b></a></sup> (modified or not by flags, field width, or precision) shall not appear in the
29374 wide string pointed to by format. Any argument to swprintf_s corresponding to a
29375 %s specifier shall not be a null pointer. No encoding error shall occur.
29378 <!--page 645 indent 4-->
29380 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
29381 than zero and less than RSIZE_MAX, then the swprintf_s function sets s[0] to the
29382 null wide character.
29383 <h6>Description</h6>
29385 The swprintf_s function is equivalent to the swprintf function except for the
29386 explicit runtime-constraints listed above.
29388 The swprintf_s function, unlike snwprintf_s, treats a result too big for the array
29389 pointed to by s as a runtime-constraint violation.
29392 If no runtime-constraint violation occurred, the swprintf_s function returns the
29393 number of wide characters written in the array, not counting the terminating null wide
29394 character. If an encoding error occurred or if n or more wide characters are requested to
29395 be written, swprintf_s returns a negative value. If any other runtime-constraint
29396 violation occurred, swprintf_s returns zero.
29399 <p><a name="note419">419)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29400 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29401 example, if the entire format string was L"%%n".
29404 <a name="K.3.9.1.5" href="#K.3.9.1.5"><h5>K.3.9.1.5 The swscanf_s function</h5></a>
29408 #define __STDC_WANT_LIB_EXT1__ 1
29409 #include <wchar.h>
29410 int swscanf_s(const wchar_t * restrict s,
29411 const wchar_t * restrict format, ...);</pre>
29412 Runtime-constraints
29414 Neither s nor format shall be a null pointer. Any argument indirected though in order
29415 to store converted input shall not be a null pointer.
29417 If there is a runtime-constraint violation, the swscanf_s function does not attempt to
29418 perform further input, and it is unspecified to what extent swscanf_s performed input
29419 before discovering the runtime-constraint violation.
29420 <h6>Description</h6>
29422 The swscanf_s function is equivalent to fwscanf_s, except that the argument s
29423 specifies a wide string from which the input is to be obtained, rather than from a stream.
29424 Reaching the end of the wide string is equivalent to encountering end-of-file for the
29425 fwscanf_s function.
29428 The swscanf_s function returns the value of the macro EOF if an input failure occurs
29429 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29430 swscanf_s function returns the number of input items assigned, which can be fewer
29431 than provided for, or even zero, in the event of an early matching failure.
29432 <!--page 646 indent 4-->
29434 <a name="K.3.9.1.6" href="#K.3.9.1.6"><h5>K.3.9.1.6 The vfwprintf_s function</h5></a>
29438 #define __STDC_WANT_LIB_EXT1__ 1
29439 #include <stdarg.h>
29440 #include <stdio.h>
29441 #include <wchar.h>
29442 int vfwprintf_s(FILE * restrict stream,
29443 const wchar_t * restrict format,
29444 va_list arg);</pre>
29445 Runtime-constraints
29447 Neither stream nor format shall be a null pointer. The %n specifier<sup><a href="#note420"><b>420)</b></a></sup> (modified or
29448 not by flags, field width, or precision) shall not appear in the wide string pointed to by
29449 format. Any argument to vfwprintf_s corresponding to a %s specifier shall not be
29452 If there is a runtime-constraint violation, the vfwprintf_s function does not attempt
29453 to produce further output, and it is unspecified to what extent vfwprintf_s produced
29454 output before discovering the runtime-constraint violation.
29455 <h6>Description</h6>
29457 The vfwprintf_s function is equivalent to the vfwprintf function except for the
29458 explicit runtime-constraints listed above.
29461 The vfwprintf_s function returns the number of wide characters transmitted, or a
29462 negative value if an output error, encoding error, or runtime-constraint violation occurred.
29465 <p><a name="note420">420)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29466 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29467 example, if the entire format string was L"%%n".
29470 <a name="K.3.9.1.7" href="#K.3.9.1.7"><h5>K.3.9.1.7 The vfwscanf_s function</h5></a>
29474 #define __STDC_WANT_LIB_EXT1__ 1
29475 #include <stdarg.h>
29476 #include <stdio.h>
29477 #include <wchar.h>
29478 int vfwscanf_s(FILE * restrict stream,
29479 const wchar_t * restrict format, va_list arg);</pre>
29483 <!--page 647 indent 4-->
29484 Runtime-constraints
29486 Neither stream nor format shall be a null pointer. Any argument indirected though in
29487 order to store converted input shall not be a null pointer.
29489 If there is a runtime-constraint violation, the vfwscanf_s function does not attempt to
29490 perform further input, and it is unspecified to what extent vfwscanf_s performed input
29491 before discovering the runtime-constraint violation.
29492 <h6>Description</h6>
29494 The vfwscanf_s function is equivalent to fwscanf_s, with the variable argument
29495 list replaced by arg, which shall have been initialized by the va_start macro (and
29496 possibly subsequent va_arg calls). The vfwscanf_s function does not invoke the
29497 va_end macro.<sup><a href="#note421"><b>421)</b></a></sup>
29500 The vfwscanf_s function returns the value of the macro EOF if an input failure occurs
29501 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29502 vfwscanf_s function returns the number of input items assigned, which can be fewer
29503 than provided for, or even zero, in the event of an early matching failure.
29506 <p><a name="note421">421)</a> As the functions vfwscanf_s, vwscanf_s, and vswscanf_s invoke the va_arg macro, the
29507 value of arg after the return is indeterminate.
29510 <a name="K.3.9.1.8" href="#K.3.9.1.8"><h5>K.3.9.1.8 The vsnwprintf_s function</h5></a>
29514 #define __STDC_WANT_LIB_EXT1__ 1
29515 #include <stdarg.h>
29516 #include <wchar.h>
29517 int vsnwprintf_s(wchar_t * restrict s,
29519 const wchar_t * restrict format,
29520 va_list arg);</pre>
29521 Runtime-constraints
29523 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
29524 than RSIZE_MAX. The %n specifier<sup><a href="#note422"><b>422)</b></a></sup> (modified or not by flags, field width, or
29525 precision) shall not appear in the wide string pointed to by format. Any argument to
29526 vsnwprintf_s corresponding to a %s specifier shall not be a null pointer. No
29527 encoding error shall occur.
29529 <!--page 648 indent 4-->
29531 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
29532 than zero and less than RSIZE_MAX, then the vsnwprintf_s function sets s[0] to
29533 the null wide character.
29534 <h6>Description</h6>
29536 The vsnwprintf_s function is equivalent to the vswprintf function except for the
29537 explicit runtime-constraints listed above.
29539 The vsnwprintf_s function, unlike vswprintf_s, will truncate the result to fit
29540 within the array pointed to by s.
29543 The vsnwprintf_s function returns the number of wide characters that would have
29544 been written had n been sufficiently large, not counting the terminating null character, or
29545 a negative value if a runtime-constraint violation occurred. Thus, the null-terminated
29546 output has been completely written if and only if the returned value is nonnegative and
29550 <p><a name="note422">422)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29551 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29552 example, if the entire format string was L"%%n".
29555 <a name="K.3.9.1.9" href="#K.3.9.1.9"><h5>K.3.9.1.9 The vswprintf_s function</h5></a>
29559 #define __STDC_WANT_LIB_EXT1__ 1
29560 #include <stdarg.h>
29561 #include <wchar.h>
29562 int vswprintf_s(wchar_t * restrict s,
29564 const wchar_t * restrict format,
29565 va_list arg);</pre>
29566 Runtime-constraints
29568 Neither s nor format shall be a null pointer. n shall neither equal zero nor be greater
29569 than RSIZE_MAX. The number of wide characters (including the trailing null) required
29570 for the result to be written to the array pointed to by s shall not be greater than n. The %n
29571 specifier<sup><a href="#note423"><b>423)</b></a></sup> (modified or not by flags, field width, or precision) shall not appear in the
29572 wide string pointed to by format. Any argument to vswprintf_s corresponding to a
29573 %s specifier shall not be a null pointer. No encoding error shall occur.
29575 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
29576 than zero and less than RSIZE_MAX, then the vswprintf_s function sets s[0] to the
29577 null wide character.
29579 <!--page 649 indent 4-->
29580 <h6>Description</h6>
29582 The vswprintf_s function is equivalent to the vswprintf function except for the
29583 explicit runtime-constraints listed above.
29585 The vswprintf_s function, unlike vsnwprintf_s, treats a result too big for the
29586 array pointed to by s as a runtime-constraint violation.
29589 If no runtime-constraint violation occurred, the vswprintf_s function returns the
29590 number of wide characters written in the array, not counting the terminating null wide
29591 character. If an encoding error occurred or if n or more wide characters are requested to
29592 be written, vswprintf_s returns a negative value. If any other runtime-constraint
29593 violation occurred, vswprintf_s returns zero.
29596 <p><a name="note423">423)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29597 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29598 example, if the entire format string was L"%%n".
29601 <a name="K.3.9.1.10" href="#K.3.9.1.10"><h5>K.3.9.1.10 The vswscanf_s function</h5></a>
29605 #define __STDC_WANT_LIB_EXT1__ 1
29606 #include <stdarg.h>
29607 #include <wchar.h>
29608 int vswscanf_s(const wchar_t * restrict s,
29609 const wchar_t * restrict format,
29610 va_list arg);</pre>
29611 Runtime-constraints
29613 Neither s nor format shall be a null pointer. Any argument indirected though in order
29614 to store converted input shall not be a null pointer.
29616 If there is a runtime-constraint violation, the vswscanf_s function does not attempt to
29617 perform further input, and it is unspecified to what extent vswscanf_s performed input
29618 before discovering the runtime-constraint violation.
29619 <h6>Description</h6>
29621 The vswscanf_s function is equivalent to swscanf_s, with the variable argument
29622 list replaced by arg, which shall have been initialized by the va_start macro (and
29623 possibly subsequent va_arg calls). The vswscanf_s function does not invoke the
29624 va_end macro.<sup><a href="#note424"><b>424)</b></a></sup>
29629 <!--page 650 indent 4-->
29632 The vswscanf_s function returns the value of the macro EOF if an input failure occurs
29633 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29634 vswscanf_s function returns the number of input items assigned, which can be fewer
29635 than provided for, or even zero, in the event of an early matching failure.
29638 <p><a name="note424">424)</a> As the functions vfwscanf_s, vwscanf_s, and vswscanf_s invoke the va_arg macro, the
29639 value of arg after the return is indeterminate.
29642 <a name="K.3.9.1.11" href="#K.3.9.1.11"><h5>K.3.9.1.11 The vwprintf_s function</h5></a>
29646 #define __STDC_WANT_LIB_EXT1__ 1
29647 #include <stdarg.h>
29648 #include <wchar.h>
29649 int vwprintf_s(const wchar_t * restrict format,
29650 va_list arg);</pre>
29651 Runtime-constraints
29653 format shall not be a null pointer. The %n specifier<sup><a href="#note425"><b>425)</b></a></sup> (modified or not by flags, field
29654 width, or precision) shall not appear in the wide string pointed to by format. Any
29655 argument to vwprintf_s corresponding to a %s specifier shall not be a null pointer.
29657 If there is a runtime-constraint violation, the vwprintf_s function does not attempt to
29658 produce further output, and it is unspecified to what extent vwprintf_s produced
29659 output before discovering the runtime-constraint violation.
29660 <h6>Description</h6>
29662 The vwprintf_s function is equivalent to the vwprintf function except for the
29663 explicit runtime-constraints listed above.
29666 The vwprintf_s function returns the number of wide characters transmitted, or a
29667 negative value if an output error, encoding error, or runtime-constraint violation occurred.
29672 <!--page 651 indent 4-->
29675 <p><a name="note425">425)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29676 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29677 example, if the entire format string was L"%%n".
29680 <a name="K.3.9.1.12" href="#K.3.9.1.12"><h5>K.3.9.1.12 The vwscanf_s function</h5></a>
29684 #define __STDC_WANT_LIB_EXT1__ 1
29685 #include <stdarg.h>
29686 #include <wchar.h>
29687 int vwscanf_s(const wchar_t * restrict format,
29688 va_list arg);</pre>
29689 Runtime-constraints
29691 format shall not be a null pointer. Any argument indirected though in order to store
29692 converted input shall not be a null pointer.
29694 If there is a runtime-constraint violation, the vwscanf_s function does not attempt to
29695 perform further input, and it is unspecified to what extent vwscanf_s performed input
29696 before discovering the runtime-constraint violation.
29697 <h6>Description</h6>
29699 The vwscanf_s function is equivalent to wscanf_s, with the variable argument list
29700 replaced by arg, which shall have been initialized by the va_start macro (and
29701 possibly subsequent va_arg calls). The vwscanf_s function does not invoke the
29702 va_end macro.<sup><a href="#note426"><b>426)</b></a></sup>
29705 The vwscanf_s function returns the value of the macro EOF if an input failure occurs
29706 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29707 vwscanf_s function returns the number of input items assigned, which can be fewer
29708 than provided for, or even zero, in the event of an early matching failure.
29711 <p><a name="note426">426)</a> As the functions vfwscanf_s, vwscanf_s, and vswscanf_s invoke the va_arg macro, the
29712 value of arg after the return is indeterminate.
29715 <a name="K.3.9.1.13" href="#K.3.9.1.13"><h5>K.3.9.1.13 The wprintf_s function</h5></a>
29719 #define __STDC_WANT_LIB_EXT1__ 1
29720 #include <wchar.h>
29721 int wprintf_s(const wchar_t * restrict format, ...);</pre>
29722 Runtime-constraints
29724 format shall not be a null pointer. The %n specifier<sup><a href="#note427"><b>427)</b></a></sup> (modified or not by flags, field
29726 <!--page 652 indent 4-->
29727 width, or precision) shall not appear in the wide string pointed to by format. Any
29728 argument to wprintf_s corresponding to a %s specifier shall not be a null pointer.
29730 If there is a runtime-constraint violation, the wprintf_s function does not attempt to
29731 produce further output, and it is unspecified to what extent wprintf_s produced output
29732 before discovering the runtime-constraint violation.
29733 <h6>Description</h6>
29735 The wprintf_s function is equivalent to the wprintf function except for the explicit
29736 runtime-constraints listed above.
29739 The wprintf_s function returns the number of wide characters transmitted, or a
29740 negative value if an output error, encoding error, or runtime-constraint violation occurred.
29743 <p><a name="note427">427)</a> It is not a runtime-constraint violation for the wide characters %n to appear in sequence in the wide
29744 string pointed at by format when those wide characters are not a interpreted as a %n specifier. For
29745 example, if the entire format string was L"%%n".
29748 <a name="K.3.9.1.14" href="#K.3.9.1.14"><h5>K.3.9.1.14 The wscanf_s function</h5></a>
29752 #define __STDC_WANT_LIB_EXT1__ 1
29753 #include <wchar.h>
29754 int wscanf_s(const wchar_t * restrict format, ...);</pre>
29755 Runtime-constraints
29757 format shall not be a null pointer. Any argument indirected though in order to store
29758 converted input shall not be a null pointer.
29760 If there is a runtime-constraint violation, the wscanf_s function does not attempt to
29761 perform further input, and it is unspecified to what extent wscanf_s performed input
29762 before discovering the runtime-constraint violation.
29763 <h6>Description</h6>
29765 The wscanf_s function is equivalent to fwscanf_s with the argument stdin
29766 interposed before the arguments to wscanf_s.
29769 The wscanf_s function returns the value of the macro EOF if an input failure occurs
29770 before any conversion or if there is a runtime-constraint violation. Otherwise, the
29771 wscanf_s function returns the number of input items assigned, which can be fewer than
29772 provided for, or even zero, in the event of an early matching failure.
29773 <!--page 653 indent 4-->
29775 <a name="K.3.9.2" href="#K.3.9.2"><h5>K.3.9.2 General wide string utilities</h5></a>
29777 <a name="K.3.9.2.1" href="#K.3.9.2.1"><h5>K.3.9.2.1 Wide string copying functions</h5></a>
29779 <a name="K.3.9.2.1.1" href="#K.3.9.2.1.1"><h5>K.3.9.2.1.1 The wcscpy_s function</h5></a>
29783 #define __STDC_WANT_LIB_EXT1__ 1
29784 #include <wchar.h>
29785 errno_t wcscpy_s(wchar_t * restrict s1,
29787 const wchar_t * restrict s2);</pre>
29788 Runtime-constraints
29790 Neither s1 nor s2 shall be a null pointer. s1max shall not be greater than RSIZE_MAX.
29791 s1max shall not equal zero. s1max shall be greater than wcsnlen_s(s2, s1max).
29792 Copying shall not take place between objects that overlap.
29794 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
29795 greater than zero and not greater than RSIZE_MAX, then wcscpy_s sets s1[0] to the
29796 null wide character.
29797 <h6>Description</h6>
29799 The wcscpy_s function copies the wide string pointed to by s2 (including the
29800 terminating null wide character) into the array pointed to by s1.
29802 All elements following the terminating null wide character (if any) written by
29803 wcscpy_s in the array of s1max wide characters pointed to by s1 take unspecified
29804 values when wcscpy_s returns.<sup><a href="#note428"><b>428)</b></a></sup>
29807 The wcscpy_s function returns zero<sup><a href="#note429"><b>429)</b></a></sup> if there was no runtime-constraint violation.
29808 Otherwise, a nonzero value is returned.
29813 <!--page 654 indent 5-->
29816 <p><a name="note428">428)</a> This allows an implementation to copy wide characters from s2 to s1 while simultaneously checking
29817 if any of those wide characters are null. Such an approach might write a wide character to every
29818 element of s1 before discovering that the first element should be set to the null wide character.
29820 <p><a name="note429">429)</a> A zero return value implies that all of the requested wide characters from the string pointed to by s2
29821 fit within the array pointed to by s1 and that the result in s1 is null terminated.
29824 <a name="K.3.9.2.1.2" href="#K.3.9.2.1.2"><h5>K.3.9.2.1.2 The wcsncpy_s function</h5></a>
29828 #define __STDC_WANT_LIB_EXT1__ 1
29829 #include <wchar.h>
29830 errno_t wcsncpy_s(wchar_t * restrict s1,
29832 const wchar_t * restrict s2,
29834 Runtime-constraints
29836 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
29837 RSIZE_MAX. s1max shall not equal zero. If n is not less than s1max, then s1max
29838 shall be greater than wcsnlen_s(s2, s1max). Copying shall not take place between
29839 objects that overlap.
29841 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
29842 greater than zero and not greater than RSIZE_MAX, then wcsncpy_s sets s1[0] to the
29843 null wide character.
29844 <h6>Description</h6>
29846 The wcsncpy_s function copies not more than n successive wide characters (wide
29847 characters that follow a null wide character are not copied) from the array pointed to by
29848 s2 to the array pointed to by s1. If no null wide character was copied from s2, then
29849 s1[n] is set to a null wide character.
29851 All elements following the terminating null wide character (if any) written by
29852 wcsncpy_s in the array of s1max wide characters pointed to by s1 take unspecified
29853 values when wcsncpy_s returns.<sup><a href="#note430"><b>430)</b></a></sup>
29856 The wcsncpy_s function returns zero<sup><a href="#note431"><b>431)</b></a></sup> if there was no runtime-constraint violation.
29857 Otherwise, a nonzero value is returned.
29859 EXAMPLE 1 The wcsncpy_s function can be used to copy a wide string without the danger that the
29860 result will not be null terminated or that wide characters will be written past the end of the destination
29866 <!--page 655 indent 5-->
29868 #define __STDC_WANT_LIB_EXT1__ 1
29869 #include <wchar.h>
29871 wchar_t src1[100] = L"hello";
29872 wchar_t src2[7] = {L'g', L'o', L'o', L'd', L'b', L'y', L'e'};
29873 wchar_t dst1[6], dst2[5], dst3[5];
29875 r1 = wcsncpy_s(dst1, 6, src1, 100);
29876 r2 = wcsncpy_s(dst2, 5, src2, 7);
29877 r3 = wcsncpy_s(dst3, 5, src2, 4);</pre>
29878 The first call will assign to r1 the value zero and to dst1 the sequence of wide characters hello\0.
29879 The second call will assign to r2 a nonzero value and to dst2 the sequence of wide characters \0.
29880 The third call will assign to r3 the value zero and to dst3 the sequence of wide characters good\0.
29884 <p><a name="note430">430)</a> This allows an implementation to copy wide characters from s2 to s1 while simultaneously checking
29885 if any of those wide characters are null. Such an approach might write a wide character to every
29886 element of s1 before discovering that the first element should be set to the null wide character.
29888 <p><a name="note431">431)</a> A zero return value implies that all of the requested wide characters from the string pointed to by s2
29889 fit within the array pointed to by s1 and that the result in s1 is null terminated.
29892 <a name="K.3.9.2.1.3" href="#K.3.9.2.1.3"><h5>K.3.9.2.1.3 The wmemcpy_s function</h5></a>
29896 #define __STDC_WANT_LIB_EXT1__ 1
29897 #include <wchar.h>
29898 errno_t wmemcpy_s(wchar_t * restrict s1,
29900 const wchar_t * restrict s2,
29902 Runtime-constraints
29904 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
29905 RSIZE_MAX. n shall not be greater than s1max. Copying shall not take place between
29906 objects that overlap.
29908 If there is a runtime-constraint violation, the wmemcpy_s function stores zeros in the
29909 first s1max wide characters of the object pointed to by s1 if s1 is not a null pointer and
29910 s1max is not greater than RSIZE_MAX.
29911 <h6>Description</h6>
29913 The wmemcpy_s function copies n successive wide characters from the object pointed
29914 to by s2 into the object pointed to by s1.
29917 The wmemcpy_s function returns zero if there was no runtime-constraint violation.
29918 Otherwise, a nonzero value is returned.
29919 <!--page 656 indent 5-->
29921 <a name="K.3.9.2.1.4" href="#K.3.9.2.1.4"><h5>K.3.9.2.1.4 The wmemmove_s function</h5></a>
29925 #define __STDC_WANT_LIB_EXT1__ 1
29926 #include <wchar.h>
29927 errno_t wmemmove_s(wchar_t *s1, rsize_t s1max,
29928 const wchar_t *s2, rsize_t n);</pre>
29929 Runtime-constraints
29931 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
29932 RSIZE_MAX. n shall not be greater than s1max.
29934 If there is a runtime-constraint violation, the wmemmove_s function stores zeros in the
29935 first s1max wide characters of the object pointed to by s1 if s1 is not a null pointer and
29936 s1max is not greater than RSIZE_MAX.
29937 <h6>Description</h6>
29939 The wmemmove_s function copies n successive wide characters from the object pointed
29940 to by s2 into the object pointed to by s1. This copying takes place as if the n wide
29941 characters from the object pointed to by s2 are first copied into a temporary array of n
29942 wide characters that does not overlap the objects pointed to by s1 or s2, and then the n
29943 wide characters from the temporary array are copied into the object pointed to by s1.
29946 The wmemmove_s function returns zero if there was no runtime-constraint violation.
29947 Otherwise, a nonzero value is returned.
29949 <a name="K.3.9.2.2" href="#K.3.9.2.2"><h5>K.3.9.2.2 Wide string concatenation functions</h5></a>
29951 <a name="K.3.9.2.2.1" href="#K.3.9.2.2.1"><h5>K.3.9.2.2.1 The wcscat_s function</h5></a>
29955 #define __STDC_WANT_LIB_EXT1__ 1
29956 #include <wchar.h>
29957 errno_t wcscat_s(wchar_t * restrict s1,
29959 const wchar_t * restrict s2);</pre>
29960 Runtime-constraints
29962 Let m denote the value s1max - wcsnlen_s(s1, s1max) upon entry to
29965 Neither s1 nor s2 shall be a null pointer. s1max shall not be greater than RSIZE_MAX.
29966 s1max shall not equal zero. m shall not equal zero.<sup><a href="#note432"><b>432)</b></a></sup> m shall be greater than
29967 wcsnlen_s(s2, m). Copying shall not take place between objects that overlap.
29968 <!--page 657 indent 5-->
29970 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
29971 greater than zero and not greater than RSIZE_MAX, then wcscat_s sets s1[0] to the
29972 null wide character.
29973 <h6>Description</h6>
29975 The wcscat_s function appends a copy of the wide string pointed to by s2 (including
29976 the terminating null wide character) to the end of the wide string pointed to by s1. The
29977 initial wide character from s2 overwrites the null wide character at the end of s1.
29979 All elements following the terminating null wide character (if any) written by
29980 wcscat_s in the array of s1max wide characters pointed to by s1 take unspecified
29981 values when wcscat_s returns.<sup><a href="#note433"><b>433)</b></a></sup>
29984 The wcscat_s function returns zero<sup><a href="#note434"><b>434)</b></a></sup> if there was no runtime-constraint violation.
29985 Otherwise, a nonzero value is returned.
29988 <p><a name="note432">432)</a> Zero means that s1 was not null terminated upon entry to wcscat_s.
29990 <p><a name="note433">433)</a> This allows an implementation to append wide characters from s2 to s1 while simultaneously
29991 checking if any of those wide characters are null. Such an approach might write a wide character to
29992 every element of s1 before discovering that the first element should be set to the null wide character.
29994 <p><a name="note434">434)</a> A zero return value implies that all of the requested wide characters from the wide string pointed to by
29995 s2 were appended to the wide string pointed to by s1 and that the result in s1 is null terminated.
29998 <a name="K.3.9.2.2.2" href="#K.3.9.2.2.2"><h5>K.3.9.2.2.2 The wcsncat_s function</h5></a>
30002 #define __STDC_WANT_LIB_EXT1__ 1
30003 #include <wchar.h>
30004 errno_t wcsncat_s(wchar_t * restrict s1,
30006 const wchar_t * restrict s2,
30008 Runtime-constraints
30010 Let m denote the value s1max - wcsnlen_s(s1, s1max) upon entry to
30013 Neither s1 nor s2 shall be a null pointer. Neither s1max nor n shall be greater than
30014 RSIZE_MAX. s1max shall not equal zero. m shall not equal zero.<sup><a href="#note435"><b>435)</b></a></sup> If n is not less
30015 than m, then m shall be greater than wcsnlen_s(s2, m). Copying shall not take
30016 place between objects that overlap.
30019 <!--page 658 indent 5-->
30021 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
30022 greater than zero and not greater than RSIZE_MAX, then wcsncat_s sets s1[0] to the
30023 null wide character.
30024 <h6>Description</h6>
30026 The wcsncat_s function appends not more than n successive wide characters (wide
30027 characters that follow a null wide character are not copied) from the array pointed to by
30028 s2 to the end of the wide string pointed to by s1. The initial wide character from s2
30029 overwrites the null wide character at the end of s1. If no null wide character was copied
30030 from s2, then s1[s1max-m+n] is set to a null wide character.
30032 All elements following the terminating null wide character (if any) written by
30033 wcsncat_s in the array of s1max wide characters pointed to by s1 take unspecified
30034 values when wcsncat_s returns.<sup><a href="#note436"><b>436)</b></a></sup>
30037 The wcsncat_s function returns zero<sup><a href="#note437"><b>437)</b></a></sup> if there was no runtime-constraint violation.
30038 Otherwise, a nonzero value is returned.
30040 EXAMPLE 1 The wcsncat_s function can be used to copy a wide string without the danger that the
30041 result will not be null terminated or that wide characters will be written past the end of the destination
30044 #define __STDC_WANT_LIB_EXT1__ 1
30045 #include <wchar.h>
30047 wchar_t s1[100] = L"good";
30048 wchar_t s2[6] = L"hello";
30049 wchar_t s3[6] = L"hello";
30050 wchar_t s4[7] = L"abc";
30051 wchar_t s5[1000] = L"bye";
30052 int r1, r2, r3, r4;
30053 r1 = wcsncat_s(s1, 100, s5, 1000);
30054 r2 = wcsncat_s(s2, 6, L"", 1);
30055 r3 = wcsncat_s(s3, 6, L"X", 2);
30056 r4 = wcsncat_s(s4, 7, L"defghijklmn", 3);</pre>
30057 After the first call r1 will have the value zero and s1 will be the wide character sequence goodbye\0.
30058 After the second call r2 will have the value zero and s2 will be the wide character sequence hello\0.
30059 After the third call r3 will have a nonzero value and s3 will be the wide character sequence \0.
30060 After the fourth call r4 will have the value zero and s4 will be the wide character sequence abcdef\0.
30065 <!--page 659 indent 4-->
30068 <p><a name="note435">435)</a> Zero means that s1 was not null terminated upon entry to wcsncat_s.
30070 <p><a name="note436">436)</a> This allows an implementation to append wide characters from s2 to s1 while simultaneously
30071 checking if any of those wide characters are null. Such an approach might write a wide character to
30072 every element of s1 before discovering that the first element should be set to the null wide character.
30074 <p><a name="note437">437)</a> A zero return value implies that all of the requested wide characters from the wide string pointed to by
30075 s2 were appended to the wide string pointed to by s1 and that the result in s1 is null terminated.
30078 <a name="K.3.9.2.3" href="#K.3.9.2.3"><h5>K.3.9.2.3 Wide string search functions</h5></a>
30080 <a name="K.3.9.2.3.1" href="#K.3.9.2.3.1"><h5>K.3.9.2.3.1 The wcstok_s function</h5></a>
30084 #define __STDC_WANT_LIB_EXT1__ 1
30085 #include <wchar.h>
30086 wchar_t *wcstok_s(wchar_t * restrict s1,
30087 rsize_t * restrict s1max,
30088 const wchar_t * restrict s2,
30089 wchar_t ** restrict ptr);</pre>
30090 Runtime-constraints
30092 None of s1max, s2, or ptr shall be a null pointer. If s1 is a null pointer, then *ptr
30093 shall not be a null pointer. The value of *s1max shall not be greater than RSIZE_MAX.
30094 The end of the token found shall occur within the first *s1max wide characters of s1 for
30095 the first call, and shall occur within the first *s1max wide characters of where searching
30096 resumes on subsequent calls.
30098 If there is a runtime-constraint violation, the wcstok_s function does not indirect
30099 through the s1 or s2 pointers, and does not store a value in the object pointed to by ptr.
30100 <h6>Description</h6>
30102 A sequence of calls to the wcstok_s function breaks the wide string pointed to by s1
30103 into a sequence of tokens, each of which is delimited by a wide character from the wide
30104 string pointed to by s2. The fourth argument points to a caller-provided wchar_t
30105 pointer into which the wcstok_s function stores information necessary for it to
30106 continue scanning the same wide string.
30108 The first call in a sequence has a non-null first argument and s1max points to an object
30109 whose value is the number of elements in the wide character array pointed to by the first
30110 argument. The first call stores an initial value in the object pointed to by ptr and
30111 updates the value pointed to by s1max to reflect the number of elements that remain in
30112 relation to ptr. Subsequent calls in the sequence have a null first argument and the
30113 objects pointed to by s1max and ptr are required to have the values stored by the
30114 previous call in the sequence, which are then updated. The separator wide string pointed
30115 to by s2 may be different from call to call.
30117 The first call in the sequence searches the wide string pointed to by s1 for the first wide
30118 character that is not contained in the current separator wide string pointed to by s2. If no
30119 such wide character is found, then there are no tokens in the wide string pointed to by s1
30120 and the wcstok_s function returns a null pointer. If such a wide character is found, it is
30121 the start of the first token.
30122 <!--page 660 indent 5-->
30124 The wcstok_s function then searches from there for the first wide character in s1 that
30125 is contained in the current separator wide string. If no such wide character is found, the
30126 current token extends to the end of the wide string pointed to by s1, and subsequent
30127 searches in the same wide string for a token return a null pointer. If such a wide character
30128 is found, it is overwritten by a null wide character, which terminates the current token.
30130 In all cases, the wcstok_s function stores sufficient information in the pointer pointed
30131 to by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
30132 value for ptr, shall start searching just past the element overwritten by a null wide
30133 character (if any).
30136 The wcstok_s function returns a pointer to the first wide character of a token, or a null
30137 pointer if there is no token or there is a runtime-constraint violation.
30141 #define __STDC_WANT_LIB_EXT1__ 1
30142 #include <wchar.h>
30143 static wchar_t str1[] = L"?a???b,,,#c";
30144 static wchar_t str2[] = L"\t \t";
30145 wchar_t *t, *ptr1, *ptr2;
30146 rsize_t max1 = wcslen(str1)+1;
30147 rsize_t max2 = wcslen(str2)+1;
30148 t = wcstok_s(str1, &max1, "?", &ptr1); // t points to the token "a"
30149 t = wcstok_s(NULL, &max1, ",", &ptr1); // t points to the token "??b"
30150 t = wcstok_s(str2, &max2, " \t", &ptr2); // t is a null pointer
30151 t = wcstok_s(NULL, &max1, "#,", &ptr1); // t points to the token "c"
30152 t = wcstok_s(NULL, &max1, "?", &ptr1); // t is a null pointer</pre>
30155 <a name="K.3.9.2.4" href="#K.3.9.2.4"><h5>K.3.9.2.4 Miscellaneous functions</h5></a>
30157 <a name="K.3.9.2.4.1" href="#K.3.9.2.4.1"><h5>K.3.9.2.4.1 The wcsnlen_s function</h5></a>
30161 #define __STDC_WANT_LIB_EXT1__ 1
30162 #include <wchar.h>
30163 size_t wcsnlen_s(const wchar_t *s, size_t maxsize);</pre>
30164 <h6>Description</h6>
30166 The wcsnlen_s function computes the length of the wide string pointed to by s.
30169 If s is a null pointer,<sup><a href="#note438"><b>438)</b></a></sup> then the wcsnlen_s function returns zero.
30171 Otherwise, the wcsnlen_s function returns the number of wide characters that precede
30172 the terminating null wide character. If there is no null wide character in the first
30173 maxsize wide characters of s then wcsnlen_s returns maxsize. At most the first
30174 <!--page 661 indent 4-->
30175 maxsize wide characters of s shall be accessed by wcsnlen_s.
30178 <p><a name="note438">438)</a> Note that the wcsnlen_s function has no runtime-constraints. This lack of runtime-constraints
30179 along with the values returned for a null pointer or an unterminated wide string argument make
30180 wcsnlen_s useful in algorithms that gracefully handle such exceptional data.
30183 <a name="K.3.9.3" href="#K.3.9.3"><h5>K.3.9.3 Extended multibyte/wide character conversion utilities</h5></a>
30185 <a name="K.3.9.3.1" href="#K.3.9.3.1"><h5>K.3.9.3.1 Restartable multibyte/wide character conversion functions</h5></a>
30187 Unlike wcrtomb, wcrtomb_s does not permit the ps parameter (the pointer to the
30188 conversion state) to be a null pointer.
30190 <a name="K.3.9.3.1.1" href="#K.3.9.3.1.1"><h5>K.3.9.3.1.1 The wcrtomb_s function</h5></a>
30194 #include <wchar.h>
30195 errno_t wcrtomb_s(size_t * restrict retval,
30196 char * restrict s, rsize_t smax,
30197 wchar_t wc, mbstate_t * restrict ps);</pre>
30198 Runtime-constraints
30200 Neither retval nor ps shall be a null pointer. If s is not a null pointer, then smax
30201 shall not equal zero and shall not be greater than RSIZE_MAX. If s is not a null pointer,
30202 then smax shall be not be less than the number of bytes to be stored in the array pointed
30203 to by s. If s is a null pointer, then smax shall equal zero.
30205 If there is a runtime-constraint violation, then wcrtomb_s does the following. If s is
30206 not a null pointer and smax is greater than zero and not greater than RSIZE_MAX, then
30207 wcrtomb_s sets s[0] to the null character. If retval is not a null pointer, then
30208 wcrtomb_s sets *retval to (size_t)(-1).
30209 <h6>Description</h6>
30211 If s is a null pointer, the wcrtomb_s function is equivalent to the call
30213 wcrtomb_s(&retval, buf, sizeof buf, L'\0', ps)</pre>
30214 where retval and buf are internal variables of the appropriate types, and the size of
30215 buf is greater than MB_CUR_MAX.
30217 If s is not a null pointer, the wcrtomb_s function determines the number of bytes
30218 needed to represent the multibyte character that corresponds to the wide character given
30219 by wc (including any shift sequences), and stores the multibyte character representation
30220 in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are
30221 stored. If wc is a null wide character, a null byte is stored, preceded by any shift
30222 sequence needed to restore the initial shift state; the resulting state described is the initial
30225 <!--page 662 indent 4-->
30227 If wc does not correspond to a valid multibyte character, an encoding error occurs: the
30228 wcrtomb_s function stores the value (size_t)(-1) into *retval and the
30229 conversion state is unspecified. Otherwise, the wcrtomb_s function stores into
30230 *retval the number of bytes (including any shift sequences) stored in the array pointed
30234 The wcrtomb_s function returns zero if no runtime-constraint violation and no
30235 encoding error occurred. Otherwise, a nonzero value is returned.
30237 <a name="K.3.9.3.2" href="#K.3.9.3.2"><h5>K.3.9.3.2 Restartable multibyte/wide string conversion functions</h5></a>
30239 Unlike mbsrtowcs and wcsrtombs, mbsrtowcs_s and wcsrtombs_s do not
30240 permit the ps parameter (the pointer to the conversion state) to be a null pointer.
30242 <a name="K.3.9.3.2.1" href="#K.3.9.3.2.1"><h5>K.3.9.3.2.1 The mbsrtowcs_s function</h5></a>
30246 #include <wchar.h>
30247 errno_t mbsrtowcs_s(size_t * restrict retval,
30248 wchar_t * restrict dst, rsize_t dstmax,
30249 const char ** restrict src, rsize_t len,
30250 mbstate_t * restrict ps);</pre>
30251 Runtime-constraints
30253 None of retval, src, *src, or ps shall be null pointers. If dst is not a null pointer,
30254 then neither len nor dstmax shall be greater than RSIZE_MAX. If dst is a null
30255 pointer, then dstmax shall equal zero. If dst is not a null pointer, then dstmax shall
30256 not equal zero. If dst is not a null pointer and len is not less than dstmax, then a null
30257 character shall occur within the first dstmax multibyte characters of the array pointed to
30260 If there is a runtime-constraint violation, then mbsrtowcs_s does the following. If
30261 retval is not a null pointer, then mbsrtowcs_s sets *retval to (size_t)(-1).
30262 If dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
30263 then mbsrtowcs_s sets dst[0] to the null wide character.
30264 <h6>Description</h6>
30266 The mbsrtowcs_s function converts a sequence of multibyte characters that begins in
30267 the conversion state described by the object pointed to by ps, from the array indirectly
30268 pointed to by src into a sequence of corresponding wide characters. If dst is not a null
30269 pointer, the converted characters are stored into the array pointed to by dst. Conversion
30270 continues up to and including a terminating null character, which is also stored.
30271 Conversion stops earlier in two cases: when a sequence of bytes is encountered that does
30272 not form a valid multibyte character, or (if dst is not a null pointer) when len wide
30273 <!--page 663 indent 5-->
30274 characters have been stored into the array pointed to by dst.<sup><a href="#note439"><b>439)</b></a></sup> If dst is not a null
30275 pointer and no null wide character was stored into the array pointed to by dst, then
30276 dst[len] is set to the null wide character. Each conversion takes place as if by a call
30277 to the mbrtowc function.
30279 If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
30280 pointer (if conversion stopped due to reaching a terminating null character) or the address
30281 just past the last multibyte character converted (if any). If conversion stopped due to
30282 reaching a terminating null character and if dst is not a null pointer, the resulting state
30283 described is the initial conversion state.
30285 Regardless of whether dst is or is not a null pointer, if the input conversion encounters a
30286 sequence of bytes that do not form a valid multibyte character, an encoding error occurs:
30287 the mbsrtowcs_s function stores the value (size_t)(-1) into *retval and the
30288 conversion state is unspecified. Otherwise, the mbsrtowcs_s function stores into
30289 *retval the number of multibyte characters successfully converted, not including the
30290 terminating null character (if any).
30292 All elements following the terminating null wide character (if any) written by
30293 mbsrtowcs_s in the array of dstmax wide characters pointed to by dst take
30294 unspecified values when mbsrtowcs_s returns.<sup><a href="#note440"><b>440)</b></a></sup>
30296 If copying takes place between objects that overlap, the objects take on unspecified
30300 The mbsrtowcs_s function returns zero if no runtime-constraint violation and no
30301 encoding error occurred. Otherwise, a nonzero value is returned.
30304 <p><a name="note439">439)</a> Thus, the value of len is ignored if dst is a null pointer.
30306 <p><a name="note440">440)</a> This allows an implementation to attempt converting the multibyte string before discovering a
30307 terminating null character did not occur where required.
30310 <a name="K.3.9.3.2.2" href="#K.3.9.3.2.2"><h5>K.3.9.3.2.2 The wcsrtombs_s function</h5></a>
30314 #include <wchar.h>
30315 errno_t wcsrtombs_s(size_t * restrict retval,
30316 char * restrict dst, rsize_t dstmax,
30317 const wchar_t ** restrict src, rsize_t len,
30318 mbstate_t * restrict ps);</pre>
30323 <!--page 664 indent 5-->
30324 Runtime-constraints
30326 None of retval, src, *src, or ps shall be null pointers. If dst is not a null pointer,
30327 then neither len nor dstmax shall be greater than RSIZE_MAX. If dst is a null
30328 pointer, then dstmax shall equal zero. If dst is not a null pointer, then dstmax shall
30329 not equal zero. If dst is not a null pointer and len is not less than dstmax, then the
30330 conversion shall have been stopped (see below) because a terminating null wide character
30331 was reached or because an encoding error occurred.
30333 If there is a runtime-constraint violation, then wcsrtombs_s does the following. If
30334 retval is not a null pointer, then wcsrtombs_s sets *retval to (size_t)(-1).
30335 If dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
30336 then wcsrtombs_s sets dst[0] to the null character.
30337 <h6>Description</h6>
30339 The wcsrtombs_s function converts a sequence of wide characters from the array
30340 indirectly pointed to by src into a sequence of corresponding multibyte characters that
30341 begins in the conversion state described by the object pointed to by ps. If dst is not a
30342 null pointer, the converted characters are then stored into the array pointed to by dst.
30343 Conversion continues up to and including a terminating null wide character, which is also
30344 stored. Conversion stops earlier in two cases:
30346 <li> when a wide character is reached that does not correspond to a valid multibyte
30348 <li> (if dst is not a null pointer) when the next multibyte character would exceed the
30349 limit of n total bytes to be stored into the array pointed to by dst. If the wide
30350 character being converted is the null wide character, then n is the lesser of len or
30351 dstmax. Otherwise, n is the lesser of len or dstmax-1.
30353 If the conversion stops without converting a null wide character and dst is not a null
30354 pointer, then a null character is stored into the array pointed to by dst immediately
30355 following any multibyte characters already stored. Each conversion takes place as if by a
30356 call to the wcrtomb function.<sup><a href="#note441"><b>441)</b></a></sup>
30358 If dst is not a null pointer, the pointer object pointed to by src is assigned either a null
30359 pointer (if conversion stopped due to reaching a terminating null wide character) or the
30360 address just past the last wide character converted (if any). If conversion stopped due to
30361 reaching a terminating null wide character, the resulting state described is the initial
30365 <!--page 665 indent 5-->
30367 Regardless of whether dst is or is not a null pointer, if the input conversion encounters a
30368 wide character that does not correspond to a valid multibyte character, an encoding error
30369 occurs: the wcsrtombs_s function stores the value (size_t)(-1) into *retval
30370 and the conversion state is unspecified. Otherwise, the wcsrtombs_s function stores
30371 into *retval the number of bytes in the resulting multibyte character sequence, not
30372 including the terminating null character (if any).
30374 All elements following the terminating null character (if any) written by wcsrtombs_s
30375 in the array of dstmax elements pointed to by dst take unspecified values when
30376 wcsrtombs_s returns.<sup><a href="#note442"><b>442)</b></a></sup>
30378 If copying takes place between objects that overlap, the objects take on unspecified
30382 The wcsrtombs_s function returns zero if no runtime-constraint violation and no
30383 encoding error occurred. Otherwise, a nonzero value is returned.
30388 <!--page 666 indent 4-->
30391 <p><a name="note441">441)</a> If conversion stops because a terminating null wide character has been reached, the bytes stored
30392 include those necessary to reach the initial shift state immediately before the null byte. However, if
30393 the conversion stops before a terminating null wide character has been reached, the result will be null
30394 terminated, but might not end in the initial shift state.
30396 <p><a name="note442">442)</a> When len is not less than dstmax, the implementation might fill the array before discovering a
30397 runtime-constraint violation.
30400 <a name="L" href="#L"><h2>Annex L</h2></a>
30403 Analyzability</pre>
30405 <a name="L.1" href="#L.1"><h3>L.1 Scope</h3></a>
30407 This annex specifies optional behavior that can aid in the analyzability of C programs.
30409 An implementation that defines __STDC_ANALYZABLE__ shall conform to the
30410 specifications in this annex.<sup><a href="#note443"><b>443)</b></a></sup>
30413 <p><a name="note443">443)</a> Implementations that do not define __STDC_ANALYZABLE__ are not required to conform to these
30417 <a name="L.2" href="#L.2"><h3>L.2 Definitions</h3></a>
30419 <a name="L.2.1" href="#L.2.1"><h4>L.2.1</h4></a>
30421 out-of-bounds store
30422 an (attempted) access (<a href="#3.1">3.1</a>) that, at run time, for a given computational state, would
30423 modify (or, for an object declared volatile, fetch) one or more bytes that lie outside
30424 the bounds permitted by this Standard.
30426 <a name="L.2.2" href="#L.2.2"><h4>L.2.2</h4></a>
30428 bounded undefined behavior
30429 undefined behavior (<a href="#3.4.3">3.4.3</a>) that does not perform an out-of-bounds store.
30431 NOTE 1 The behavior might perform a trap.
30434 NOTE 2 Any values produced or stored might be indeterminate values.
30437 <a name="L.2.3" href="#L.2.3"><h4>L.2.3</h4></a>
30439 critical undefined behavior
30440 undefined behavior that is not bounded undefined behavior.
30442 NOTE The behavior might perform an out-of-bounds store or perform a trap.
30447 <!--page 667 indent 4-->
30449 <a name="L.3" href="#L.3"><h3>L.3 Requirements</h3></a>
30451 If the program performs a trap (<a href="#3.19.5">3.19.5</a>), the implementation is permitted to invoke a
30452 runtime-constraint handler. Any such semantics are implementation-defined.
30454 All undefined behavior shall be limited to bounded undefined behavior, except for the
30455 following which are permitted to result in critical undefined behavior:
30457 <li> An object is referred to outside of its lifetime (<a href="#6.2.4">6.2.4</a>).
30458 <li> An lvalue does not designate an object when evaluated (<a href="#6.3.2.1">6.3.2.1</a>).
30459 <li> A pointer is used to call a function whose type is not compatible with the referenced
30460 type (<a href="#6.3.2.3">6.3.2.3</a>).
30461 <li> The operand of the unary * operator has an invalid value (<a href="#6.5.3.2">6.5.3.2</a>).
30462 <li> Addition or subtraction of a pointer into, or just beyond, an array object and an
30463 integer type produces a result that points just beyond the array object and is used as
30464 the operand of a unary * operator that is evaluated (<a href="#6.5.6">6.5.6</a>).
30465 <li> An argument to a library function has an invalid value or a type not expected by a
30466 function with variable number of arguments (<a href="#7.1.4">7.1.4</a>).
30467 <li> The value of a pointer that refers to space deallocated by a call to the free or realloc
30468 function is used (<a href="#7.22.3">7.22.3</a>).
30469 <li> A string or wide string utility function is instructed to access an array beyond the end
30470 of an object (<a href="#7.23.1">7.23.1</a>, <a href="#7.28.4">7.28.4</a>).
30471 <!--page 668 indent -1-->
30474 <a name="Bibliography" href="#Bibliography"><h2>Bibliography</h2></a>
30476 <li> ''The C Reference Manual'' by Dennis M. Ritchie, a version of which was
30477 published in The C Programming Language by Brian W. Kernighan and Dennis
30478 M. Ritchie, Prentice-Hall, Inc., (1978). Copyright owned by AT&T.
30479 <li> 1984 /usr/group Standard by the /usr/group Standards Committee, Santa Clara,
30480 California, USA, November 1984.
30481 <li> ANSI X3/TR-1-82 (1982), American National Dictionary for Information
30482 Processing Systems, Information Processing Systems Technical Report.
30483 <li> ANSI/IEEE 754-1985, American National Standard for Binary Floating-Point
30485 <li> ANSI/IEEE 854-1988, American National Standard for Radix-Independent
30486 Floating-Point Arithmetic.
30487 <li> IEC 60559:1989, Binary floating-point arithmetic for microprocessor systems,
30488 second edition (previously designated IEC 559:1989).
30489 <li> ISO 31-11:1992, Quantities and units -- Part 11: Mathematical signs and
30490 symbols for use in the physical sciences and technology.
30491 <li> ISO/IEC 646:1991, Information technology -- ISO 7-bit coded character set for
30492 information interchange.
30493 <li> ISO/IEC 2382-1:1993, Information technology -- Vocabulary -- Part 1:
30495 <li> ISO 4217:1995, Codes for the representation of currencies and funds.
30496 <li> ISO 8601:1988, Data elements and interchange formats -- Information
30497 interchange -- Representation of dates and times.
30498 <li> ISO/IEC 9899:1990, Programming languages -- C.
30499 <li> ISO/IEC 9899/COR1:1994, Technical Corrigendum 1.
30500 <li> ISO/IEC 9899/COR2:1996, Technical Corrigendum 2.
30501 <li> ISO/IEC 9899/AMD1:1995, Amendment 1 to ISO/IEC 9899:1990 C Integrity.
30502 <li> ISO/IEC 9899:1999, Programming languages -- C.
30503 <li> ISO/IEC 9899:1999/Cor.1:2001, Technical Corrigendum 1.
30504 <li> ISO/IEC 9899:1999/Cor.2:2004, Technical Corrigendum 2.
30505 <li> ISO/IEC 9899:1999/Cor.3:2007, Technical Corrigendum 3.
30506 <!--page 669 indent -1-->
30507 <li> ISO/IEC 9945-2:1993, Information technology -- Portable Operating System
30508 Interface (POSIX) -- Part 2: Shell and Utilities.
30509 <li> ISO/IEC TR 10176:1998, Information technology -- Guidelines for the
30510 preparation of programming language standards.
30511 <li> ISO/IEC 10646-1:1993, Information technology -- Universal Multiple-Octet
30512 Coded Character Set (UCS) -- Part 1: Architecture and Basic Multilingual Plane.
30513 <li> ISO/IEC 10646-1/COR1:1996, Technical Corrigendum 1 to
30514 ISO/IEC 10646-1:1993.
30515 <li> ISO/IEC 10646-1/COR2:1998, Technical Corrigendum 2 to
30516 ISO/IEC 10646-1:1993.
30517 <li> ISO/IEC 10646-1/AMD1:1996, Amendment 1 to ISO/IEC 10646-1:1993
30518 Transformation Format for 16 planes of group 00 (UTF-16).
30519 <li> ISO/IEC 10646-1/AMD2:1996, Amendment 2 to ISO/IEC 10646-1:1993 UCS
30520 Transformation Format 8 (UTF-8).
30521 <li> ISO/IEC 10646-1/AMD3:1996, Amendment 3 to ISO/IEC 10646-1:1993.
30522 <li> ISO/IEC 10646-1/AMD4:1996, Amendment 4 to ISO/IEC 10646-1:1993.
30523 <li> ISO/IEC 10646-1/AMD5:1998, Amendment 5 to ISO/IEC 10646-1:1993 Hangul
30525 <li> ISO/IEC 10646-1/AMD6:1997, Amendment 6 to ISO/IEC 10646-1:1993
30527 <li> ISO/IEC 10646-1/AMD7:1997, Amendment 7 to ISO/IEC 10646-1:1993 33
30528 additional characters.
30529 <li> ISO/IEC 10646-1/AMD8:1997, Amendment 8 to ISO/IEC 10646-1:1993.
30530 <li> ISO/IEC 10646-1/AMD9:1997, Amendment 9 to ISO/IEC 10646-1:1993
30531 Identifiers for characters.
30532 <li> ISO/IEC 10646-1/AMD10:1998, Amendment 10 to ISO/IEC 10646-1:1993
30534 <li> ISO/IEC 10646-1/AMD11:1998, Amendment 11 to ISO/IEC 10646-1:1993
30535 Unified Canadian Aboriginal Syllabics.
30536 <li> ISO/IEC 10646-1/AMD12:1998, Amendment 12 to ISO/IEC 10646-1:1993
30538 <li> ISO/IEC 10967-1:1994, Information technology -- Language independent
30539 arithmetic -- Part 1: Integer and floating point arithmetic.
30540 <!--page 670 indent -1-->
30541 <li> ISO/IEC TR 19769:2004, Information technology -- Programming languages,
30542 their environments and system software interfaces -- Extensions for the
30543 programming language C to support new character data types.
30544 <li> ISO/IEC TR 24731-1:2007, Information technology -- Programming languages,
30545 their environments and system software interfaces -- Extensions to the C library
30546 -- Part 1: Bounds-checking interfaces.
30547 <!--page 671 indent 0-->
30550 <a name="Index" href="#Index"><h2>Index</h2></a>
30552 [^ x ^], <a href="#3.20">3.20</a> , (comma operator), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.17">6.5.17</a>
30553 , (comma punctuator), <a href="#6.5.2">6.5.2</a>, <a href="#6.7">6.7</a>, <a href="#6.7.2.1">6.7.2.1</a>, <a href="#6.7.2.2">6.7.2.2</a>,
30554 [_ x _], <a href="#3.21">3.21</a> <a href="#6.7.2.3">6.7.2.3</a>, <a href="#6.7.9">6.7.9</a>
30555 ! (logical negation operator), <a href="#6.5.3.3">6.5.3.3</a> - (subtraction operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.6">6.5.6</a>, <a href="#F.3">F.3</a>, <a href="#G.5.2">G.5.2</a>
30556 != (inequality operator), <a href="#6.5.9">6.5.9</a> - (unary minus operator), <a href="#6.5.3.3">6.5.3.3</a>, <a href="#F.3">F.3</a>
30557 # operator, <a href="#6.10.3.2">6.10.3.2</a> -- (postfix decrement operator), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.4">6.5.2.4</a>
30558 # preprocessing directive, <a href="#6.10.7">6.10.7</a> -- (prefix decrement operator), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.1">6.5.3.1</a>
30559 # punctuator, <a href="#6.10">6.10</a> -= (subtraction assignment operator), <a href="#6.5.16.2">6.5.16.2</a>
30560 ## operator, <a href="#6.10.3.3">6.10.3.3</a> -> (structure/union pointer operator), <a href="#6.5.2.3">6.5.2.3</a>
30561 #define preprocessing directive, <a href="#6.10.3">6.10.3</a> . (structure/union member operator), <a href="#6.3.2.1">6.3.2.1</a>,
30562 #elif preprocessing directive, <a href="#6.10.1">6.10.1</a> <a href="#6.5.2.3">6.5.2.3</a>
30563 #else preprocessing directive, <a href="#6.10.1">6.10.1</a> . punctuator, <a href="#6.7.9">6.7.9</a>
30564 #endif preprocessing directive, <a href="#6.10.1">6.10.1</a> ... (ellipsis punctuator), <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.10.3">6.10.3</a>
30565 #error preprocessing directive, <a href="#4">4</a>, <a href="#6.10.5">6.10.5</a> / (division operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#F.3">F.3</a>, <a href="#G.5.1">G.5.1</a>
30566 #if preprocessing directive, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, /* */ (comment delimiters), <a href="#6.4.9">6.4.9</a>
30567 <a href="#6.10.1">6.10.1</a>, <a href="#7.1.4">7.1.4</a> // (comment delimiter), <a href="#6.4.9">6.4.9</a>
30568 #ifdef preprocessing directive, <a href="#6.10.1">6.10.1</a> /= (division assignment operator), <a href="#6.5.16.2">6.5.16.2</a>
30569 #ifndef preprocessing directive, <a href="#6.10.1">6.10.1</a> : (colon punctuator), <a href="#6.7.2.1">6.7.2.1</a>
30570 #include preprocessing directive, <a href="#5.1.1.2">5.1.1.2</a>, :> (alternative spelling of ]), <a href="#6.4.6">6.4.6</a>
30571 <a href="#6.10.2">6.10.2</a> ; (semicolon punctuator), <a href="#6.7">6.7</a>, <a href="#6.7.2.1">6.7.2.1</a>, <a href="#6.8.3">6.8.3</a>,
30572 #line preprocessing directive, <a href="#6.10.4">6.10.4</a> <a href="#6.8.5">6.8.5</a>, <a href="#6.8.6">6.8.6</a>
30573 #pragma preprocessing directive, <a href="#6.10.6">6.10.6</a> < (less-than operator), <a href="#6.5.8">6.5.8</a>
30574 #undef preprocessing directive, <a href="#6.10.3.5">6.10.3.5</a>, <a href="#7.1.3">7.1.3</a>, <% (alternative spelling of {), <a href="#6.4.6">6.4.6</a>
30575 <a href="#7.1.4">7.1.4</a> <: (alternative spelling of [), <a href="#6.4.6">6.4.6</a>
30576 % (remainder operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a> << (left-shift operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a>
30577 %: (alternative spelling of #), <a href="#6.4.6">6.4.6</a> <<= (left-shift assignment operator), <a href="#6.5.16.2">6.5.16.2</a>
30578 %:%: (alternative spelling of ##), <a href="#6.4.6">6.4.6</a> <= (less-than-or-equal-to operator), <a href="#6.5.8">6.5.8</a>
30579 %= (remainder assignment operator), <a href="#6.5.16.2">6.5.16.2</a> <assert.h> header, <a href="#7.2">7.2</a>
30580 %> (alternative spelling of }), <a href="#6.4.6">6.4.6</a> <complex.h> header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>,
30581 & (address operator), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a> <a href="#7.3">7.3</a>, <a href="#7.24">7.24</a>, <a href="#7.30.1">7.30.1</a>, <a href="#G.6">G.6</a>, <a href="#J.5.17">J.5.17</a>
30582 & (bitwise AND operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.10">6.5.10</a> <ctype.h> header, <a href="#7.4">7.4</a>, <a href="#7.30.2">7.30.2</a>
30583 && (logical AND operator), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.13">6.5.13</a> <errno.h> header, <a href="#7.5">7.5</a>, <a href="#7.30.3">7.30.3</a>, <a href="#K.3.2">K.3.2</a>
30584 &= (bitwise AND assignment operator), <a href="#6.5.16.2">6.5.16.2</a> <fenv.h> header, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F">F</a>,
30585 ' ' (space character), <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a>, <a href="#7.4.1.3">7.4.1.3</a>, <a href="#H">H</a>
30586 <a href="#7.4.1.10">7.4.1.10</a>, <a href="#7.29.2.1.3">7.29.2.1.3</a> <float.h> header, <a href="#4">4</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.7">7.7</a>, <a href="#7.22.1.3">7.22.1.3</a>,
30587 ( ) (cast operator), <a href="#6.5.4">6.5.4</a> <a href="#7.28.4.1.1">7.28.4.1.1</a>
30588 ( ) (function-call operator), <a href="#6.5.2.2">6.5.2.2</a> <inttypes.h> header, <a href="#7.8">7.8</a>, <a href="#7.30.4">7.30.4</a>
30589 ( ) (parentheses punctuator), <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.8.4">6.8.4</a>, <a href="#6.8.5">6.8.5</a> <iso646.h> header, <a href="#4">4</a>, <a href="#7.9">7.9</a>
30590 ( ){ } (compound-literal operator), <a href="#6.5.2.5">6.5.2.5</a> <limits.h> header, <a href="#4">4</a>, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#6.2.5">6.2.5</a>, <a href="#7.10">7.10</a>
30591 * (asterisk punctuator), <a href="#6.7.6.1">6.7.6.1</a>, <a href="#6.7.6.2">6.7.6.2</a> <locale.h> header, <a href="#7.11">7.11</a>, <a href="#7.30.5">7.30.5</a>
30592 * (indirection operator), <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a> <math.h> header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.5">6.5</a>, <a href="#7.12">7.12</a>, <a href="#7.24">7.24</a>, <a href="#F">F</a>,
30593 * (multiplication operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#F.3">F.3</a>, <a href="#F.10">F.10</a>, <a href="#J.5.17">J.5.17</a>
30594 <a href="#G.5.1">G.5.1</a> <setjmp.h> header, <a href="#7.13">7.13</a>
30595 *= (multiplication assignment operator), <a href="#6.5.16.2">6.5.16.2</a> <signal.h> header, <a href="#7.14">7.14</a>, <a href="#7.30.6">7.30.6</a>
30596 + (addition operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a>, <stdalign.h> header, <a href="#4">4</a>, <a href="#7.15">7.15</a>
30597 <a href="#6.5.6">6.5.6</a>, <a href="#F.3">F.3</a>, <a href="#G.5.2">G.5.2</a> <stdarg.h> header, <a href="#4">4</a>, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#7.16">7.16</a>
30598 + (unary plus operator), <a href="#6.5.3.3">6.5.3.3</a> <stdatomic.h> header, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.17">7.17</a>
30599 ++ (postfix increment operator), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.4">6.5.2.4</a> <stdbool.h> header, <a href="#4">4</a>, <a href="#7.18">7.18</a>, <a href="#7.30.7">7.30.7</a>, <a href="#H">H</a>
30600 ++ (prefix increment operator), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.1">6.5.3.1</a> <stddef.h> header, <a href="#4">4</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.3.2.3">6.3.2.3</a>, <a href="#6.4.4.4">6.4.4.4</a>,
30601 += (addition assignment operator), <a href="#6.5.16.2">6.5.16.2</a>
30602 <!--page 672 indent 0-->
30603 <a href="#6.4.5">6.4.5</a>, <a href="#6.5.3.4">6.5.3.4</a>, <a href="#6.5.6">6.5.6</a>, <a href="#7.19">7.19</a>, <a href="#K.3.3">K.3.3</a> \x hexadecimal digits (hexadecimal-character
30604 <stdint.h> header, <a href="#4">4</a>, <a href="#5.2.4.2">5.2.4.2</a>, <a href="#6.10.1">6.10.1</a>, <a href="#7.8">7.8</a>, escape sequence), <a href="#6.4.4.4">6.4.4.4</a>
30605 <a href="#7.20">7.20</a>, <a href="#7.30.8">7.30.8</a>, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a> ^ (bitwise exclusive OR operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.11">6.5.11</a>
30606 <stdio.h> header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21">7.21</a>, <a href="#7.30.9">7.30.9</a>, <a href="#F">F</a>, ^= (bitwise exclusive OR assignment operator),
30607 <a href="#K.3.5">K.3.5</a> <a href="#6.5.16.2">6.5.16.2</a>
30608 <stdlib.h> header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.22">7.22</a>, <a href="#7.30.10">7.30.10</a>, <a href="#F">F</a>, __alignas_is_defined macro, <a href="#7.15">7.15</a>
30609 <a href="#K.3.1.4">K.3.1.4</a>, <a href="#K.3.6">K.3.6</a> __bool_true_false_are_defined
30610 <string.h> header, <a href="#7.23">7.23</a>, <a href="#7.30.11">7.30.11</a>, <a href="#K.3.7">K.3.7</a> macro, <a href="#7.18">7.18</a>
30611 <tgmath.h> header, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> __cplusplus macro, <a href="#6.10.8">6.10.8</a>
30612 <threads.h> header, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.25">7.25</a> __DATE__ macro, <a href="#6.10.8.1">6.10.8.1</a>
30613 <time.h> header, <a href="#7.26">7.26</a>, <a href="#K.3.8">K.3.8</a> __FILE__ macro, <a href="#6.10.8.1">6.10.8.1</a>, <a href="#7.2.1.1">7.2.1.1</a>
30614 <uchar.h> header, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#7.27">7.27</a> __func__ identifier, <a href="#6.4.2.2">6.4.2.2</a>, <a href="#7.2.1.1">7.2.1.1</a>
30615 <wchar.h> header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.28">7.28</a>, __LINE__ macro, <a href="#6.10.8.1">6.10.8.1</a>, <a href="#7.2.1.1">7.2.1.1</a>
30616 <a href="#7.30.12">7.30.12</a>, <a href="#F">F</a>, <a href="#K.3.9">K.3.9</a> __STDC_, <a href="#6.11.9">6.11.9</a>
30617 <wctype.h> header, <a href="#7.29">7.29</a>, <a href="#7.30.13">7.30.13</a> __STDC__ macro, <a href="#6.10.8.1">6.10.8.1</a>
30618 = (equal-sign punctuator), <a href="#6.7">6.7</a>, <a href="#6.7.2.2">6.7.2.2</a>, <a href="#6.7.9">6.7.9</a> __STDC_ANALYZABLE__ macro, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#L.1">L.1</a>
30619 = (simple assignment operator), <a href="#6.5.16.1">6.5.16.1</a> __STDC_HOSTED__ macro, <a href="#6.10.8.1">6.10.8.1</a>
30620 == (equality operator), <a href="#6.5.9">6.5.9</a> __STDC_IEC_559__ macro, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#F.1">F.1</a>
30621 > (greater-than operator), <a href="#6.5.8">6.5.8</a> __STDC_IEC_559_COMPLEX__ macro,
30622 >= (greater-than-or-equal-to operator), <a href="#6.5.8">6.5.8</a> <a href="#6.10.8.3">6.10.8.3</a>, <a href="#G.1">G.1</a>
30623 >> (right-shift operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a> __STDC_ISO_10646__ macro, <a href="#6.10.8.2">6.10.8.2</a>
30624 >>= (right-shift assignment operator), <a href="#6.5.16.2">6.5.16.2</a> __STDC_LIB_EXT1__ macro, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#K.2">K.2</a>
30625 ? : (conditional operator), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.15">6.5.15</a> __STDC_MB_MIGHT_NEQ_WC__ macro,
30626 ?? (trigraph sequences), <a href="#5.2.1.1">5.2.1.1</a> <a href="#6.10.8.2">6.10.8.2</a>, <a href="#7.19">7.19</a>
30627 [ ] (array subscript operator), <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a> __STDC_NO_COMPLEX__ macro, <a href="#6.10.8.3">6.10.8.3</a>,
30628 [ ] (brackets punctuator), <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.7.9">6.7.9</a> <a href="#7.3.1">7.3.1</a>
30629 \ (backslash character), <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4.4.4">6.4.4.4</a> __STDC_NO_THREADS__ macro, <a href="#6.10.8.3">6.10.8.3</a>,
30630 \ (escape character), <a href="#6.4.4.4">6.4.4.4</a> <a href="#7.17.1">7.17.1</a>, <a href="#7.25.1">7.25.1</a>
30631 \" (double-quote escape sequence), <a href="#6.4.4.4">6.4.4.4</a>, __STDC_NO_VLA__ macro, <a href="#6.10.8.3">6.10.8.3</a>
30632 <a href="#6.4.5">6.4.5</a>, <a href="#6.10.9">6.10.9</a> __STDC_UTF_16__ macro, <a href="#6.10.8.2">6.10.8.2</a>
30633 \\ (backslash escape sequence), <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.10.9">6.10.9</a> __STDC_UTF_32__ macro, <a href="#6.10.8.2">6.10.8.2</a>
30634 \' (single-quote escape sequence), <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a> __STDC_VERSION__ macro, <a href="#6.10.8.1">6.10.8.1</a>
30635 \0 (null character), <a href="#5.2.1">5.2.1</a>, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a> __STDC_WANT_LIB_EXT1__ macro, <a href="#K.3.1.1">K.3.1.1</a>
30636 padding of binary stream, <a href="#7.21.2">7.21.2</a> __TIME__ macro, <a href="#6.10.8.1">6.10.8.1</a>
30637 \? (question-mark escape sequence), <a href="#6.4.4.4">6.4.4.4</a> __VA_ARGS__ identifier, <a href="#6.10.3">6.10.3</a>, <a href="#6.10.3.1">6.10.3.1</a>
30638 \a (alert escape sequence), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a> _Alignas, <a href="#6.7.5">6.7.5</a>
30639 \b (backspace escape sequence), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a> _Atomic type qualifier, <a href="#6.7.3">6.7.3</a>
30640 \f (form-feed escape sequence), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, _Bool type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.2">6.3.1.2</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.17.1">7.17.1</a>,
30641 <a href="#7.4.1.10">7.4.1.10</a> <a href="#F.4">F.4</a>
30642 \n (new-line escape sequence), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, _Bool type conversions, <a href="#6.3.1.2">6.3.1.2</a>
30643 <a href="#7.4.1.10">7.4.1.10</a> _Complex types, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.3.1">7.3.1</a>, <a href="#G">G</a>
30644 \octal digits (octal-character escape sequence), _Complex_I macro, <a href="#7.3.1">7.3.1</a>
30645 <a href="#6.4.4.4">6.4.4.4</a> _Exit function, <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a>
30646 \r (carriage-return escape sequence), <a href="#5.2.2">5.2.2</a>, _Imaginary keyword, <a href="#G.2">G.2</a>
30647 <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.4.1.10">7.4.1.10</a> _Imaginary types, <a href="#7.3.1">7.3.1</a>, <a href="#G">G</a>
30648 \t (horizontal-tab escape sequence), <a href="#5.2.2">5.2.2</a>, _Imaginary_I macro, <a href="#7.3.1">7.3.1</a>, <a href="#G.6">G.6</a>
30649 <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.4.1.3">7.4.1.3</a>, <a href="#7.4.1.10">7.4.1.10</a>, <a href="#7.29.2.1.3">7.29.2.1.3</a> _IOFBF macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.5">7.21.5.5</a>, <a href="#7.21.5.6">7.21.5.6</a>
30650 \U (universal character names), <a href="#6.4.3">6.4.3</a> _IOLBF macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.6">7.21.5.6</a>
30651 \u (universal character names), <a href="#6.4.3">6.4.3</a> _IONBF macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.5">7.21.5.5</a>, <a href="#7.21.5.6">7.21.5.6</a>
30652 \v (vertical-tab escape sequence), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, _Noreturn, <a href="#6.7.4">6.7.4</a>
30653 <a href="#7.4.1.10">7.4.1.10</a> _Pragma operator, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.10.9">6.10.9</a>
30654 <!--page 673 indent 0-->
30655 _Static_assert, <a href="#6.7.10">6.7.10</a>, <a href="#7.2">7.2</a> allocated storage, order and contiguity, <a href="#7.22.3">7.22.3</a>
30656 _Thread_local storage-class specifier, <a href="#6.2.4">6.2.4</a>, and macro, <a href="#7.9">7.9</a>
30657 <a href="#6.7.1">6.7.1</a> AND operators
30658 { } (braces punctuator), <a href="#6.7.2.2">6.7.2.2</a>, <a href="#6.7.2.3">6.7.2.3</a>, <a href="#6.7.9">6.7.9</a>, bitwise (&), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.10">6.5.10</a>
30659 <a href="#6.8.2">6.8.2</a> bitwise assignment (&=), <a href="#6.5.16.2">6.5.16.2</a>
30660 { } (compound-literal operator), <a href="#6.5.2.5">6.5.2.5</a> logical (&&), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.13">6.5.13</a>
30661 | (bitwise inclusive OR operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.12">6.5.12</a> and_eq macro, <a href="#7.9">7.9</a>
30662 |= (bitwise inclusive OR assignment operator), anonymous structure, <a href="#6.7.2.1">6.7.2.1</a>
30663 <a href="#6.5.16.2">6.5.16.2</a> anonymous union, <a href="#6.7.2.1">6.7.2.1</a>
30664 || (logical OR operator), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.14">6.5.14</a> ANSI/IEEE 754, <a href="#F.1">F.1</a>
30665 ~ (bitwise complement operator), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.3.3">6.5.3.3</a> ANSI/IEEE 854, <a href="#F.1">F.1</a>
30666 argc (main function parameter), <a href="#5.1.2.2.1">5.1.2.2.1</a>
30667 abort function, <a href="#7.2.1.1">7.2.1.1</a>, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#7.21.3">7.21.3</a>, argument, <a href="#3.3">3.3</a>
30668 <a href="#7.22.4.1">7.22.4.1</a>, <a href="#7.25.3.6">7.25.3.6</a>, <a href="#K.3.6.1.2">K.3.6.1.2</a> array, <a href="#6.9.1">6.9.1</a>
30669 abort_handler_s function, <a href="#K.3.6.1.2">K.3.6.1.2</a> default promotions, <a href="#6.5.2.2">6.5.2.2</a>
30670 abs function, <a href="#7.22.6.1">7.22.6.1</a> function, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.9.1">6.9.1</a>
30671 absolute-value functions macro, substitution, <a href="#6.10.3.1">6.10.3.1</a>
30672 complex, <a href="#7.3.8">7.3.8</a>, <a href="#G.6.4">G.6.4</a> argument, complex, <a href="#7.3.9.1">7.3.9.1</a>
30673 integer, <a href="#7.8.2.1">7.8.2.1</a>, <a href="#7.22.6.1">7.22.6.1</a> argv (main function parameter), <a href="#5.1.2.2.1">5.1.2.2.1</a>
30674 real, <a href="#7.12.7">7.12.7</a>, <a href="#F.10.4">F.10.4</a> arithmetic constant expression, <a href="#6.6">6.6</a>
30675 abstract declarator, <a href="#6.7.7">6.7.7</a> arithmetic conversions, usual, see usual arithmetic
30676 abstract machine, <a href="#5.1.2.3">5.1.2.3</a> conversions
30677 access, <a href="#3.1">3.1</a>, <a href="#6.7.3">6.7.3</a>, <a href="#L.2.1">L.2.1</a> arithmetic operators
30678 accuracy, see floating-point accuracy additive, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.6">6.5.6</a>, <a href="#G.5.2">G.5.2</a>
30679 acos functions, <a href="#7.12.4.1">7.12.4.1</a>, <a href="#F.10.1.1">F.10.1.1</a> bitwise, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.3.3">6.5.3.3</a>, <a href="#6.5.10">6.5.10</a>, <a href="#6.5.11">6.5.11</a>, <a href="#6.5.12">6.5.12</a>
30680 acos type-generic macro, <a href="#7.24">7.24</a> increment and decrement, <a href="#6.5.2.4">6.5.2.4</a>, <a href="#6.5.3.1">6.5.3.1</a>
30681 acosh functions, <a href="#7.12.5.1">7.12.5.1</a>, <a href="#F.10.2.1">F.10.2.1</a> multiplicative, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#G.5.1">G.5.1</a>
30682 acosh type-generic macro, <a href="#7.24">7.24</a> shift, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a>
30683 acquire fence, <a href="#7.17.4">7.17.4</a> unary, <a href="#6.5.3.3">6.5.3.3</a>
30684 acquire operation, <a href="#5.1.2.4">5.1.2.4</a> arithmetic types, <a href="#6.2.5">6.2.5</a>
30685 active position, <a href="#5.2.2">5.2.2</a> arithmetic, pointer, <a href="#6.5.6">6.5.6</a>
30686 actual argument, <a href="#3.3">3.3</a> array
30687 actual parameter (deprecated), <a href="#3.3">3.3</a> argument, <a href="#6.9.1">6.9.1</a>
30688 addition assignment operator (+=), <a href="#6.5.16.2">6.5.16.2</a> declarator, <a href="#6.7.6.2">6.7.6.2</a>
30689 addition operator (+), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a>, initialization, <a href="#6.7.9">6.7.9</a>
30690 <a href="#6.5.6">6.5.6</a>, <a href="#F.3">F.3</a>, <a href="#G.5.2">G.5.2</a> multidimensional, <a href="#6.5.2.1">6.5.2.1</a>
30691 additive expressions, <a href="#6.5.6">6.5.6</a>, <a href="#G.5.2">G.5.2</a> parameter, <a href="#6.9.1">6.9.1</a>
30692 address constant, <a href="#6.6">6.6</a> storage order, <a href="#6.5.2.1">6.5.2.1</a>
30693 address operator (&), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a> subscript operator ([ ]), <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a>
30694 address-free, <a href="#7.17.5">7.17.5</a> subscripting, <a href="#6.5.2.1">6.5.2.1</a>
30695 aggregate initialization, <a href="#6.7.9">6.7.9</a> type, <a href="#6.2.5">6.2.5</a>
30696 aggregate types, <a href="#6.2.5">6.2.5</a> type conversion, <a href="#6.3.2.1">6.3.2.1</a>
30697 alert escape sequence (\a), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a> variable length, <a href="#6.7.6">6.7.6</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.10.8.3">6.10.8.3</a>
30698 aliasing, <a href="#6.5">6.5</a> arrow operator (->), <a href="#6.5.2.3">6.5.2.3</a>
30699 alignas macro, <a href="#7.15">7.15</a> as-if rule, <a href="#5.1.2.3">5.1.2.3</a>
30700 aligned_alloc function, <a href="#7.22.3">7.22.3</a>, <a href="#7.22.3.1">7.22.3.1</a> ASCII code set, <a href="#5.2.1.1">5.2.1.1</a>
30701 alignment, <a href="#3.2">3.2</a>, <a href="#6.2.8">6.2.8</a>, <a href="#7.22.3.1">7.22.3.1</a> asctime function, <a href="#7.26.3.1">7.26.3.1</a>
30702 pointer, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.2.3">6.3.2.3</a> asctime_s function, <a href="#K.3.8.2">K.3.8.2</a>, <a href="#K.3.8.2.1">K.3.8.2.1</a>
30703 structure/union member, <a href="#6.7.2.1">6.7.2.1</a> asin functions, <a href="#7.12.4.2">7.12.4.2</a>, <a href="#F.10.1.2">F.10.1.2</a>
30704 alignment specifier, <a href="#6.7.5">6.7.5</a> asin type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
30705 alignof operator, <a href="#6.5.3">6.5.3</a>, <a href="#6.5.3.4">6.5.3.4</a> asinh functions, <a href="#7.12.5.2">7.12.5.2</a>, <a href="#F.10.2.2">F.10.2.2</a>
30706 <!--page 674 indent 0-->
30707 asinh type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> atomic_is_lock_free generic function,
30708 asm keyword, <a href="#J.5.10">J.5.10</a> <a href="#7.17.5.1">7.17.5.1</a>
30709 assert macro, <a href="#7.2.1.1">7.2.1.1</a> ATOMIC_LLONG_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a>
30710 assert.h header, <a href="#7.2">7.2</a> atomic_load generic functions, <a href="#7.17.7.2">7.17.7.2</a>
30711 assignment ATOMIC_LONG_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a>
30712 compound, <a href="#6.5.16.2">6.5.16.2</a> ATOMIC_SHORT_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a>
30713 conversion, <a href="#6.5.16.1">6.5.16.1</a> atomic_signal_fence function, <a href="#7.17.4.2">7.17.4.2</a>
30714 expression, <a href="#6.5.16">6.5.16</a> atomic_store generic functions, <a href="#7.17.7.1">7.17.7.1</a>
30715 operators, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.16">6.5.16</a> atomic_thread_fence function, <a href="#7.17.4.1">7.17.4.1</a>
30716 simple, <a href="#6.5.16.1">6.5.16.1</a> ATOMIC_VAR_INIT macro, <a href="#7.17.2.1">7.17.2.1</a>
30717 associativity of operators, <a href="#6.5">6.5</a> ATOMIC_WCHAR_T_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a>
30718 asterisk punctuator (*), <a href="#6.7.6.1">6.7.6.1</a>, <a href="#6.7.6.2">6.7.6.2</a> atomics header, <a href="#7.17">7.17</a>
30719 at_quick_exit function, <a href="#7.22.4.2">7.22.4.2</a>, <a href="#7.22.4.3">7.22.4.3</a>, auto storage-class specifier, <a href="#6.7.1">6.7.1</a>, <a href="#6.9">6.9</a>
30720 <a href="#7.22.4.4">7.22.4.4</a>, <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a> automatic storage duration, <a href="#5.2.3">5.2.3</a>, <a href="#6.2.4">6.2.4</a>
30721 atan functions, <a href="#7.12.4.3">7.12.4.3</a>, <a href="#F.10.1.3">F.10.1.3</a>
30722 atan type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> backslash character (\), <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4.4.4">6.4.4.4</a>
30723 atan2 functions, <a href="#7.12.4.4">7.12.4.4</a>, <a href="#F.10.1.4">F.10.1.4</a> backslash escape sequence (\\), <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.10.9">6.10.9</a>
30724 atan2 type-generic macro, <a href="#7.24">7.24</a> backspace escape sequence (\b), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>
30725 atanh functions, <a href="#7.12.5.3">7.12.5.3</a>, <a href="#F.10.2.3">F.10.2.3</a> basic character set, <a href="#3.6">3.6</a>, <a href="#3.7.2">3.7.2</a>, <a href="#5.2.1">5.2.1</a>
30726 atanh type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> basic types, <a href="#6.2.5">6.2.5</a>
30727 atexit function, <a href="#7.22.4.2">7.22.4.2</a>, <a href="#7.22.4.3">7.22.4.3</a>, <a href="#7.22.4.4">7.22.4.4</a>, behavior, <a href="#3.4">3.4</a>
30728 <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a>, <a href="#J.5.13">J.5.13</a> binary streams, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.21.9.2">7.21.9.2</a>,
30729 atof function, <a href="#7.22.1">7.22.1</a>, <a href="#7.22.1.1">7.22.1.1</a> <a href="#7.21.9.4">7.21.9.4</a>
30730 atoi function, <a href="#7.22.1">7.22.1</a>, <a href="#7.22.1.2">7.22.1.2</a> bit, <a href="#3.5">3.5</a>
30731 atol function, <a href="#7.22.1">7.22.1</a>, <a href="#7.22.1.2">7.22.1.2</a> high order, <a href="#3.6">3.6</a>
30732 atoll function, <a href="#7.22.1">7.22.1</a>, <a href="#7.22.1.2">7.22.1.2</a> low order, <a href="#3.6">3.6</a>
30733 atomic lock-free macros, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.5">7.17.5</a> bit-field, <a href="#6.7.2.1">6.7.2.1</a>
30734 atomic operations, <a href="#5.1.2.4">5.1.2.4</a> bitand macro, <a href="#7.9">7.9</a>
30735 atomic types, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.2.5">6.2.5</a>, <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.3.2.1">6.3.2.1</a>, bitor macro, <a href="#7.9">7.9</a>
30736 <a href="#6.5.2.3">6.5.2.3</a>, <a href="#6.5.2.4">6.5.2.4</a>, <a href="#6.5.16.2">6.5.16.2</a>, <a href="#6.7.2.4">6.7.2.4</a>, <a href="#6.10.8.3">6.10.8.3</a>, bitwise operators, <a href="#6.5">6.5</a>
30737 <a href="#7.17.6">7.17.6</a> AND, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.10">6.5.10</a>
30738 atomic_address type, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.6">7.17.6</a> AND assignment (&=), <a href="#6.5.16.2">6.5.16.2</a>
30739 ATOMIC_ADDRESS_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a> complement (~), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.3.3">6.5.3.3</a>
30740 atomic_bool type, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.6">7.17.6</a> exclusive OR, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.11">6.5.11</a>
30741 ATOMIC_CHAR16_T_LOCK_FREE macro, exclusive OR assignment (^=), <a href="#6.5.16.2">6.5.16.2</a>
30742 <a href="#7.17.1">7.17.1</a> inclusive OR, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.12">6.5.12</a>
30743 ATOMIC_CHAR32_T_LOCK_FREE macro, inclusive OR assignment (|=), <a href="#6.5.16.2">6.5.16.2</a>
30744 <a href="#7.17.1">7.17.1</a> shift, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a>
30745 ATOMIC_CHAR_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a> blank character, <a href="#7.4.1.3">7.4.1.3</a>
30746 atomic_compare_exchange generic block, <a href="#6.8">6.8</a>, <a href="#6.8.2">6.8.2</a>, <a href="#6.8.4">6.8.4</a>, <a href="#6.8.5">6.8.5</a>
30747 functions, <a href="#7.17.7.4">7.17.7.4</a> block scope, <a href="#6.2.1">6.2.1</a>
30748 atomic_exchange generic functions, <a href="#7.17.7.3">7.17.7.3</a> block structure, <a href="#6.2.1">6.2.1</a>
30749 atomic_fetch and modify generic functions, bold type convention, <a href="#6.1">6.1</a>
30750 <a href="#7.17.7.5">7.17.7.5</a> bool macro, <a href="#7.18">7.18</a>
30751 atomic_flag type, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.8">7.17.8</a> boolean type, <a href="#6.3.1.2">6.3.1.2</a>
30752 atomic_flag_clear functions, <a href="#7.17.8.2">7.17.8.2</a> boolean type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.2">6.3.1.2</a>
30753 ATOMIC_FLAG_INIT macro, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.8">7.17.8</a> bounded undefined behavior, <a href="#L.2.2">L.2.2</a>
30754 atomic_flag_test_and_set functions, braces punctuator ({ }), <a href="#6.7.2.2">6.7.2.2</a>, <a href="#6.7.2.3">6.7.2.3</a>, <a href="#6.7.9">6.7.9</a>,
30755 <a href="#7.17.8.1">7.17.8.1</a> <a href="#6.8.2">6.8.2</a>
30756 atomic_init generic function, <a href="#7.17.2.2">7.17.2.2</a> brackets operator ([ ]), <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a>
30757 ATOMIC_INT_LOCK_FREE macro, <a href="#7.17.1">7.17.1</a> brackets punctuator ([ ]), <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.7.9">6.7.9</a>
30758 <!--page 675 indent 0-->
30759 branch cuts, <a href="#7.3.3">7.3.3</a> type-generic macro for, <a href="#7.24">7.24</a>
30760 break statement, <a href="#6.8.6.3">6.8.6.3</a> ccosh functions, <a href="#7.3.6.4">7.3.6.4</a>, <a href="#G.6.2.4">G.6.2.4</a>
30761 broken-down time, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.3">7.26.2.3</a>, <a href="#7.26.3">7.26.3</a>, type-generic macro for, <a href="#7.24">7.24</a>
30762 <a href="#7.26.3.1">7.26.3.1</a>, <a href="#7.26.3.3">7.26.3.3</a>, <a href="#7.26.3.4">7.26.3.4</a>, <a href="#7.26.3.5">7.26.3.5</a>, ceil functions, <a href="#7.12.9.1">7.12.9.1</a>, <a href="#F.10.6.1">F.10.6.1</a>
30763 <a href="#K.3.8.2.1">K.3.8.2.1</a>, <a href="#K.3.8.2.3">K.3.8.2.3</a>, <a href="#K.3.8.2.4">K.3.8.2.4</a> ceil type-generic macro, <a href="#7.24">7.24</a>
30764 bsearch function, <a href="#7.22.5">7.22.5</a>, <a href="#7.22.5.1">7.22.5.1</a> cerf function, <a href="#7.30.1">7.30.1</a>
30765 bsearch_s function, <a href="#K.3.6.3">K.3.6.3</a>, <a href="#K.3.6.3.1">K.3.6.3.1</a> cerfc function, <a href="#7.30.1">7.30.1</a>
30766 btowc function, <a href="#7.28.6.1.1">7.28.6.1.1</a> cexp functions, <a href="#7.3.7.1">7.3.7.1</a>, <a href="#G.6.3.1">G.6.3.1</a>
30767 BUFSIZ macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.5.5">7.21.5.5</a> type-generic macro for, <a href="#7.24">7.24</a>
30768 byte, <a href="#3.6">3.6</a>, <a href="#6.5.3.4">6.5.3.4</a> cexp2 function, <a href="#7.30.1">7.30.1</a>
30769 byte input/output functions, <a href="#7.21.1">7.21.1</a> cexpm1 function, <a href="#7.30.1">7.30.1</a>
30770 byte-oriented stream, <a href="#7.21.2">7.21.2</a> char type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.7.2">6.7.2</a>, <a href="#K.3.5.3.2">K.3.5.3.2</a>,
30771 <a href="#K.3.9.1.2">K.3.9.1.2</a>
30772 <a href="#C">C</a> program, <a href="#5.1.1.1">5.1.1.1</a> char type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.3.1.4">6.3.1.4</a>,
30773 c16rtomb function, <a href="#7.27.1.2">7.27.1.2</a> <a href="#6.3.1.8">6.3.1.8</a>
30774 c32rtomb function, <a href="#7.27.1.4">7.27.1.4</a> char16_t type, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#6.10.8.2">6.10.8.2</a>, <a href="#7.27">7.27</a>
30775 cabs functions, <a href="#7.3.8.1">7.3.8.1</a>, <a href="#G.6">G.6</a> char32_t type, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#6.10.8.2">6.10.8.2</a>, <a href="#7.27">7.27</a>
30776 type-generic macro for, <a href="#7.24">7.24</a> CHAR_BIT macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#6.7.2.1">6.7.2.1</a>
30777 cacos functions, <a href="#7.3.5.1">7.3.5.1</a>, <a href="#G.6.1.1">G.6.1.1</a> CHAR_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.11.2.1">7.11.2.1</a>
30778 type-generic macro for, <a href="#7.24">7.24</a> CHAR_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>
30779 cacosh functions, <a href="#7.3.6.1">7.3.6.1</a>, <a href="#G.6.2.1">G.6.2.1</a> character, <a href="#3.7">3.7</a>, <a href="#3.7.1">3.7.1</a>
30780 type-generic macro for, <a href="#7.24">7.24</a> character array initialization, <a href="#6.7.9">6.7.9</a>
30781 calendar time, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.2">7.26.2.2</a>, <a href="#7.26.2.3">7.26.2.3</a>, <a href="#7.26.2.4">7.26.2.4</a>, character case mapping functions, <a href="#7.4.2">7.4.2</a>
30782 <a href="#7.26.3.2">7.26.3.2</a>, <a href="#7.26.3.3">7.26.3.3</a>, <a href="#7.26.3.4">7.26.3.4</a>, <a href="#K.3.8.2.2">K.3.8.2.2</a>, wide character, <a href="#7.29.3.1">7.29.3.1</a>
30783 <a href="#K.3.8.2.3">K.3.8.2.3</a>, <a href="#K.3.8.2.4">K.3.8.2.4</a> extensible, <a href="#7.29.3.2">7.29.3.2</a>
30784 call by value, <a href="#6.5.2.2">6.5.2.2</a> character classification functions, <a href="#7.4.1">7.4.1</a>
30785 call_once function, <a href="#7.25.1">7.25.1</a>, <a href="#7.25.2.1">7.25.2.1</a> wide character, <a href="#7.29.2.1">7.29.2.1</a>
30786 calloc function, <a href="#7.22.3">7.22.3</a>, <a href="#7.22.3.2">7.22.3.2</a> extensible, <a href="#7.29.2.2">7.29.2.2</a>
30787 carg functions, <a href="#7.3.9.1">7.3.9.1</a>, <a href="#G.6">G.6</a> character constant, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4.4.4">6.4.4.4</a>
30788 carg type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> character display semantics, <a href="#5.2.2">5.2.2</a>
30789 carriage-return escape sequence (\r), <a href="#5.2.2">5.2.2</a>, character handling header, <a href="#7.4">7.4</a>, <a href="#7.11.1.1">7.11.1.1</a>
30790 <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.4.1.10">7.4.1.10</a> character input/output functions, <a href="#7.21.7">7.21.7</a>, <a href="#K.3.5.4">K.3.5.4</a>
30791 carries a dependency, <a href="#5.1.2.4">5.1.2.4</a> wide character, <a href="#7.28.3">7.28.3</a>
30792 case label, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.4.2">6.8.4.2</a> character sets, <a href="#5.2.1">5.2.1</a>
30793 case mapping functions character string literal, see string literal
30794 character, <a href="#7.4.2">7.4.2</a> character type conversion, <a href="#6.3.1.1">6.3.1.1</a>
30795 wide character, <a href="#7.29.3.1">7.29.3.1</a> character types, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.9">6.7.9</a>
30796 extensible, <a href="#7.29.3.2">7.29.3.2</a> cimag functions, <a href="#7.3.9.2">7.3.9.2</a>, <a href="#7.3.9.5">7.3.9.5</a>, <a href="#G.6">G.6</a>
30797 casin functions, <a href="#7.3.5.2">7.3.5.2</a>, <a href="#G.6">G.6</a> cimag type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
30798 type-generic macro for, <a href="#7.24">7.24</a> cis function, <a href="#G.6">G.6</a>
30799 casinh functions, <a href="#7.3.6.2">7.3.6.2</a>, <a href="#G.6.2.2">G.6.2.2</a> classification functions
30800 type-generic macro for, <a href="#7.24">7.24</a> character, <a href="#7.4.1">7.4.1</a>
30801 cast expression, <a href="#6.5.4">6.5.4</a> floating-point, <a href="#7.12.3">7.12.3</a>
30802 cast operator (( )), <a href="#6.5.4">6.5.4</a> wide character, <a href="#7.29.2.1">7.29.2.1</a>
30803 catan functions, <a href="#7.3.5.3">7.3.5.3</a>, <a href="#G.6">G.6</a> extensible, <a href="#7.29.2.2">7.29.2.2</a>
30804 type-generic macro for, <a href="#7.24">7.24</a> clearerr function, <a href="#7.21.10.1">7.21.10.1</a>
30805 catanh functions, <a href="#7.3.6.3">7.3.6.3</a>, <a href="#G.6.2.3">G.6.2.3</a> clgamma function, <a href="#7.30.1">7.30.1</a>
30806 type-generic macro for, <a href="#7.24">7.24</a> clock function, <a href="#7.26.2.1">7.26.2.1</a>
30807 cbrt functions, <a href="#7.12.7.1">7.12.7.1</a>, <a href="#F.10.4.1">F.10.4.1</a> clock_t type, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.1">7.26.2.1</a>
30808 cbrt type-generic macro, <a href="#7.24">7.24</a> CLOCKS_PER_SEC macro, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.1">7.26.2.1</a>
30809 ccos functions, <a href="#7.3.5.4">7.3.5.4</a>, <a href="#G.6">G.6</a> clog functions, <a href="#7.3.7.2">7.3.7.2</a>, <a href="#G.6.3.2">G.6.3.2</a>
30810 <!--page 676 indent 0-->
30811 type-generic macro for, <a href="#7.24">7.24</a> string, <a href="#7.23.3">7.23.3</a>, <a href="#K.3.7.2">K.3.7.2</a>
30812 clog10 function, <a href="#7.30.1">7.30.1</a> wide string, <a href="#7.28.4.3">7.28.4.3</a>, <a href="#K.3.9.2.2">K.3.9.2.2</a>
30813 clog1p function, <a href="#7.30.1">7.30.1</a> concatenation, preprocessing, see preprocessing
30814 clog2 function, <a href="#7.30.1">7.30.1</a> concatenation
30815 CMPLX macros, <a href="#7.3.9.3">7.3.9.3</a> conceptual models, <a href="#5.1">5.1</a>
30816 cnd_broadcast function, <a href="#7.25.3.1">7.25.3.1</a>, <a href="#7.25.3.5">7.25.3.5</a>, conditional features, <a href="#4">4</a>, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.10.8.3">6.10.8.3</a>,
30817 <a href="#7.25.3.6">7.25.3.6</a> <a href="#7.1.2">7.1.2</a>, <a href="#F.1">F.1</a>, <a href="#G.1">G.1</a>, <a href="#K.2">K.2</a>, <a href="#L.1">L.1</a>
30818 cnd_destroy function, <a href="#7.25.3.2">7.25.3.2</a> conditional inclusion, <a href="#6.10.1">6.10.1</a>
30819 cnd_init function, <a href="#7.25.3.3">7.25.3.3</a> conditional operator (? :), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.15">6.5.15</a>
30820 cnd_signal function, <a href="#7.25.3.4">7.25.3.4</a>, <a href="#7.25.3.5">7.25.3.5</a>, conflict, <a href="#5.1.2.4">5.1.2.4</a>
30821 <a href="#7.25.3.6">7.25.3.6</a> conformance, <a href="#4">4</a>
30822 cnd_t type, <a href="#7.25.1">7.25.1</a> conj functions, <a href="#7.3.9.4">7.3.9.4</a>, <a href="#G.6">G.6</a>
30823 cnd_timedwait function, <a href="#7.25.3.5">7.25.3.5</a> conj type-generic macro, <a href="#7.24">7.24</a>
30824 cnd_wait function, <a href="#7.25.3.3">7.25.3.3</a>, <a href="#7.25.3.6">7.25.3.6</a> const type qualifier, <a href="#6.7.3">6.7.3</a>
30825 collating sequences, <a href="#5.2.1">5.2.1</a> const-qualified type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.7.3">6.7.3</a>
30826 colon punctuator (:), <a href="#6.7.2.1">6.7.2.1</a> constant expression, <a href="#6.6">6.6</a>, <a href="#F.8.4">F.8.4</a>
30827 comma operator (,), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.17">6.5.17</a> constants, <a href="#6.4.4">6.4.4</a>
30828 comma punctuator (,), <a href="#6.5.2">6.5.2</a>, <a href="#6.7">6.7</a>, <a href="#6.7.2.1">6.7.2.1</a>, <a href="#6.7.2.2">6.7.2.2</a>, as primary expression, <a href="#6.5.1">6.5.1</a>
30829 <a href="#6.7.2.3">6.7.2.3</a>, <a href="#6.7.9">6.7.9</a> character, <a href="#6.4.4.4">6.4.4.4</a>
30830 command processor, <a href="#7.22.4.8">7.22.4.8</a> enumeration, <a href="#6.2.1">6.2.1</a>, <a href="#6.4.4.3">6.4.4.3</a>
30831 comment delimiters (/* */ and //), <a href="#6.4.9">6.4.9</a> floating, <a href="#6.4.4.2">6.4.4.2</a>
30832 comments, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.4">6.4</a>, <a href="#6.4.9">6.4.9</a> hexadecimal, <a href="#6.4.4.1">6.4.4.1</a>
30833 common extensions, <a href="#J.5">J.5</a> integer, <a href="#6.4.4.1">6.4.4.1</a>
30834 common initial sequence, <a href="#6.5.2.3">6.5.2.3</a> octal, <a href="#6.4.4.1">6.4.4.1</a>
30835 common real type, <a href="#6.3.1.8">6.3.1.8</a> constraint, <a href="#3.8">3.8</a>, <a href="#4">4</a>
30836 common warnings, <a href="#I">I</a> constraint_handler_t type, <a href="#K.3.6">K.3.6</a>
30837 comparison functions, <a href="#7.22.5">7.22.5</a>, <a href="#7.22.5.1">7.22.5.1</a>, <a href="#7.22.5.2">7.22.5.2</a>, consume operation, <a href="#5.1.2.4">5.1.2.4</a>
30838 <a href="#K.3.6.3">K.3.6.3</a>, <a href="#K.3.6.3.1">K.3.6.3.1</a>, <a href="#K.3.6.3.2">K.3.6.3.2</a> content of structure/union/enumeration, <a href="#6.7.2.3">6.7.2.3</a>
30839 string, <a href="#7.23.4">7.23.4</a> contiguity of allocated storage, <a href="#7.22.3">7.22.3</a>
30840 wide string, <a href="#7.28.4.4">7.28.4.4</a> continue statement, <a href="#6.8.6.2">6.8.6.2</a>
30841 comparison macros, <a href="#7.12.14">7.12.14</a> contracted expression, <a href="#6.5">6.5</a>, <a href="#7.12.2">7.12.2</a>, <a href="#F.7">F.7</a>
30842 comparison, pointer, <a href="#6.5.8">6.5.8</a> control character, <a href="#5.2.1">5.2.1</a>, <a href="#7.4">7.4</a>
30843 compatible type, <a href="#6.2.7">6.2.7</a>, <a href="#6.7.2">6.7.2</a>, <a href="#6.7.3">6.7.3</a>, <a href="#6.7.6">6.7.6</a> control wide character, <a href="#7.29.2">7.29.2</a>
30844 compl macro, <a href="#7.9">7.9</a> conversion, <a href="#6.3">6.3</a>
30845 complement operator (~), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.3.3">6.5.3.3</a> arithmetic operands, <a href="#6.3.1">6.3.1</a>
30846 complete type, <a href="#6.2.5">6.2.5</a> array argument, <a href="#6.9.1">6.9.1</a>
30847 complex macro, <a href="#7.3.1">7.3.1</a> array parameter, <a href="#6.9.1">6.9.1</a>
30848 complex numbers, <a href="#6.2.5">6.2.5</a>, <a href="#G">G</a> arrays, <a href="#6.3.2.1">6.3.2.1</a>
30849 complex type conversion, <a href="#6.3.1.6">6.3.1.6</a>, <a href="#6.3.1.7">6.3.1.7</a> boolean, <a href="#6.3.1.2">6.3.1.2</a>
30850 complex type domain, <a href="#6.2.5">6.2.5</a> boolean, characters, and integers, <a href="#6.3.1.1">6.3.1.1</a>
30851 complex types, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2">6.7.2</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#G">G</a> by assignment, <a href="#6.5.16.1">6.5.16.1</a>
30852 complex.h header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, by return statement, <a href="#6.8.6.4">6.8.6.4</a>
30853 <a href="#7.3">7.3</a>, <a href="#7.24">7.24</a>, <a href="#7.30.1">7.30.1</a>, <a href="#G.6">G.6</a>, <a href="#J.5.17">J.5.17</a> complex types, <a href="#6.3.1.6">6.3.1.6</a>
30854 compliance, see conformance explicit, <a href="#6.3">6.3</a>
30855 components of time, <a href="#7.26.1">7.26.1</a>, <a href="#K.3.8.1">K.3.8.1</a> function, <a href="#6.3.2.1">6.3.2.1</a>
30856 composite type, <a href="#6.2.7">6.2.7</a> function argument, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.9.1">6.9.1</a>
30857 compound assignment, <a href="#6.5.16.2">6.5.16.2</a> function designators, <a href="#6.3.2.1">6.3.2.1</a>
30858 compound literals, <a href="#6.5.2.5">6.5.2.5</a> function parameter, <a href="#6.9.1">6.9.1</a>
30859 compound statement, <a href="#6.8.2">6.8.2</a> imaginary, <a href="#G.4.1">G.4.1</a>
30860 compound-literal operator (( ){ }), <a href="#6.5.2.5">6.5.2.5</a> imaginary and complex, <a href="#G.4.3">G.4.3</a>
30861 concatenation functions implicit, <a href="#6.3">6.3</a>
30862 <!--page 677 indent 0-->
30863 lvalues, <a href="#6.3.2.1">6.3.2.1</a> csinh functions, <a href="#7.3.6.5">7.3.6.5</a>, <a href="#G.6.2.5">G.6.2.5</a>
30864 pointer, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.3.2.3">6.3.2.3</a> type-generic macro for, <a href="#7.24">7.24</a>
30865 real and complex, <a href="#6.3.1.7">6.3.1.7</a> csqrt functions, <a href="#7.3.8.3">7.3.8.3</a>, <a href="#G.6.4.2">G.6.4.2</a>
30866 real and imaginary, <a href="#G.4.2">G.4.2</a> type-generic macro for, <a href="#7.24">7.24</a>
30867 real floating and integer, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#F.3">F.3</a>, <a href="#F.4">F.4</a> ctan functions, <a href="#7.3.5.6">7.3.5.6</a>, <a href="#G.6">G.6</a>
30868 real floating types, <a href="#6.3.1.5">6.3.1.5</a>, <a href="#F.3">F.3</a> type-generic macro for, <a href="#7.24">7.24</a>
30869 signed and unsigned integers, <a href="#6.3.1.3">6.3.1.3</a> ctanh functions, <a href="#7.3.6.6">7.3.6.6</a>, <a href="#G.6.2.6">G.6.2.6</a>
30870 usual arithmetic, see usual arithmetic type-generic macro for, <a href="#7.24">7.24</a>
30871 conversions ctgamma function, <a href="#7.30.1">7.30.1</a>
30872 void type, <a href="#6.3.2.2">6.3.2.2</a> ctime function, <a href="#7.26.3.2">7.26.3.2</a>
30873 conversion functions ctime_s function, <a href="#K.3.8.2">K.3.8.2</a>, <a href="#K.3.8.2.2">K.3.8.2.2</a>
30874 multibyte/wide character, <a href="#7.22.7">7.22.7</a>, <a href="#K.3.6.4">K.3.6.4</a> ctype.h header, <a href="#7.4">7.4</a>, <a href="#7.30.2">7.30.2</a>
30875 extended, <a href="#7.28.6">7.28.6</a>, <a href="#K.3.9.3">K.3.9.3</a> current object, <a href="#6.7.9">6.7.9</a>
30876 restartable, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#K.3.9.3.1">K.3.9.3.1</a> CX_LIMITED_RANGE pragma, <a href="#6.10.6">6.10.6</a>, <a href="#7.3.4">7.3.4</a>
30877 multibyte/wide string, <a href="#7.22.8">7.22.8</a>, <a href="#K.3.6.5">K.3.6.5</a>
30878 restartable, <a href="#7.28.6.4">7.28.6.4</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a> data race, <a href="#5.1.2.4">5.1.2.4</a>, <a href="#7.1.4">7.1.4</a>, <a href="#7.22.2.1">7.22.2.1</a>, <a href="#7.22.4.6">7.22.4.6</a>,
30879 numeric, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.22.1">7.22.1</a> <a href="#7.23.5.8">7.23.5.8</a>, <a href="#7.23.6.2">7.23.6.2</a>, <a href="#7.26.3">7.26.3</a>, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.6.3">7.28.6.3</a>,
30880 wide string, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.28.4.1">7.28.4.1</a> <a href="#7.28.6.4">7.28.6.4</a>
30881 single byte/wide character, <a href="#7.28.6.1">7.28.6.1</a> data stream, see streams
30882 time, <a href="#7.26.3">7.26.3</a>, <a href="#K.3.8.2">K.3.8.2</a> date and time header, <a href="#7.26">7.26</a>, <a href="#K.3.8">K.3.8</a>
30883 wide character, <a href="#7.28.5">7.28.5</a> Daylight Saving Time, <a href="#7.26.1">7.26.1</a>
30884 conversion specifier, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, DBL_DECIMAL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30885 <a href="#7.28.2.2">7.28.2.2</a> DBL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30886 conversion state, <a href="#7.22.7">7.22.7</a>, <a href="#7.27.1">7.27.1</a>, <a href="#7.27.1.1">7.27.1.1</a>, DBL_EPSILON macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30887 <a href="#7.27.1.2">7.27.1.2</a>, <a href="#7.27.1.3">7.27.1.3</a>, <a href="#7.27.1.4">7.27.1.4</a>, <a href="#7.28.6">7.28.6</a>, DBL_HAS_SUBNORM macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30888 <a href="#7.28.6.2.1">7.28.6.2.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#7.28.6.3.2">7.28.6.3.2</a>, <a href="#7.28.6.3.3">7.28.6.3.3</a>, DBL_MANT_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30889 <a href="#7.28.6.4">7.28.6.4</a>, <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#7.28.6.4.2">7.28.6.4.2</a>, <a href="#K.3.6.4">K.3.6.4</a>, DBL_MAX macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30890 <a href="#K.3.9.3.1">K.3.9.3.1</a>, <a href="#K.3.9.3.1.1">K.3.9.3.1.1</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a>, <a href="#K.3.9.3.2.1">K.3.9.3.2.1</a>, DBL_MAX_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30891 <a href="#K.3.9.3.2.2">K.3.9.3.2.2</a> DBL_MAX_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30892 conversion state functions, <a href="#7.28.6.2">7.28.6.2</a> DBL_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30893 copying functions DBL_MIN_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30894 string, <a href="#7.23.2">7.23.2</a>, <a href="#K.3.7.1">K.3.7.1</a> DBL_MIN_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30895 wide string, <a href="#7.28.4.2">7.28.4.2</a>, <a href="#K.3.9.2.1">K.3.9.2.1</a> DBL_TRUE_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
30896 copysign functions, <a href="#7.3.9.5">7.3.9.5</a>, <a href="#7.12.11.1">7.12.11.1</a>, <a href="#F.3">F.3</a>, decimal constant, <a href="#6.4.4.1">6.4.4.1</a>
30897 <a href="#F.10.8.1">F.10.8.1</a> decimal digit, <a href="#5.2.1">5.2.1</a>
30898 copysign type-generic macro, <a href="#7.24">7.24</a> decimal-point character, <a href="#7.1.1">7.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a>
30899 correctly rounded result, <a href="#3.9">3.9</a> DECIMAL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21.6.1">7.21.6.1</a>,
30900 corresponding real type, <a href="#6.2.5">6.2.5</a> <a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#F.5">F.5</a>
30901 cos functions, <a href="#7.12.4.5">7.12.4.5</a>, <a href="#F.10.1.5">F.10.1.5</a> declaration specifiers, <a href="#6.7">6.7</a>
30902 cos type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> declarations, <a href="#6.7">6.7</a>
30903 cosh functions, <a href="#7.12.5.4">7.12.5.4</a>, <a href="#F.10.2.4">F.10.2.4</a> function, <a href="#6.7.6.3">6.7.6.3</a>
30904 cosh type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> pointer, <a href="#6.7.6.1">6.7.6.1</a>
30905 cpow functions, <a href="#7.3.8.2">7.3.8.2</a>, <a href="#G.6.4.1">G.6.4.1</a> structure/union, <a href="#6.7.2.1">6.7.2.1</a>
30906 type-generic macro for, <a href="#7.24">7.24</a> typedef, <a href="#6.7.8">6.7.8</a>
30907 cproj functions, <a href="#7.3.9.5">7.3.9.5</a>, <a href="#G.6">G.6</a> declarator, <a href="#6.7.6">6.7.6</a>
30908 cproj type-generic macro, <a href="#7.24">7.24</a> abstract, <a href="#6.7.7">6.7.7</a>
30909 creal functions, <a href="#7.3.9.6">7.3.9.6</a>, <a href="#G.6">G.6</a> declarator type derivation, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.6">6.7.6</a>
30910 creal type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> decrement operators, see arithmetic operators,
30911 critical undefined behavior, <a href="#L.2.3">L.2.3</a> increment and decrement
30912 csin functions, <a href="#7.3.5.5">7.3.5.5</a>, <a href="#G.6">G.6</a> default argument promotions, <a href="#6.5.2.2">6.5.2.2</a>
30913 type-generic macro for, <a href="#7.24">7.24</a> default initialization, <a href="#6.7.9">6.7.9</a>
30914 <!--page 678 indent 0-->
30915 default label, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.4.2">6.8.4.2</a> elif preprocessing directive, <a href="#6.10.1">6.10.1</a>
30916 define preprocessing directive, <a href="#6.10.3">6.10.3</a> ellipsis punctuator (...), <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.10.3">6.10.3</a>
30917 defined operator, <a href="#6.10.1">6.10.1</a>, <a href="#6.10.8">6.10.8</a> else preprocessing directive, <a href="#6.10.1">6.10.1</a>
30918 definition, <a href="#6.7">6.7</a> else statement, <a href="#6.8.4.1">6.8.4.1</a>
30919 function, <a href="#6.9.1">6.9.1</a> empty statement, <a href="#6.8.3">6.8.3</a>
30920 dependency-ordered before, <a href="#5.1.2.4">5.1.2.4</a> encoding error, <a href="#7.21.3">7.21.3</a>, <a href="#7.27.1.1">7.27.1.1</a>, <a href="#7.27.1.2">7.27.1.2</a>,
30921 derived declarator types, <a href="#6.2.5">6.2.5</a> <a href="#7.27.1.3">7.27.1.3</a>, <a href="#7.27.1.4">7.27.1.4</a>, <a href="#7.28.3.1">7.28.3.1</a>, <a href="#7.28.3.3">7.28.3.3</a>,
30922 derived types, <a href="#6.2.5">6.2.5</a> <a href="#7.28.6.3.2">7.28.6.3.2</a>, <a href="#7.28.6.3.3">7.28.6.3.3</a>, <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#7.28.6.4.2">7.28.6.4.2</a>,
30923 designated initializer, <a href="#6.7.9">6.7.9</a> <a href="#K.3.6.5.1">K.3.6.5.1</a>, <a href="#K.3.6.5.2">K.3.6.5.2</a>, <a href="#K.3.9.3.1.1">K.3.9.3.1.1</a>, <a href="#K.3.9.3.2.1">K.3.9.3.2.1</a>,
30924 destringizing, <a href="#6.10.9">6.10.9</a> <a href="#K.3.9.3.2.2">K.3.9.3.2.2</a>
30925 device input/output, <a href="#5.1.2.3">5.1.2.3</a> end-of-file, <a href="#7.28.1">7.28.1</a>
30926 diagnostic message, <a href="#3.10">3.10</a>, <a href="#5.1.1.3">5.1.1.3</a> end-of-file indicator, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.1">7.21.7.1</a>,
30927 diagnostics, <a href="#5.1.1.3">5.1.1.3</a> <a href="#7.21.7.5">7.21.7.5</a>, <a href="#7.21.7.6">7.21.7.6</a>, <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.21.9.2">7.21.9.2</a>,
30928 diagnostics header, <a href="#7.2">7.2</a> <a href="#7.21.9.3">7.21.9.3</a>, <a href="#7.21.10.1">7.21.10.1</a>, <a href="#7.21.10.2">7.21.10.2</a>, <a href="#7.28.3.1">7.28.3.1</a>,
30929 difftime function, <a href="#7.26.2.2">7.26.2.2</a> <a href="#7.28.3.10">7.28.3.10</a>
30930 digit, <a href="#5.2.1">5.2.1</a>, <a href="#7.4">7.4</a> end-of-file macro, see EOF macro
30931 digraphs, <a href="#6.4.6">6.4.6</a> end-of-line indicator, <a href="#5.2.1">5.2.1</a>
30932 direct input/output functions, <a href="#7.21.8">7.21.8</a> endif preprocessing directive, <a href="#6.10.1">6.10.1</a>
30933 display device, <a href="#5.2.2">5.2.2</a> enum type, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2">6.7.2</a>, <a href="#6.7.2.2">6.7.2.2</a>
30934 div function, <a href="#7.22.6.2">7.22.6.2</a> enumerated type, <a href="#6.2.5">6.2.5</a>
30935 div_t type, <a href="#7.22">7.22</a> enumeration, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2.2">6.7.2.2</a>
30936 division assignment operator (/=), <a href="#6.5.16.2">6.5.16.2</a> enumeration constant, <a href="#6.2.1">6.2.1</a>, <a href="#6.4.4.3">6.4.4.3</a>
30937 division operator (/), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#F.3">F.3</a>, <a href="#G.5.1">G.5.1</a> enumeration content, <a href="#6.7.2.3">6.7.2.3</a>
30938 do statement, <a href="#6.8.5.2">6.8.5.2</a> enumeration members, <a href="#6.7.2.2">6.7.2.2</a>
30939 documentation of implementation, <a href="#4">4</a> enumeration specifiers, <a href="#6.7.2.2">6.7.2.2</a>
30940 domain error, <a href="#7.12.1">7.12.1</a>, <a href="#7.12.4.1">7.12.4.1</a>, <a href="#7.12.4.2">7.12.4.2</a>, <a href="#7.12.4.4">7.12.4.4</a>, enumeration tag, <a href="#6.2.3">6.2.3</a>, <a href="#6.7.2.3">6.7.2.3</a>
30941 <a href="#7.12.5.1">7.12.5.1</a>, <a href="#7.12.5.3">7.12.5.3</a>, <a href="#7.12.6.5">7.12.6.5</a>, <a href="#7.12.6.7">7.12.6.7</a>, enumerator, <a href="#6.7.2.2">6.7.2.2</a>
30942 <a href="#7.12.6.8">7.12.6.8</a>, <a href="#7.12.6.9">7.12.6.9</a>, <a href="#7.12.6.10">7.12.6.10</a>, <a href="#7.12.6.11">7.12.6.11</a>, environment, <a href="#5">5</a>
30943 <a href="#7.12.7.4">7.12.7.4</a>, <a href="#7.12.7.5">7.12.7.5</a>, <a href="#7.12.8.4">7.12.8.4</a>, <a href="#7.12.9.5">7.12.9.5</a>, environment functions, <a href="#7.22.4">7.22.4</a>, <a href="#K.3.6.2">K.3.6.2</a>
30944 <a href="#7.12.9.7">7.12.9.7</a>, <a href="#7.12.10.1">7.12.10.1</a>, <a href="#7.12.10.2">7.12.10.2</a>, <a href="#7.12.10.3">7.12.10.3</a> environment list, <a href="#7.22.4.6">7.22.4.6</a>, <a href="#K.3.6.2.1">K.3.6.2.1</a>
30945 dot operator (.), <a href="#6.5.2.3">6.5.2.3</a> environmental considerations, <a href="#5.2">5.2</a>
30946 double _Complex type, <a href="#6.2.5">6.2.5</a> environmental limits, <a href="#5.2.4">5.2.4</a>, <a href="#7.13.1.1">7.13.1.1</a>, <a href="#7.21.2">7.21.2</a>,
30947 double _Complex type conversion, <a href="#6.3.1.6">6.3.1.6</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.4.4">7.21.4.4</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.22.2.1">7.22.2.1</a>, <a href="#7.22.4.2">7.22.4.2</a>,
30948 <a href="#6.3.1.7">6.3.1.7</a>, <a href="#6.3.1.8">6.3.1.8</a> <a href="#7.22.4.3">7.22.4.3</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a>
30949 double _Imaginary type, <a href="#G.2">G.2</a> EOF macro, <a href="#7.4">7.4</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.1">7.21.5.1</a>, <a href="#7.21.5.2">7.21.5.2</a>,
30950 double type, <a href="#6.2.5">6.2.5</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.21.6.7">7.21.6.7</a>, <a href="#7.21.6.9">7.21.6.9</a>, <a href="#7.21.6.11">7.21.6.11</a>,
30951 <a href="#7.28.2.2">7.28.2.2</a>, <a href="#F.2">F.2</a> <a href="#7.21.6.14">7.21.6.14</a>, <a href="#7.21.7.1">7.21.7.1</a>, <a href="#7.21.7.3">7.21.7.3</a>, <a href="#7.21.7.4">7.21.7.4</a>,
30952 double type conversion, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.5">6.3.1.5</a>, <a href="#6.3.1.7">6.3.1.7</a>, <a href="#7.21.7.5">7.21.7.5</a>, <a href="#7.21.7.6">7.21.7.6</a>, <a href="#7.21.7.8">7.21.7.8</a>, <a href="#7.21.7.9">7.21.7.9</a>,
30953 <a href="#6.3.1.8">6.3.1.8</a> <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.28.1">7.28.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#7.28.2.4">7.28.2.4</a>,
30954 double-precision arithmetic, <a href="#5.1.2.3">5.1.2.3</a> <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.8">7.28.2.8</a>, <a href="#7.28.2.10">7.28.2.10</a>, <a href="#7.28.2.12">7.28.2.12</a>,
30955 double-quote escape sequence (\"), <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.28.3.4">7.28.3.4</a>, <a href="#7.28.6.1.1">7.28.6.1.1</a>, <a href="#7.28.6.1.2">7.28.6.1.2</a>, <a href="#K.3.5.3.7">K.3.5.3.7</a>,
30956 <a href="#6.4.5">6.4.5</a>, <a href="#6.10.9">6.10.9</a> <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>,
30957 double_t type, <a href="#7.12">7.12</a>, <a href="#J.5.6">J.5.6</a> <a href="#K.3.9.1.5">K.3.9.1.5</a>, <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a>,
30958 <a href="#K.3.9.1.14">K.3.9.1.14</a>
30959 EDOM macro, <a href="#7.5">7.5</a>, <a href="#7.12.1">7.12.1</a>, see also domain error equal-sign punctuator (=), <a href="#6.7">6.7</a>, <a href="#6.7.2.2">6.7.2.2</a>, <a href="#6.7.9">6.7.9</a>
30960 effective type, <a href="#6.5">6.5</a> equal-to operator, see equality operator
30961 EILSEQ macro, <a href="#7.5">7.5</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.27.1.1">7.27.1.1</a>, <a href="#7.27.1.2">7.27.1.2</a>, equality expressions, <a href="#6.5.9">6.5.9</a>
30962 <a href="#7.27.1.3">7.27.1.3</a>, <a href="#7.27.1.4">7.27.1.4</a>, <a href="#7.28.3.1">7.28.3.1</a>, <a href="#7.28.3.3">7.28.3.3</a>, equality operator (==), <a href="#6.5.9">6.5.9</a>
30963 <a href="#7.28.6.3.2">7.28.6.3.2</a>, <a href="#7.28.6.3.3">7.28.6.3.3</a>, <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#7.28.6.4.2">7.28.6.4.2</a>, ERANGE macro, <a href="#7.5">7.5</a>, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.12.1">7.12.1</a>,
30964 see also encoding error <a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>, see
30965 element type, <a href="#6.2.5">6.2.5</a> also range error, pole error
30966 <!--page 679 indent 0-->
30967 erf functions, <a href="#7.12.8.1">7.12.8.1</a>, <a href="#F.10.5.1">F.10.5.1</a> exp2 functions, <a href="#7.12.6.2">7.12.6.2</a>, <a href="#F.10.3.2">F.10.3.2</a>
30968 erf type-generic macro, <a href="#7.24">7.24</a> exp2 type-generic macro, <a href="#7.24">7.24</a>
30969 erfc functions, <a href="#7.12.8.2">7.12.8.2</a>, <a href="#F.10.5.2">F.10.5.2</a> explicit conversion, <a href="#6.3">6.3</a>
30970 erfc type-generic macro, <a href="#7.24">7.24</a> expm1 functions, <a href="#7.12.6.3">7.12.6.3</a>, <a href="#F.10.3.3">F.10.3.3</a>
30971 errno macro, <a href="#7.1.3">7.1.3</a>, <a href="#7.3.2">7.3.2</a>, <a href="#7.5">7.5</a>, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, expm1 type-generic macro, <a href="#7.24">7.24</a>
30972 <a href="#7.12.1">7.12.1</a>, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.9.3">7.21.9.3</a>, <a href="#7.21.10.4">7.21.10.4</a>, exponent part, <a href="#6.4.4.2">6.4.4.2</a>
30973 <a href="#7.22.1">7.22.1</a>, <a href="#7.22.1.3">7.22.1.3</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.23.6.2">7.23.6.2</a>, <a href="#7.27.1.1">7.27.1.1</a>, exponential functions
30974 <a href="#7.27.1.2">7.27.1.2</a>, <a href="#7.27.1.3">7.27.1.3</a>, <a href="#7.27.1.4">7.27.1.4</a>, <a href="#7.28.3.1">7.28.3.1</a>, complex, <a href="#7.3.7">7.3.7</a>, <a href="#G.6.3">G.6.3</a>
30975 <a href="#7.28.3.3">7.28.3.3</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>, <a href="#7.28.6.3.2">7.28.6.3.2</a>, real, <a href="#7.12.6">7.12.6</a>, <a href="#F.10.3">F.10.3</a>
30976 <a href="#7.28.6.3.3">7.28.6.3.3</a>, <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#7.28.6.4.2">7.28.6.4.2</a>, <a href="#J.5.17">J.5.17</a>, expression, <a href="#6.5">6.5</a>
30977 <a href="#K.3.1.3">K.3.1.3</a>, <a href="#K.3.7.4.2">K.3.7.4.2</a> assignment, <a href="#6.5.16">6.5.16</a>
30978 errno.h header, <a href="#7.5">7.5</a>, <a href="#7.30.3">7.30.3</a>, <a href="#K.3.2">K.3.2</a> cast, <a href="#6.5.4">6.5.4</a>
30979 errno_t type, <a href="#K.3.2">K.3.2</a>, <a href="#K.3.5">K.3.5</a>, <a href="#K.3.6">K.3.6</a>, <a href="#K.3.6.1.1">K.3.6.1.1</a>, constant, <a href="#6.6">6.6</a>
30980 <a href="#K.3.7">K.3.7</a>, <a href="#K.3.8">K.3.8</a>, <a href="#K.3.9">K.3.9</a> evaluation, <a href="#5.1.2.3">5.1.2.3</a>
30981 error full, <a href="#6.8">6.8</a>
30982 domain, see domain error order of evaluation, see order of evaluation
30983 encoding, see encoding error parenthesized, <a href="#6.5.1">6.5.1</a>
30984 pole, see pole error primary, <a href="#6.5.1">6.5.1</a>
30985 range, see range error unary, <a href="#6.5.3">6.5.3</a>
30986 error conditions, <a href="#7.12.1">7.12.1</a> expression statement, <a href="#6.8.3">6.8.3</a>
30987 error functions, <a href="#7.12.8">7.12.8</a>, <a href="#F.10.5">F.10.5</a> extended alignment, <a href="#6.2.8">6.2.8</a>
30988 error indicator, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.1">7.21.7.1</a>, extended character set, <a href="#3.7.2">3.7.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#5.2.1.2">5.2.1.2</a>
30989 <a href="#7.21.7.3">7.21.7.3</a>, <a href="#7.21.7.5">7.21.7.5</a>, <a href="#7.21.7.6">7.21.7.6</a>, <a href="#7.21.7.7">7.21.7.7</a>, extended characters, <a href="#5.2.1">5.2.1</a>
30990 <a href="#7.21.7.8">7.21.7.8</a>, <a href="#7.21.9.2">7.21.9.2</a>, <a href="#7.21.10.1">7.21.10.1</a>, <a href="#7.21.10.3">7.21.10.3</a>, extended integer types, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.4.4.1">6.4.4.1</a>,
30991 <a href="#7.28.3.1">7.28.3.1</a>, <a href="#7.28.3.3">7.28.3.3</a> <a href="#7.20">7.20</a>
30992 error preprocessing directive, <a href="#4">4</a>, <a href="#6.10.5">6.10.5</a> extended multibyte/wide character conversion
30993 error-handling functions, <a href="#7.21.10">7.21.10</a>, <a href="#7.23.6.2">7.23.6.2</a>, utilities, <a href="#7.28.6">7.28.6</a>, <a href="#K.3.9.3">K.3.9.3</a>
30994 <a href="#K.3.7.4.2">K.3.7.4.2</a>, <a href="#K.3.7.4.3">K.3.7.4.3</a> extensible wide character case mapping functions,
30995 escape character (\), <a href="#6.4.4.4">6.4.4.4</a> <a href="#7.29.3.2">7.29.3.2</a>
30996 escape sequences, <a href="#5.2.1">5.2.1</a>, <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.11.4">6.11.4</a> extensible wide character classification functions,
30997 evaluation format, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#7.12">7.12</a> <a href="#7.29.2.2">7.29.2.2</a>
30998 evaluation method, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.5">6.5</a>, <a href="#F.8.5">F.8.5</a> extern storage-class specifier, <a href="#6.2.2">6.2.2</a>, <a href="#6.7.1">6.7.1</a>
30999 evaluation of expression, <a href="#5.1.2.3">5.1.2.3</a> external definition, <a href="#6.9">6.9</a>
31000 evaluation order, see order of evaluation external identifiers, underscore, <a href="#7.1.3">7.1.3</a>
31001 exceptional condition, <a href="#6.5">6.5</a> external linkage, <a href="#6.2.2">6.2.2</a>
31002 excess precision, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a> external name, <a href="#6.4.2.1">6.4.2.1</a>
31003 excess range, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a> external object definitions, <a href="#6.9.2">6.9.2</a>
31004 exclusive OR operators
31005 bitwise (^), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.11">6.5.11</a> fabs functions, <a href="#7.12.7.2">7.12.7.2</a>, <a href="#F.3">F.3</a>, <a href="#F.10.4.2">F.10.4.2</a>
31006 bitwise assignment (^=), <a href="#6.5.16.2">6.5.16.2</a> fabs type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
31007 executable program, <a href="#5.1.1.1">5.1.1.1</a> false macro, <a href="#7.18">7.18</a>
31008 execution character set, <a href="#5.2.1">5.2.1</a> fclose function, <a href="#7.21.5.1">7.21.5.1</a>
31009 execution environment, <a href="#5">5</a>, <a href="#5.1.2">5.1.2</a>, see also fdim functions, <a href="#7.12.12.1">7.12.12.1</a>, <a href="#F.10.9.1">F.10.9.1</a>
31010 environmental limits fdim type-generic macro, <a href="#7.24">7.24</a>
31011 execution sequence, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.8">6.8</a> FE_ALL_EXCEPT macro, <a href="#7.6">7.6</a>
31012 exit function, <a href="#5.1.2.2.3">5.1.2.2.3</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.22">7.22</a>, <a href="#7.22.4.4">7.22.4.4</a>, FE_DFL_ENV macro, <a href="#7.6">7.6</a>
31013 <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a> FE_DIVBYZERO macro, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a>
31014 EXIT_FAILURE macro, <a href="#7.22">7.22</a>, <a href="#7.22.4.4">7.22.4.4</a> FE_DOWNWARD macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a>
31015 EXIT_SUCCESS macro, <a href="#7.22">7.22</a>, <a href="#7.22.4.4">7.22.4.4</a> FE_INEXACT macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a>
31016 exp functions, <a href="#7.12.6.1">7.12.6.1</a>, <a href="#F.10.3.1">F.10.3.1</a> FE_INVALID macro, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a>
31017 exp type-generic macro, <a href="#7.24">7.24</a> FE_OVERFLOW macro, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a>
31018 <!--page 680 indent 0-->
31019 FE_TONEAREST macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a> float _Complex type conversion, <a href="#6.3.1.6">6.3.1.6</a>,
31020 FE_TOWARDZERO macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a> <a href="#6.3.1.7">6.3.1.7</a>, <a href="#6.3.1.8">6.3.1.8</a>
31021 FE_UNDERFLOW macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a> float _Imaginary type, <a href="#G.2">G.2</a>
31022 FE_UPWARD macro, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a> float type, <a href="#6.2.5">6.2.5</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#6.7.2">6.7.2</a>, <a href="#F.2">F.2</a>
31023 feclearexcept function, <a href="#7.6.2">7.6.2</a>, <a href="#7.6.2.1">7.6.2.1</a>, <a href="#F.3">F.3</a> float type conversion, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.5">6.3.1.5</a>, <a href="#6.3.1.7">6.3.1.7</a>,
31024 fegetenv function, <a href="#7.6.4.1">7.6.4.1</a>, <a href="#7.6.4.3">7.6.4.3</a>, <a href="#7.6.4.4">7.6.4.4</a>, <a href="#F.3">F.3</a> <a href="#6.3.1.8">6.3.1.8</a>
31025 fegetexceptflag function, <a href="#7.6.2">7.6.2</a>, <a href="#7.6.2.2">7.6.2.2</a>, <a href="#F.3">F.3</a> float.h header, <a href="#4">4</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.7">7.7</a>, <a href="#7.22.1.3">7.22.1.3</a>,
31026 fegetround function, <a href="#7.6">7.6</a>, <a href="#7.6.3.1">7.6.3.1</a>, <a href="#F.3">F.3</a> <a href="#7.28.4.1.1">7.28.4.1.1</a>
31027 feholdexcept function, <a href="#7.6.4.2">7.6.4.2</a>, <a href="#7.6.4.3">7.6.4.3</a>, float_t type, <a href="#7.12">7.12</a>, <a href="#J.5.6">J.5.6</a>
31028 <a href="#7.6.4.4">7.6.4.4</a>, <a href="#F.3">F.3</a> floating constant, <a href="#6.4.4.2">6.4.4.2</a>
31029 fence, <a href="#5.1.2.4">5.1.2.4</a> floating suffix, f or <a href="#F">F</a>, <a href="#6.4.4.2">6.4.4.2</a>
31030 fences, <a href="#7.17.4">7.17.4</a> floating type conversion, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.5">6.3.1.5</a>, <a href="#6.3.1.7">6.3.1.7</a>,
31031 fenv.h header, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F">F</a>, <a href="#H">H</a> <a href="#F.3">F.3</a>, <a href="#F.4">F.4</a>
31032 FENV_ACCESS pragma, <a href="#6.10.6">6.10.6</a>, <a href="#7.6.1">7.6.1</a>, <a href="#F.8">F.8</a>, <a href="#F.9">F.9</a>, floating types, <a href="#6.2.5">6.2.5</a>, <a href="#6.11.1">6.11.1</a>
31033 <a href="#F.10">F.10</a> floating-point accuracy, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#6.5">6.5</a>,
31034 fenv_t type, <a href="#7.6">7.6</a> <a href="#7.22.1.3">7.22.1.3</a>, <a href="#F.5">F.5</a>, see also contracted expression
31035 feof function, <a href="#7.21.10.2">7.21.10.2</a> floating-point arithmetic functions, <a href="#7.12">7.12</a>, <a href="#F.10">F.10</a>
31036 feraiseexcept function, <a href="#7.6.2">7.6.2</a>, <a href="#7.6.2.3">7.6.2.3</a>, <a href="#F.3">F.3</a> floating-point classification functions, <a href="#7.12.3">7.12.3</a>
31037 ferror function, <a href="#7.21.10.3">7.21.10.3</a> floating-point control mode, <a href="#7.6">7.6</a>, <a href="#F.8.6">F.8.6</a>
31038 fesetenv function, <a href="#7.6.4.3">7.6.4.3</a>, <a href="#F.3">F.3</a> floating-point environment, <a href="#7.6">7.6</a>, <a href="#F.8">F.8</a>, <a href="#F.8.6">F.8.6</a>
31039 fesetexceptflag function, <a href="#7.6.2">7.6.2</a>, <a href="#7.6.2.4">7.6.2.4</a>, <a href="#F.3">F.3</a> floating-point exception, <a href="#7.6">7.6</a>, <a href="#7.6.2">7.6.2</a>, <a href="#F.10">F.10</a>
31040 fesetround function, <a href="#7.6">7.6</a>, <a href="#7.6.3.2">7.6.3.2</a>, <a href="#F.3">F.3</a> floating-point number, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.2.5">6.2.5</a>
31041 fetestexcept function, <a href="#7.6.2">7.6.2</a>, <a href="#7.6.2.5">7.6.2.5</a>, <a href="#F.3">F.3</a> floating-point rounding mode, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31042 feupdateenv function, <a href="#7.6.4.2">7.6.4.2</a>, <a href="#7.6.4.4">7.6.4.4</a>, <a href="#F.3">F.3</a> floating-point status flag, <a href="#7.6">7.6</a>, <a href="#F.8.6">F.8.6</a>
31043 fexcept_t type, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a> floor functions, <a href="#7.12.9.2">7.12.9.2</a>, <a href="#F.10.6.2">F.10.6.2</a>
31044 fflush function, <a href="#7.21.5.2">7.21.5.2</a>, <a href="#7.21.5.3">7.21.5.3</a> floor type-generic macro, <a href="#7.24">7.24</a>
31045 fgetc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.7.1">7.21.7.1</a>, FLT_DECIMAL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31046 <a href="#7.21.7.5">7.21.7.5</a>, <a href="#7.21.8.1">7.21.8.1</a> FLT_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31047 fgetpos function, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.9.1">7.21.9.1</a>, <a href="#7.21.9.3">7.21.9.3</a> FLT_EPSILON macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31048 fgets function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.2">7.21.7.2</a>, <a href="#K.3.5.4.1">K.3.5.4.1</a> FLT_EVAL_METHOD macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.6">6.6</a>, <a href="#7.12">7.12</a>,
31049 fgetwc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.28.3.1">7.28.3.1</a>, <a href="#F.10.11">F.10.11</a>
31050 <a href="#7.28.3.6">7.28.3.6</a> FLT_HAS_SUBNORM macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31051 fgetws function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.2">7.28.3.2</a> FLT_MANT_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31052 field width, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a> FLT_MAX macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31053 file, <a href="#7.21.3">7.21.3</a> FLT_MAX_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31054 access functions, <a href="#7.21.5">7.21.5</a>, <a href="#K.3.5.2">K.3.5.2</a> FLT_MAX_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31055 name, <a href="#7.21.3">7.21.3</a> FLT_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31056 operations, <a href="#7.21.4">7.21.4</a>, <a href="#K.3.5.1">K.3.5.1</a> FLT_MIN_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31057 position indicator, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.3">7.21.3</a>, FLT_MIN_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31058 <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.1">7.21.7.1</a>, <a href="#7.21.7.3">7.21.7.3</a>, <a href="#7.21.7.10">7.21.7.10</a>, FLT_RADIX macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.22.1.3">7.22.1.3</a>,
31059 <a href="#7.21.8.1">7.21.8.1</a>, <a href="#7.21.8.2">7.21.8.2</a>, <a href="#7.21.9.1">7.21.9.1</a>, <a href="#7.21.9.2">7.21.9.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.4.1.1">7.28.4.1.1</a>
31060 <a href="#7.21.9.3">7.21.9.3</a>, <a href="#7.21.9.4">7.21.9.4</a>, <a href="#7.21.9.5">7.21.9.5</a>, <a href="#7.28.3.1">7.28.3.1</a>, FLT_ROUNDS macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.6">7.6</a>, <a href="#F.3">F.3</a>
31061 <a href="#7.28.3.3">7.28.3.3</a>, <a href="#7.28.3.10">7.28.3.10</a> FLT_TRUE_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31062 positioning functions, <a href="#7.21.9">7.21.9</a> fma functions, <a href="#7.12">7.12</a>, <a href="#7.12.13.1">7.12.13.1</a>, <a href="#F.10.10.1">F.10.10.1</a>
31063 file scope, <a href="#6.2.1">6.2.1</a>, <a href="#6.9">6.9</a> fma type-generic macro, <a href="#7.24">7.24</a>
31064 FILE type, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> fmax functions, <a href="#7.12.12.2">7.12.12.2</a>, <a href="#F.10.9.2">F.10.9.2</a>
31065 FILENAME_MAX macro, <a href="#7.21.1">7.21.1</a> fmax type-generic macro, <a href="#7.24">7.24</a>
31066 flags, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a>, see also floating-point fmin functions, <a href="#7.12.12.3">7.12.12.3</a>, <a href="#F.10.9.3">F.10.9.3</a>
31067 status flag fmin type-generic macro, <a href="#7.24">7.24</a>
31068 flexible array member, <a href="#6.7.2.1">6.7.2.1</a> fmod functions, <a href="#7.12.10.1">7.12.10.1</a>, <a href="#F.10.7.1">F.10.7.1</a>
31069 float _Complex type, <a href="#6.2.5">6.2.5</a> fmod type-generic macro, <a href="#7.24">7.24</a>
31070 <!--page 681 indent 0-->
31071 fopen function, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.5.4">7.21.5.4</a>, <a href="#K.3.5.2.1">K.3.5.2.1</a> <a href="#K.3.5.3.7">K.3.5.3.7</a>, <a href="#K.3.5.3.9">K.3.5.3.9</a>
31072 FOPEN_MAX macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.4.3">7.21.4.3</a>, fseek function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.10">7.21.7.10</a>,
31073 <a href="#K.3.5.1.1">K.3.5.1.1</a> <a href="#7.21.9.2">7.21.9.2</a>, <a href="#7.21.9.4">7.21.9.4</a>, <a href="#7.21.9.5">7.21.9.5</a>, <a href="#7.28.3.10">7.28.3.10</a>
31074 fopen_s function, <a href="#K.3.5.1.1">K.3.5.1.1</a>, <a href="#K.3.5.2.1">K.3.5.2.1</a>, fsetpos function, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.10">7.21.7.10</a>,
31075 <a href="#K.3.5.2.2">K.3.5.2.2</a> <a href="#7.21.9.1">7.21.9.1</a>, <a href="#7.21.9.3">7.21.9.3</a>, <a href="#7.28.3.10">7.28.3.10</a>
31076 for statement, <a href="#6.8.5">6.8.5</a>, <a href="#6.8.5.3">6.8.5.3</a> ftell function, <a href="#7.21.9.2">7.21.9.2</a>, <a href="#7.21.9.4">7.21.9.4</a>
31077 form-feed character, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a> full declarator, <a href="#6.7.6">6.7.6</a>
31078 form-feed escape sequence (\f), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, full expression, <a href="#6.8">6.8</a>
31079 <a href="#7.4.1.10">7.4.1.10</a> fully buffered stream, <a href="#7.21.3">7.21.3</a>
31080 formal argument (deprecated), <a href="#3.16">3.16</a> function
31081 formal parameter, <a href="#3.16">3.16</a> argument, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.9.1">6.9.1</a>
31082 formatted input/output functions, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.21.6">7.21.6</a>, body, <a href="#6.9.1">6.9.1</a>
31083 <a href="#K.3.5.3">K.3.5.3</a> call, <a href="#6.5.2.2">6.5.2.2</a>
31084 wide character, <a href="#7.28.2">7.28.2</a>, <a href="#K.3.9.1">K.3.9.1</a> library, <a href="#7.1.4">7.1.4</a>
31085 fortran keyword, <a href="#J.5.9">J.5.9</a> declarator, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.11.6">6.11.6</a>
31086 forward reference, <a href="#3.11">3.11</a> definition, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.9.1">6.9.1</a>, <a href="#6.11.7">6.11.7</a>
31087 FP_CONTRACT pragma, <a href="#6.5">6.5</a>, <a href="#6.10.6">6.10.6</a>, <a href="#7.12.2">7.12.2</a>, see designator, <a href="#6.3.2.1">6.3.2.1</a>
31088 also contracted expression image, <a href="#5.2.3">5.2.3</a>
31089 FP_FAST_FMA macro, <a href="#7.12">7.12</a> inline, <a href="#6.7.4">6.7.4</a>
31090 FP_FAST_FMAF macro, <a href="#7.12">7.12</a> library, <a href="#5.1.1.1">5.1.1.1</a>, <a href="#7.1.4">7.1.4</a>
31091 FP_FAST_FMAL macro, <a href="#7.12">7.12</a> name length, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.11.3">6.11.3</a>
31092 FP_ILOGB0 macro, <a href="#7.12">7.12</a>, <a href="#7.12.6.5">7.12.6.5</a> no-return, <a href="#6.7.4">6.7.4</a>
31093 FP_ILOGBNAN macro, <a href="#7.12">7.12</a>, <a href="#7.12.6.5">7.12.6.5</a> parameter, <a href="#5.1.2.2.1">5.1.2.2.1</a>, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.7">6.7</a>, <a href="#6.9.1">6.9.1</a>
31094 FP_INFINITE macro, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a> prototype, <a href="#5.1.2.2.1">5.1.2.2.1</a>, <a href="#6.2.1">6.2.1</a>, <a href="#6.2.7">6.2.7</a>, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.7">6.7</a>,
31095 FP_NAN macro, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a> <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.9.1">6.9.1</a>, <a href="#6.11.6">6.11.6</a>, <a href="#6.11.7">6.11.7</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.12">7.12</a>
31096 FP_NORMAL macro, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a> prototype scope, <a href="#6.2.1">6.2.1</a>, <a href="#6.7.6.2">6.7.6.2</a>
31097 FP_SUBNORMAL macro, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a> recursive call, <a href="#6.5.2.2">6.5.2.2</a>
31098 FP_ZERO macro, <a href="#7.12">7.12</a>, <a href="#F.3">F.3</a> return, <a href="#6.8.6.4">6.8.6.4</a>, <a href="#F.6">F.6</a>
31099 fpclassify macro, <a href="#7.12.3.1">7.12.3.1</a>, <a href="#F.3">F.3</a> scope, <a href="#6.2.1">6.2.1</a>
31100 fpos_t type, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a> type, <a href="#6.2.5">6.2.5</a>
31101 fprintf function, <a href="#7.8.1">7.8.1</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.1">7.21.6.1</a>, type conversion, <a href="#6.3.2.1">6.3.2.1</a>
31102 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.21.6.3">7.21.6.3</a>, <a href="#7.21.6.5">7.21.6.5</a>, <a href="#7.21.6.6">7.21.6.6</a>, function specifiers, <a href="#6.7.4">6.7.4</a>
31103 <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#F.3">F.3</a>, <a href="#K.3.5.3.1">K.3.5.3.1</a> function type, <a href="#6.2.5">6.2.5</a>
31104 fprintf_s function, <a href="#K.3.5.3.1">K.3.5.3.1</a> function-call operator (( )), <a href="#6.5.2.2">6.5.2.2</a>
31105 fputc function, <a href="#5.2.2">5.2.2</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.7.3">7.21.7.3</a>, function-like macro, <a href="#6.10.3">6.10.3</a>
31106 <a href="#7.21.7.7">7.21.7.7</a>, <a href="#7.21.8.2">7.21.8.2</a> fundamental alignment, <a href="#6.2.8">6.2.8</a>
31107 fputs function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.4">7.21.7.4</a> future directions
31108 fputwc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.28.3.3">7.28.3.3</a>, language, <a href="#6.11">6.11</a>
31109 <a href="#7.28.3.8">7.28.3.8</a> library, <a href="#7.30">7.30</a>
31110 fputws function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.4">7.28.3.4</a> fwide function, <a href="#7.21.2">7.21.2</a>, <a href="#7.28.3.5">7.28.3.5</a>
31111 fread function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.8.1">7.21.8.1</a> fwprintf function, <a href="#7.8.1">7.8.1</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.2">7.21.6.2</a>,
31112 free function, <a href="#7.22.3.3">7.22.3.3</a>, <a href="#7.22.3.5">7.22.3.5</a> <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#7.28.2.3">7.28.2.3</a>, <a href="#7.28.2.5">7.28.2.5</a>,
31113 freestanding execution environment, <a href="#4">4</a>, <a href="#5.1.2">5.1.2</a>, <a href="#7.28.2.11">7.28.2.11</a>, <a href="#K.3.9.1.1">K.3.9.1.1</a>
31114 <a href="#5.1.2.1">5.1.2.1</a> fwprintf_s function, <a href="#K.3.9.1.1">K.3.9.1.1</a>
31115 freopen function, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.5.4">7.21.5.4</a> fwrite function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.8.2">7.21.8.2</a>
31116 freopen_s function, <a href="#K.3.5.2.2">K.3.5.2.2</a> fwscanf function, <a href="#7.8.1">7.8.1</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.2">7.28.2.2</a>,
31117 frexp functions, <a href="#7.12.6.4">7.12.6.4</a>, <a href="#F.10.3.4">F.10.3.4</a> <a href="#7.28.2.4">7.28.2.4</a>, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.12">7.28.2.12</a>, <a href="#7.28.3.10">7.28.3.10</a>,
31118 frexp type-generic macro, <a href="#7.24">7.24</a> <a href="#K.3.9.1.2">K.3.9.1.2</a>
31119 fscanf function, <a href="#7.8.1">7.8.1</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, fwscanf_s function, <a href="#K.3.9.1.2">K.3.9.1.2</a>, <a href="#K.3.9.1.5">K.3.9.1.5</a>,
31120 <a href="#7.21.6.4">7.21.6.4</a>, <a href="#7.21.6.7">7.21.6.7</a>, <a href="#7.21.6.9">7.21.6.9</a>, <a href="#F.3">F.3</a>, <a href="#K.3.5.3.2">K.3.5.3.2</a> <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.14">K.3.9.1.14</a>
31121 fscanf_s function, <a href="#K.3.5.3.2">K.3.5.3.2</a>, <a href="#K.3.5.3.4">K.3.5.3.4</a>,
31122 <!--page 682 indent 0-->
31123 gamma functions, <a href="#7.12.8">7.12.8</a>, <a href="#F.10.5">F.10.5</a> name spaces, <a href="#6.2.3">6.2.3</a>
31124 general utilities, <a href="#7.22">7.22</a>, <a href="#K.3.6">K.3.6</a> reserved, <a href="#6.4.1">6.4.1</a>, <a href="#7.1.3">7.1.3</a>, <a href="#K.3.1.2">K.3.1.2</a>
31125 wide string, <a href="#7.28.4">7.28.4</a>, <a href="#K.3.9.2">K.3.9.2</a> scope, <a href="#6.2.1">6.2.1</a>
31126 general wide string utilities, <a href="#7.28.4">7.28.4</a>, <a href="#K.3.9.2">K.3.9.2</a> type, <a href="#6.2.5">6.2.5</a>
31127 generic parameters, <a href="#7.24">7.24</a> identifier list, <a href="#6.7.6">6.7.6</a>
31128 generic selection, <a href="#6.5.1.1">6.5.1.1</a> identifier nondigit, <a href="#6.4.2.1">6.4.2.1</a>
31129 getc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.5">7.21.7.5</a>, <a href="#7.21.7.6">7.21.7.6</a> IEC 559, <a href="#F.1">F.1</a>
31130 getchar function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.6">7.21.7.6</a> IEC 60559, <a href="#2">2</a>, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.3.3">7.3.3</a>,
31131 getenv function, <a href="#7.22.4.6">7.22.4.6</a> <a href="#7.6">7.6</a>, <a href="#7.6.4.2">7.6.4.2</a>, <a href="#7.12.1">7.12.1</a>, <a href="#7.12.10.2">7.12.10.2</a>, <a href="#7.12.14">7.12.14</a>, <a href="#F">F</a>, <a href="#G">G</a>,
31132 getenv_s function, <a href="#K.3.6.2.1">K.3.6.2.1</a> <a href="#H.1">H.1</a>
31133 gets function, <a href="#K.3.5.4.1">K.3.5.4.1</a> IEEE 754, <a href="#F.1">F.1</a>
31134 gets_s function, <a href="#K.3.5.4.1">K.3.5.4.1</a> IEEE 854, <a href="#F.1">F.1</a>
31135 getwc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.6">7.28.3.6</a>, <a href="#7.28.3.7">7.28.3.7</a> IEEE floating-point arithmetic standard, see
31136 getwchar function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.7">7.28.3.7</a> IEC 60559, ANSI/IEEE 754,
31137 gmtime function, <a href="#7.26.3.3">7.26.3.3</a> ANSI/IEEE 854
31138 gmtime_s function, <a href="#K.3.8.2.3">K.3.8.2.3</a> if preprocessing directive, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>,
31139 goto statement, <a href="#6.2.1">6.2.1</a>, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.6.1">6.8.6.1</a> <a href="#6.10.1">6.10.1</a>, <a href="#7.1.4">7.1.4</a>
31140 graphic characters, <a href="#5.2.1">5.2.1</a> if statement, <a href="#6.8.4.1">6.8.4.1</a>
31141 greater-than operator (>), <a href="#6.5.8">6.5.8</a> ifdef preprocessing directive, <a href="#6.10.1">6.10.1</a>
31142 greater-than-or-equal-to operator (>=), <a href="#6.5.8">6.5.8</a> ifndef preprocessing directive, <a href="#6.10.1">6.10.1</a>
31143 ignore_handler_s function, <a href="#K.3.6.1.3">K.3.6.1.3</a>
31144 happens before, <a href="#5.1.2.4">5.1.2.4</a> ilogb functions, <a href="#7.12">7.12</a>, <a href="#7.12.6.5">7.12.6.5</a>, <a href="#F.10.3.5">F.10.3.5</a>
31145 header, <a href="#5.1.1.1">5.1.1.1</a>, <a href="#7.1.2">7.1.2</a>, see also standard headers ilogb type-generic macro, <a href="#7.24">7.24</a>
31146 header names, <a href="#6.4">6.4</a>, <a href="#6.4.7">6.4.7</a>, <a href="#6.10.2">6.10.2</a> imaginary macro, <a href="#7.3.1">7.3.1</a>, <a href="#G.6">G.6</a>
31147 hexadecimal constant, <a href="#6.4.4.1">6.4.4.1</a> imaginary numbers, <a href="#G">G</a>
31148 hexadecimal digit, <a href="#6.4.4.1">6.4.4.1</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#6.4.4.4">6.4.4.4</a> imaginary type domain, <a href="#G.2">G.2</a>
31149 hexadecimal prefix, <a href="#6.4.4.1">6.4.4.1</a> imaginary types, <a href="#G">G</a>
31150 hexadecimal-character escape sequence imaxabs function, <a href="#7.8.2.1">7.8.2.1</a>
31151 (\x hexadecimal digits), <a href="#6.4.4.4">6.4.4.4</a> imaxdiv function, <a href="#7.8">7.8</a>, <a href="#7.8.2.2">7.8.2.2</a>
31152 high-order bit, <a href="#3.6">3.6</a> imaxdiv_t type, <a href="#7.8">7.8</a>
31153 horizontal-tab character, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a> implementation, <a href="#3.12">3.12</a>
31154 horizontal-tab escape sequence (\r), <a href="#7.29.2.1.3">7.29.2.1.3</a> implementation limit, <a href="#3.13">3.13</a>, <a href="#4">4</a>, <a href="#5.2.4.2">5.2.4.2</a>, <a href="#6.4.2.1">6.4.2.1</a>,
31155 horizontal-tab escape sequence (\t), <a href="#5.2.2">5.2.2</a>, <a href="#6.7.6">6.7.6</a>, <a href="#6.8.4.2">6.8.4.2</a>, <a href="#E">E</a>, see also environmental
31156 <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.4.1.3">7.4.1.3</a>, <a href="#7.4.1.10">7.4.1.10</a> limits
31157 hosted execution environment, <a href="#4">4</a>, <a href="#5.1.2">5.1.2</a>, <a href="#5.1.2.2">5.1.2.2</a> implementation-defined behavior, <a href="#3.4.1">3.4.1</a>, <a href="#4">4</a>, <a href="#J.3">J.3</a>
31158 HUGE_VAL macro, <a href="#7.12">7.12</a>, <a href="#7.12.1">7.12.1</a>, <a href="#7.22.1.3">7.22.1.3</a>, implementation-defined value, <a href="#3.19.1">3.19.1</a>
31159 <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#F.10">F.10</a> implicit conversion, <a href="#6.3">6.3</a>
31160 HUGE_VALF macro, <a href="#7.12">7.12</a>, <a href="#7.12.1">7.12.1</a>, <a href="#7.22.1.3">7.22.1.3</a>, implicit initialization, <a href="#6.7.9">6.7.9</a>
31161 <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#F.10">F.10</a> include preprocessing directive, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.10.2">6.10.2</a>
31162 HUGE_VALL macro, <a href="#7.12">7.12</a>, <a href="#7.12.1">7.12.1</a>, <a href="#7.22.1.3">7.22.1.3</a>, inclusive OR operators
31163 <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#F.10">F.10</a> bitwise (|), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.12">6.5.12</a>
31164 hyperbolic functions bitwise assignment (|=), <a href="#6.5.16.2">6.5.16.2</a>
31165 complex, <a href="#7.3.6">7.3.6</a>, <a href="#G.6.2">G.6.2</a> incomplete type, <a href="#6.2.5">6.2.5</a>
31166 real, <a href="#7.12.5">7.12.5</a>, <a href="#F.10.2">F.10.2</a> increment operators, see arithmetic operators,
31167 hypot functions, <a href="#7.12.7.3">7.12.7.3</a>, <a href="#F.10.4.3">F.10.4.3</a> increment and decrement
31168 hypot type-generic macro, <a href="#7.24">7.24</a> indeterminate value, <a href="#3.19.2">3.19.2</a>
31169 indeterminately sequenced, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.5.2.2">6.5.2.2</a>,
31170 <a href="#I">I</a> macro, <a href="#7.3.1">7.3.1</a>, <a href="#7.3.9.5">7.3.9.5</a>, <a href="#G.6">G.6</a> <a href="#6.5.2.4">6.5.2.4</a>, <a href="#6.5.16.2">6.5.16.2</a>, see also sequenced before,
31171 identifier, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.5.1">6.5.1</a> unsequenced
31172 linkage, see linkage indirection operator (*), <a href="#6.5.2.1">6.5.2.1</a>, <a href="#6.5.3.2">6.5.3.2</a>
31173 maximum length, <a href="#6.4.2.1">6.4.2.1</a> inequality operator (!=), <a href="#6.5.9">6.5.9</a>
31174 <!--page 683 indent 0-->
31175 infinitary, <a href="#7.12.1">7.12.1</a> extended, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.4.4.1">6.4.4.1</a>, <a href="#7.20">7.20</a>
31176 INFINITY macro, <a href="#7.3.9.5">7.3.9.5</a>, <a href="#7.12">7.12</a>, <a href="#F.2.1">F.2.1</a> inter-thread happens before, <a href="#5.1.2.4">5.1.2.4</a>
31177 initial position, <a href="#5.2.2">5.2.2</a> interactive device, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.5.3">7.21.5.3</a>
31178 initial shift state, <a href="#5.2.1.2">5.2.1.2</a> internal linkage, <a href="#6.2.2">6.2.2</a>
31179 initialization, <a href="#5.1.2">5.1.2</a>, <a href="#6.2.4">6.2.4</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.5">6.5.2.5</a>, <a href="#6.7.9">6.7.9</a>, internal name, <a href="#6.4.2.1">6.4.2.1</a>
31180 <a href="#F.8.5">F.8.5</a> interrupt, <a href="#5.2.3">5.2.3</a>
31181 in blocks, <a href="#6.8">6.8</a> INTMAX_C macro, <a href="#7.20.4.2">7.20.4.2</a>
31182 initializer, <a href="#6.7.9">6.7.9</a> INTMAX_MAX macro, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.20.2.5">7.20.2.5</a>
31183 permitted form, <a href="#6.6">6.6</a> INTMAX_MIN macro, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.20.2.5">7.20.2.5</a>
31184 string literal, <a href="#6.3.2.1">6.3.2.1</a> intmax_t type, <a href="#7.20.1.5">7.20.1.5</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>,
31185 inline, <a href="#6.7.4">6.7.4</a> <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31186 inner scope, <a href="#6.2.1">6.2.1</a> INTN_C macros, <a href="#7.20.4.1">7.20.4.1</a>
31187 input failure, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.8">7.28.2.8</a>, <a href="#7.28.2.10">7.28.2.10</a>, INTN_MAX macros, <a href="#7.20.2.1">7.20.2.1</a>
31188 <a href="#K.3.5.3.2">K.3.5.3.2</a>, <a href="#K.3.5.3.4">K.3.5.3.4</a>, <a href="#K.3.5.3.7">K.3.5.3.7</a>, <a href="#K.3.5.3.9">K.3.5.3.9</a>, INTN_MIN macros, <a href="#7.20.2.1">7.20.2.1</a>
31189 <a href="#K.3.5.3.11">K.3.5.3.11</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>, <a href="#K.3.9.1.5">K.3.9.1.5</a>, intN_t types, <a href="#7.20.1.1">7.20.1.1</a>
31190 <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a>, <a href="#K.3.9.1.14">K.3.9.1.14</a> INTPTR_MAX macro, <a href="#7.20.2.4">7.20.2.4</a>
31191 input/output functions INTPTR_MIN macro, <a href="#7.20.2.4">7.20.2.4</a>
31192 character, <a href="#7.21.7">7.21.7</a>, <a href="#K.3.5.4">K.3.5.4</a> intptr_t type, <a href="#7.20.1.4">7.20.1.4</a>
31193 direct, <a href="#7.21.8">7.21.8</a> inttypes.h header, <a href="#7.8">7.8</a>, <a href="#7.30.4">7.30.4</a>
31194 formatted, <a href="#7.21.6">7.21.6</a>, <a href="#K.3.5.3">K.3.5.3</a> isalnum function, <a href="#7.4.1.1">7.4.1.1</a>, <a href="#7.4.1.9">7.4.1.9</a>, <a href="#7.4.1.10">7.4.1.10</a>
31195 wide character, <a href="#7.28.2">7.28.2</a>, <a href="#K.3.9.1">K.3.9.1</a> isalpha function, <a href="#7.4.1.1">7.4.1.1</a>, <a href="#7.4.1.2">7.4.1.2</a>
31196 wide character, <a href="#7.28.3">7.28.3</a> isblank function, <a href="#7.4.1.3">7.4.1.3</a>
31197 formatted, <a href="#7.28.2">7.28.2</a>, <a href="#K.3.9.1">K.3.9.1</a> iscntrl function, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.4">7.4.1.4</a>, <a href="#7.4.1.7">7.4.1.7</a>,
31198 input/output header, <a href="#7.21">7.21</a>, <a href="#K.3.5">K.3.5</a> <a href="#7.4.1.11">7.4.1.11</a>
31199 input/output, device, <a href="#5.1.2.3">5.1.2.3</a> isdigit function, <a href="#7.4.1.1">7.4.1.1</a>, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.5">7.4.1.5</a>,
31200 int type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.4.4.1">6.4.4.1</a>, <a href="#6.7.2">6.7.2</a> <a href="#7.4.1.7">7.4.1.7</a>, <a href="#7.4.1.11">7.4.1.11</a>, <a href="#7.11.1.1">7.11.1.1</a>
31201 int type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.3.1.4">6.3.1.4</a>, isfinite macro, <a href="#7.12.3.2">7.12.3.2</a>, <a href="#F.3">F.3</a>
31202 <a href="#6.3.1.8">6.3.1.8</a> isgraph function, <a href="#7.4.1.6">7.4.1.6</a>
31203 INT_FASTN_MAX macros, <a href="#7.20.2.3">7.20.2.3</a> isgreater macro, <a href="#7.12.14.1">7.12.14.1</a>, <a href="#F.3">F.3</a>
31204 INT_FASTN_MIN macros, <a href="#7.20.2.3">7.20.2.3</a> isgreaterequal macro, <a href="#7.12.14.2">7.12.14.2</a>, <a href="#F.3">F.3</a>
31205 int_fastN_t types, <a href="#7.20.1.3">7.20.1.3</a> isinf macro, <a href="#7.12.3.3">7.12.3.3</a>
31206 INT_LEASTN_MAX macros, <a href="#7.20.2.2">7.20.2.2</a> isless macro, <a href="#7.12.14.3">7.12.14.3</a>, <a href="#F.3">F.3</a>
31207 INT_LEASTN_MIN macros, <a href="#7.20.2.2">7.20.2.2</a> islessequal macro, <a href="#7.12.14.4">7.12.14.4</a>, <a href="#F.3">F.3</a>
31208 int_leastN_t types, <a href="#7.20.1.2">7.20.1.2</a> islessgreater macro, <a href="#7.12.14.5">7.12.14.5</a>, <a href="#F.3">F.3</a>
31209 INT_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.12">7.12</a>, <a href="#7.12.6.5">7.12.6.5</a> islower function, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.7">7.4.1.7</a>, <a href="#7.4.2.1">7.4.2.1</a>,
31210 INT_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.12">7.12</a> <a href="#7.4.2.2">7.4.2.2</a>
31211 integer arithmetic functions, <a href="#7.8.2.1">7.8.2.1</a>, <a href="#7.8.2.2">7.8.2.2</a>, isnan macro, <a href="#7.12.3.4">7.12.3.4</a>, <a href="#F.3">F.3</a>
31212 <a href="#7.22.6">7.22.6</a> isnormal macro, <a href="#7.12.3.5">7.12.3.5</a>
31213 integer character constant, <a href="#6.4.4.4">6.4.4.4</a> ISO 31-11, <a href="#2">2</a>, <a href="#3">3</a>
31214 integer constant, <a href="#6.4.4.1">6.4.4.1</a> ISO 4217, <a href="#2">2</a>, <a href="#7.11.2.1">7.11.2.1</a>
31215 integer constant expression, <a href="#6.3.2.3">6.3.2.3</a>, <a href="#6.6">6.6</a>, <a href="#6.7.2.1">6.7.2.1</a>, ISO 8601, <a href="#2">2</a>, <a href="#7.26.3.5">7.26.3.5</a>
31216 <a href="#6.7.2.2">6.7.2.2</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.7.9">6.7.9</a>, <a href="#6.7.10">6.7.10</a>, <a href="#6.8.4.2">6.8.4.2</a>, <a href="#6.10.1">6.10.1</a>, ISO/IEC 10646, <a href="#2">2</a>, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.4.3">6.4.3</a>, <a href="#6.10.8.2">6.10.8.2</a>
31217 <a href="#7.1.4">7.1.4</a> ISO/IEC 10976-1, <a href="#H.1">H.1</a>
31218 integer conversion rank, <a href="#6.3.1.1">6.3.1.1</a> ISO/IEC 2382-1, <a href="#2">2</a>, <a href="#3">3</a>
31219 integer promotions, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#6.3.1.1">6.3.1.1</a>, ISO/IEC 646, <a href="#2">2</a>, <a href="#5.2.1.1">5.2.1.1</a>
31220 <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.5.3.3">6.5.3.3</a>, <a href="#6.5.7">6.5.7</a>, <a href="#6.8.4.2">6.8.4.2</a>, <a href="#7.20.2">7.20.2</a>, <a href="#7.20.3">7.20.3</a>, ISO/IEC 9945-2, <a href="#7.11">7.11</a>
31221 <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a> iso646.h header, <a href="#4">4</a>, <a href="#7.9">7.9</a> *
31222 integer suffix, <a href="#6.4.4.1">6.4.4.1</a> isprint function, <a href="#5.2.2">5.2.2</a>, <a href="#7.4.1.8">7.4.1.8</a>
31223 integer type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.3.1.4">6.3.1.4</a>, ispunct function, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.7">7.4.1.7</a>, <a href="#7.4.1.9">7.4.1.9</a>,
31224 <a href="#F.3">F.3</a>, <a href="#F.4">F.4</a> <a href="#7.4.1.11">7.4.1.11</a>
31225 integer types, <a href="#6.2.5">6.2.5</a>, <a href="#7.20">7.20</a> isspace function, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.7">7.4.1.7</a>, <a href="#7.4.1.9">7.4.1.9</a>,
31226 <!--page 684 indent 0-->
31227 <a href="#7.4.1.10">7.4.1.10</a>, <a href="#7.4.1.11">7.4.1.11</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22.1.3">7.22.1.3</a>, LC_ALL macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a>
31228 <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.2.2">7.28.2.2</a> LC_COLLATE macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.23.4.3">7.23.4.3</a>,
31229 isunordered macro, <a href="#7.12.14.6">7.12.14.6</a>, <a href="#F.3">F.3</a> <a href="#7.28.4.4.2">7.28.4.4.2</a>
31230 isupper function, <a href="#7.4.1.2">7.4.1.2</a>, <a href="#7.4.1.11">7.4.1.11</a>, <a href="#7.4.2.1">7.4.2.1</a>, LC_CTYPE macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.22">7.22</a>, <a href="#7.22.7">7.22.7</a>,
31231 <a href="#7.4.2.2">7.4.2.2</a> <a href="#7.22.8">7.22.8</a>, <a href="#7.28.6">7.28.6</a>, <a href="#7.29.1">7.29.1</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a>, <a href="#7.29.2.2.2">7.29.2.2.2</a>,
31232 iswalnum function, <a href="#7.29.2.1.1">7.29.2.1.1</a>, <a href="#7.29.2.1.9">7.29.2.1.9</a>, <a href="#7.29.3.2.1">7.29.3.2.1</a>, <a href="#7.29.3.2.2">7.29.3.2.2</a>, <a href="#K.3.6.4">K.3.6.4</a>, <a href="#K.3.6.5">K.3.6.5</a>
31233 <a href="#7.29.2.1.10">7.29.2.1.10</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> LC_MONETARY macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a>
31234 iswalpha function, <a href="#7.29.2.1.1">7.29.2.1.1</a>, <a href="#7.29.2.1.2">7.29.2.1.2</a>, LC_NUMERIC macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a>
31235 <a href="#7.29.2.2.1">7.29.2.2.1</a> LC_TIME macro, <a href="#7.11">7.11</a>, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.26.3.5">7.26.3.5</a>
31236 iswblank function, <a href="#7.29.2.1.3">7.29.2.1.3</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> lconv structure type, <a href="#7.11">7.11</a>
31237 iswcntrl function, <a href="#7.29.2.1.2">7.29.2.1.2</a>, <a href="#7.29.2.1.4">7.29.2.1.4</a>, LDBL_DECIMAL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31238 <a href="#7.29.2.1.7">7.29.2.1.7</a>, <a href="#7.29.2.1.11">7.29.2.1.11</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> LDBL_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31239 iswctype function, <a href="#7.29.2.2.1">7.29.2.2.1</a>, <a href="#7.29.2.2.2">7.29.2.2.2</a> LDBL_EPSILON macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31240 iswdigit function, <a href="#7.29.2.1.1">7.29.2.1.1</a>, <a href="#7.29.2.1.2">7.29.2.1.2</a>, LDBL_HAS_SUBNORM macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31241 <a href="#7.29.2.1.5">7.29.2.1.5</a>, <a href="#7.29.2.1.7">7.29.2.1.7</a>, <a href="#7.29.2.1.11">7.29.2.1.11</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> LDBL_MANT_DIG macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31242 iswgraph function, <a href="#7.29.2.1">7.29.2.1</a>, <a href="#7.29.2.1.6">7.29.2.1.6</a>, LDBL_MAX macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31243 <a href="#7.29.2.1.10">7.29.2.1.10</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> LDBL_MAX_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31244 iswlower function, <a href="#7.29.2.1.2">7.29.2.1.2</a>, <a href="#7.29.2.1.7">7.29.2.1.7</a>, LDBL_MAX_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31245 <a href="#7.29.2.2.1">7.29.2.2.1</a>, <a href="#7.29.3.1.1">7.29.3.1.1</a>, <a href="#7.29.3.1.2">7.29.3.1.2</a> LDBL_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31246 iswprint function, <a href="#7.29.2.1.6">7.29.2.1.6</a>, <a href="#7.29.2.1.8">7.29.2.1.8</a>, LDBL_MIN_10_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31247 <a href="#7.29.2.2.1">7.29.2.2.1</a> LDBL_MIN_EXP macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31248 iswpunct function, <a href="#7.29.2.1">7.29.2.1</a>, <a href="#7.29.2.1.2">7.29.2.1.2</a>, LDBL_TRUE_MIN macro, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31249 <a href="#7.29.2.1.7">7.29.2.1.7</a>, <a href="#7.29.2.1.9">7.29.2.1.9</a>, <a href="#7.29.2.1.10">7.29.2.1.10</a>, ldexp functions, <a href="#7.12.6.6">7.12.6.6</a>, <a href="#F.10.3.6">F.10.3.6</a>
31250 <a href="#7.29.2.1.11">7.29.2.1.11</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> ldexp type-generic macro, <a href="#7.24">7.24</a>
31251 iswspace function, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>, ldiv function, <a href="#7.22.6.2">7.22.6.2</a>
31252 <a href="#7.28.4.1.1">7.28.4.1.1</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>, <a href="#7.29.2.1.2">7.29.2.1.2</a>, <a href="#7.29.2.1.6">7.29.2.1.6</a>, ldiv_t type, <a href="#7.22">7.22</a>
31253 <a href="#7.29.2.1.7">7.29.2.1.7</a>, <a href="#7.29.2.1.9">7.29.2.1.9</a>, <a href="#7.29.2.1.10">7.29.2.1.10</a>, leading underscore in identifiers, <a href="#7.1.3">7.1.3</a>
31254 <a href="#7.29.2.1.11">7.29.2.1.11</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> left-shift assignment operator (<<=), <a href="#6.5.16.2">6.5.16.2</a>
31255 iswupper function, <a href="#7.29.2.1.2">7.29.2.1.2</a>, <a href="#7.29.2.1.11">7.29.2.1.11</a>, left-shift operator (<<), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a>
31256 <a href="#7.29.2.2.1">7.29.2.2.1</a>, <a href="#7.29.3.1.1">7.29.3.1.1</a>, <a href="#7.29.3.1.2">7.29.3.1.2</a> length
31257 iswxdigit function, <a href="#7.29.2.1.12">7.29.2.1.12</a>, <a href="#7.29.2.2.1">7.29.2.2.1</a> external name, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.11.3">6.11.3</a>
31258 isxdigit function, <a href="#7.4.1.12">7.4.1.12</a>, <a href="#7.11.1.1">7.11.1.1</a> function name, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.11.3">6.11.3</a>
31259 italic type convention, <a href="#3">3</a>, <a href="#6.1">6.1</a> identifier, <a href="#6.4.2.1">6.4.2.1</a>
31260 iteration statements, <a href="#6.8.5">6.8.5</a> internal name, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>
31261 length function, <a href="#7.22.7.1">7.22.7.1</a>, <a href="#7.23.6.3">7.23.6.3</a>, <a href="#7.28.4.6.1">7.28.4.6.1</a>,
31262 jmp_buf type, <a href="#7.13">7.13</a> <a href="#7.28.6.3.1">7.28.6.3.1</a>, <a href="#K.3.7.4.4">K.3.7.4.4</a>, <a href="#K.3.9.2.4.1">K.3.9.2.4.1</a>
31263 jump statements, <a href="#6.8.6">6.8.6</a> length modifier, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>,
31264 <a href="#7.28.2.2">7.28.2.2</a>
31265 keywords, <a href="#6.4.1">6.4.1</a>, <a href="#G.2">G.2</a>, <a href="#J.5.9">J.5.9</a>, <a href="#J.5.10">J.5.10</a> less-than operator (<), <a href="#6.5.8">6.5.8</a>
31266 kill_dependency macro, <a href="#5.1.2.4">5.1.2.4</a>, <a href="#7.17.3.1">7.17.3.1</a> less-than-or-equal-to operator (<=), <a href="#6.5.8">6.5.8</a>
31267 known constant size, <a href="#6.2.5">6.2.5</a> letter, <a href="#5.2.1">5.2.1</a>, <a href="#7.4">7.4</a>
31268 lexical elements, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.4">6.4</a>
31269 L_tmpnam macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.4.4">7.21.4.4</a> lgamma functions, <a href="#7.12.8.3">7.12.8.3</a>, <a href="#F.10.5.3">F.10.5.3</a>
31270 L_tmpnam_s macro, <a href="#K.3.5">K.3.5</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a> lgamma type-generic macro, <a href="#7.24">7.24</a>
31271 label name, <a href="#6.2.1">6.2.1</a>, <a href="#6.2.3">6.2.3</a> library, <a href="#5.1.1.1">5.1.1.1</a>, <a href="#7">7</a>, <a href="#K.3">K.3</a>
31272 labeled statement, <a href="#6.8.1">6.8.1</a> future directions, <a href="#7.30">7.30</a>
31273 labs function, <a href="#7.22.6.1">7.22.6.1</a> summary, <a href="#B">B</a>
31274 language, <a href="#6">6</a> terms, <a href="#7.1.1">7.1.1</a>
31275 future directions, <a href="#6.11">6.11</a> use of functions, <a href="#7.1.4">7.1.4</a>
31276 syntax summary, <a href="#A">A</a> lifetime, <a href="#6.2.4">6.2.4</a>
31277 Latin alphabet, <a href="#5.2.1">5.2.1</a>, <a href="#6.4.2.1">6.4.2.1</a> limits
31278 <!--page 685 indent 0-->
31279 environmental, see environmental limits <a href="#6.3.1.6">6.3.1.6</a>, <a href="#6.3.1.7">6.3.1.7</a>, <a href="#6.3.1.8">6.3.1.8</a>
31280 implementation, see implementation limits long double _Imaginary type, <a href="#G.2">G.2</a>
31281 numerical, see numerical limits long double suffix, l or <a href="#L">L</a>, <a href="#6.4.4.2">6.4.4.2</a>
31282 translation, see translation limits long double type, <a href="#6.2.5">6.2.5</a>, <a href="#6.4.4.2">6.4.4.2</a>, <a href="#6.7.2">6.7.2</a>,
31283 limits.h header, <a href="#4">4</a>, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#6.2.5">6.2.5</a>, <a href="#7.10">7.10</a> <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#F.2">F.2</a>
31284 line buffered stream, <a href="#7.21.3">7.21.3</a> long double type conversion, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.5">6.3.1.5</a>,
31285 line number, <a href="#6.10.4">6.10.4</a>, <a href="#6.10.8.1">6.10.8.1</a> <a href="#6.3.1.7">6.3.1.7</a>, <a href="#6.3.1.8">6.3.1.8</a>
31286 line preprocessing directive, <a href="#6.10.4">6.10.4</a> long int type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.21.6.1">7.21.6.1</a>,
31287 lines, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#7.21.2">7.21.2</a> <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31288 preprocessing directive, <a href="#6.10">6.10</a> long int type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>,
31289 linkage, <a href="#6.2.2">6.2.2</a>, <a href="#6.7">6.7</a>, <a href="#6.7.4">6.7.4</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.9">6.9</a>, <a href="#6.9.2">6.9.2</a>, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.8">6.3.1.8</a>
31290 <a href="#6.11.2">6.11.2</a> long integer suffix, l or <a href="#L">L</a>, <a href="#6.4.4.1">6.4.4.1</a>
31291 llabs function, <a href="#7.22.6.1">7.22.6.1</a> long long int type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.7.2">6.7.2</a>,
31292 lldiv function, <a href="#7.22.6.2">7.22.6.2</a> <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31293 lldiv_t type, <a href="#7.22">7.22</a> long long int type conversion, <a href="#6.3.1.1">6.3.1.1</a>,
31294 LLONG_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.8">6.3.1.8</a>
31295 <a href="#7.28.4.1.2">7.28.4.1.2</a> long long integer suffix, ll or LL, <a href="#6.4.4.1">6.4.4.1</a>
31296 LLONG_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, LONG_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>
31297 <a href="#7.28.4.1.2">7.28.4.1.2</a> LONG_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>
31298 llrint functions, <a href="#7.12.9.5">7.12.9.5</a>, <a href="#F.3">F.3</a>, <a href="#F.10.6.5">F.10.6.5</a> longjmp function, <a href="#7.13.1.1">7.13.1.1</a>, <a href="#7.13.2.1">7.13.2.1</a>, <a href="#7.22.4.4">7.22.4.4</a>,
31299 llrint type-generic macro, <a href="#7.24">7.24</a> <a href="#7.22.4.7">7.22.4.7</a>
31300 llround functions, <a href="#7.12.9.7">7.12.9.7</a>, <a href="#F.10.6.7">F.10.6.7</a> loop body, <a href="#6.8.5">6.8.5</a>
31301 llround type-generic macro, <a href="#7.24">7.24</a> low-order bit, <a href="#3.6">3.6</a>
31302 local time, <a href="#7.26.1">7.26.1</a> lowercase letter, <a href="#5.2.1">5.2.1</a>
31303 locale, <a href="#3.4.2">3.4.2</a> lrint functions, <a href="#7.12.9.5">7.12.9.5</a>, <a href="#F.3">F.3</a>, <a href="#F.10.6.5">F.10.6.5</a>
31304 locale-specific behavior, <a href="#3.4.2">3.4.2</a>, <a href="#J.4">J.4</a> lrint type-generic macro, <a href="#7.24">7.24</a>
31305 locale.h header, <a href="#7.11">7.11</a>, <a href="#7.30.5">7.30.5</a> lround functions, <a href="#7.12.9.7">7.12.9.7</a>, <a href="#F.10.6.7">F.10.6.7</a>
31306 localeconv function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a> lround type-generic macro, <a href="#7.24">7.24</a>
31307 localization, <a href="#7.11">7.11</a> lvalue, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.1">6.5.1</a>, <a href="#6.5.2.4">6.5.2.4</a>, <a href="#6.5.3.1">6.5.3.1</a>, <a href="#6.5.16">6.5.16</a>,
31308 localtime function, <a href="#7.26.3.4">7.26.3.4</a> <a href="#6.7.2.4">6.7.2.4</a>
31309 localtime_s function, <a href="#K.3.8.2.4">K.3.8.2.4</a> lvalue conversion, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.16">6.5.16</a>, <a href="#6.5.16.1">6.5.16.1</a>,
31310 log functions, <a href="#7.12.6.7">7.12.6.7</a>, <a href="#F.10.3.7">F.10.3.7</a> <a href="#6.5.16.2">6.5.16.2</a>
31311 log type-generic macro, <a href="#7.24">7.24</a>
31312 log10 functions, <a href="#7.12.6.8">7.12.6.8</a>, <a href="#F.10.3.8">F.10.3.8</a> macro argument substitution, <a href="#6.10.3.1">6.10.3.1</a>
31313 log10 type-generic macro, <a href="#7.24">7.24</a> macro definition
31314 log1p functions, <a href="#7.12.6.9">7.12.6.9</a>, <a href="#F.10.3.9">F.10.3.9</a> library function, <a href="#7.1.4">7.1.4</a>
31315 log1p type-generic macro, <a href="#7.24">7.24</a> macro invocation, <a href="#6.10.3">6.10.3</a>
31316 log2 functions, <a href="#7.12.6.10">7.12.6.10</a>, <a href="#F.10.3.10">F.10.3.10</a> macro name, <a href="#6.10.3">6.10.3</a>
31317 log2 type-generic macro, <a href="#7.24">7.24</a> length, <a href="#5.2.4.1">5.2.4.1</a>
31318 logarithmic functions predefined, <a href="#6.10.8">6.10.8</a>, <a href="#6.11.9">6.11.9</a>
31319 complex, <a href="#7.3.7">7.3.7</a>, <a href="#G.6.3">G.6.3</a> redefinition, <a href="#6.10.3">6.10.3</a>
31320 real, <a href="#7.12.6">7.12.6</a>, <a href="#F.10.3">F.10.3</a> scope, <a href="#6.10.3.5">6.10.3.5</a>
31321 logb functions, <a href="#7.12.6.11">7.12.6.11</a>, <a href="#F.3">F.3</a>, <a href="#F.10.3.11">F.10.3.11</a> macro parameter, <a href="#6.10.3">6.10.3</a>
31322 logb type-generic macro, <a href="#7.24">7.24</a> macro preprocessor, <a href="#6.10">6.10</a>
31323 logical operators macro replacement, <a href="#6.10.3">6.10.3</a>
31324 AND (&&), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.13">6.5.13</a> magnitude, complex, <a href="#7.3.8.1">7.3.8.1</a>
31325 negation (!), <a href="#6.5.3.3">6.5.3.3</a> main function, <a href="#5.1.2.2.1">5.1.2.2.1</a>, <a href="#5.1.2.2.3">5.1.2.2.3</a>, <a href="#6.7.3.1">6.7.3.1</a>, <a href="#6.7.4">6.7.4</a>,
31326 OR (||), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.14">6.5.14</a> <a href="#7.21.3">7.21.3</a>
31327 logical source lines, <a href="#5.1.1.2">5.1.1.2</a> malloc function, <a href="#7.22.3">7.22.3</a>, <a href="#7.22.3.4">7.22.3.4</a>, <a href="#7.22.3.5">7.22.3.5</a>
31328 long double _Complex type, <a href="#6.2.5">6.2.5</a> manipulation functions
31329 long double _Complex type conversion, complex, <a href="#7.3.9">7.3.9</a>
31330 <!--page 686 indent 0-->
31331 real, <a href="#7.12.11">7.12.11</a>, <a href="#F.10.8">F.10.8</a> modf functions, <a href="#7.12.6.12">7.12.6.12</a>, <a href="#F.10.3.12">F.10.3.12</a>
31332 matching failure, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.8">7.28.2.8</a>, <a href="#7.28.2.10">7.28.2.10</a>, modifiable lvalue, <a href="#6.3.2.1">6.3.2.1</a>
31333 <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a> modification order, <a href="#5.1.2.4">5.1.2.4</a>
31334 math.h header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.5">6.5</a>, <a href="#7.12">7.12</a>, <a href="#7.24">7.24</a>, <a href="#F">F</a>, modulus functions, <a href="#7.12.6.12">7.12.6.12</a>
31335 <a href="#F.10">F.10</a>, <a href="#J.5.17">J.5.17</a> modulus, complex, <a href="#7.3.8.1">7.3.8.1</a>
31336 MATH_ERREXCEPT macro, <a href="#7.12">7.12</a>, <a href="#F.10">F.10</a> mtx_destroy function, <a href="#7.25.4.1">7.25.4.1</a>
31337 math_errhandling macro, <a href="#7.1.3">7.1.3</a>, <a href="#7.12">7.12</a>, <a href="#F.10">F.10</a> mtx_init function, <a href="#7.25.1">7.25.1</a>, <a href="#7.25.4.2">7.25.4.2</a>
31338 MATH_ERRNO macro, <a href="#7.12">7.12</a> mtx_lock function, <a href="#7.25.4.3">7.25.4.3</a>
31339 max_align_t type, <a href="#7.19">7.19</a> mtx_t type, <a href="#7.25.1">7.25.1</a>
31340 maximum functions, <a href="#7.12.12">7.12.12</a>, <a href="#F.10.9">F.10.9</a> mtx_timedlock function, <a href="#7.25.4.4">7.25.4.4</a>
31341 MB_CUR_MAX macro, <a href="#7.1.1">7.1.1</a>, <a href="#7.22">7.22</a>, <a href="#7.22.7.2">7.22.7.2</a>, mtx_trylock function, <a href="#7.25.4.5">7.25.4.5</a>
31342 <a href="#7.22.7.3">7.22.7.3</a>, <a href="#7.27.1.2">7.27.1.2</a>, <a href="#7.27.1.4">7.27.1.4</a>, <a href="#7.28.6.3.3">7.28.6.3.3</a>, mtx_unlock function, <a href="#7.25.4.3">7.25.4.3</a>, <a href="#7.25.4.4">7.25.4.4</a>,
31343 <a href="#K.3.6.4.1">K.3.6.4.1</a>, <a href="#K.3.9.3.1.1">K.3.9.3.1.1</a> <a href="#7.25.4.5">7.25.4.5</a>, <a href="#7.25.4.6">7.25.4.6</a>
31344 MB_LEN_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.1.1">7.1.1</a>, <a href="#7.22">7.22</a> multibyte character, <a href="#3.7.2">3.7.2</a>, <a href="#5.2.1.2">5.2.1.2</a>, <a href="#6.4.4.4">6.4.4.4</a>
31345 mblen function, <a href="#7.22.7.1">7.22.7.1</a>, <a href="#7.28.6.3">7.28.6.3</a> multibyte conversion functions
31346 mbrlen function, <a href="#7.28.6.3.1">7.28.6.3.1</a> wide character, <a href="#7.22.7">7.22.7</a>, <a href="#K.3.6.4">K.3.6.4</a>
31347 mbrtoc16 function, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#7.27.1.1">7.27.1.1</a> extended, <a href="#7.28.6">7.28.6</a>, <a href="#K.3.9.3">K.3.9.3</a>
31348 mbrtoc32 function, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#7.27.1.3">7.27.1.3</a> restartable, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#K.3.9.3.1">K.3.9.3.1</a>
31349 mbrtowc function, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, wide string, <a href="#7.22.8">7.22.8</a>, <a href="#K.3.6.5">K.3.6.5</a>
31350 <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#7.28.6.3.1">7.28.6.3.1</a>, <a href="#7.28.6.3.2">7.28.6.3.2</a>, restartable, <a href="#7.28.6.4">7.28.6.4</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a>
31351 <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#K.3.6.5.1">K.3.6.5.1</a>, <a href="#K.3.9.3.2.1">K.3.9.3.2.1</a> multibyte string, <a href="#7.1.1">7.1.1</a>
31352 mbsinit function, <a href="#7.28.6.2.1">7.28.6.2.1</a> multibyte/wide character conversion functions,
31353 mbsrtowcs function, <a href="#7.28.6.4.1">7.28.6.4.1</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a> <a href="#7.22.7">7.22.7</a>, <a href="#K.3.6.4">K.3.6.4</a>
31354 mbsrtowcs_s function, <a href="#K.3.9.3.2">K.3.9.3.2</a>, <a href="#K.3.9.3.2.1">K.3.9.3.2.1</a> extended, <a href="#7.28.6">7.28.6</a>, <a href="#K.3.9.3">K.3.9.3</a>
31355 mbstate_t type, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.6.1">7.21.6.1</a>, restartable, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#K.3.9.3.1">K.3.9.3.1</a>
31356 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.27">7.27</a>, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.1">7.28.1</a>, <a href="#7.28.2.1">7.28.2.1</a>, multibyte/wide string conversion functions,
31357 <a href="#7.28.2.2">7.28.2.2</a>, <a href="#7.28.6">7.28.6</a>, <a href="#7.28.6.2.1">7.28.6.2.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#7.22.8">7.22.8</a>, <a href="#K.3.6.5">K.3.6.5</a>
31358 <a href="#7.28.6.3.1">7.28.6.3.1</a>, <a href="#7.28.6.4">7.28.6.4</a> restartable, <a href="#7.28.6.4">7.28.6.4</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a>
31359 mbstowcs function, <a href="#6.4.5">6.4.5</a>, <a href="#7.22.8.1">7.22.8.1</a>, <a href="#7.28.6.4">7.28.6.4</a> multidimensional array, <a href="#6.5.2.1">6.5.2.1</a>
31360 mbstowcs_s function, <a href="#K.3.6.5.1">K.3.6.5.1</a> multiplication assignment operator (*=), <a href="#6.5.16.2">6.5.16.2</a>
31361 mbtowc function, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#7.22.7.1">7.22.7.1</a>, <a href="#7.22.7.2">7.22.7.2</a>, multiplication operator (*), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#F.3">F.3</a>,
31362 <a href="#7.22.8.1">7.22.8.1</a>, <a href="#7.28.6.3">7.28.6.3</a> <a href="#G.5.1">G.5.1</a>
31363 member access operators (. and ->), <a href="#6.5.2.3">6.5.2.3</a> multiplicative expressions, <a href="#6.5.5">6.5.5</a>, <a href="#G.5.1">G.5.1</a>
31364 member alignment, <a href="#6.7.2.1">6.7.2.1</a>
31365 memchr function, <a href="#7.23.5.1">7.23.5.1</a> n-char sequence, <a href="#7.22.1.3">7.22.1.3</a>
31366 memcmp function, <a href="#7.23.4">7.23.4</a>, <a href="#7.23.4.1">7.23.4.1</a> n-wchar sequence, <a href="#7.28.4.1.1">7.28.4.1.1</a>
31367 memcpy function, <a href="#7.23.2.1">7.23.2.1</a> name
31368 memcpy_s function, <a href="#K.3.7.1.1">K.3.7.1.1</a> external, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>, <a href="#6.11.3">6.11.3</a>
31369 memmove function, <a href="#7.23.2.2">7.23.2.2</a> file, <a href="#7.21.3">7.21.3</a>
31370 memmove_s function, <a href="#K.3.7.1.2">K.3.7.1.2</a> internal, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.2.1">6.4.2.1</a>
31371 memory location, <a href="#3.14">3.14</a> label, <a href="#6.2.3">6.2.3</a>
31372 memory management functions, <a href="#7.22.3">7.22.3</a> structure/union member, <a href="#6.2.3">6.2.3</a>
31373 memory_order type, <a href="#7.17.1">7.17.1</a>, <a href="#7.17.3">7.17.3</a> name spaces, <a href="#6.2.3">6.2.3</a>
31374 memset function, <a href="#7.23.6.1">7.23.6.1</a>, <a href="#K.3.7.4.1">K.3.7.4.1</a> named label, <a href="#6.8.1">6.8.1</a>
31375 memset_s function, <a href="#K.3.7.4.1">K.3.7.4.1</a> NaN, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31376 minimum functions, <a href="#7.12.12">7.12.12</a>, <a href="#F.10.9">F.10.9</a> nan functions, <a href="#7.12.11.2">7.12.11.2</a>, <a href="#F.2.1">F.2.1</a>, <a href="#F.10.8.2">F.10.8.2</a>
31377 minus operator, unary, <a href="#6.5.3.3">6.5.3.3</a> NAN macro, <a href="#7.12">7.12</a>, <a href="#F.2.1">F.2.1</a>
31378 miscellaneous functions NDEBUG macro, <a href="#7.2">7.2</a>
31379 string, <a href="#7.23.6">7.23.6</a>, <a href="#K.3.7.4">K.3.7.4</a> nearbyint functions, <a href="#7.12.9.3">7.12.9.3</a>, <a href="#7.12.9.4">7.12.9.4</a>, <a href="#F.3">F.3</a>,
31380 wide string, <a href="#7.28.4.6">7.28.4.6</a>, <a href="#K.3.9.2.4">K.3.9.2.4</a> <a href="#F.10.6.3">F.10.6.3</a>
31381 mktime function, <a href="#7.26.2.3">7.26.2.3</a> nearbyint type-generic macro, <a href="#7.24">7.24</a>
31382 <!--page 687 indent 0-->
31383 nearest integer functions, <a href="#7.12.9">7.12.9</a>, <a href="#F.10.6">F.10.6</a> operating system, <a href="#5.1.2.1">5.1.2.1</a>, <a href="#7.22.4.8">7.22.4.8</a>
31384 negation operator (!), <a href="#6.5.3.3">6.5.3.3</a> operations on files, <a href="#7.21.4">7.21.4</a>, <a href="#K.3.5.1">K.3.5.1</a>
31385 negative zero, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#7.12.11.1">7.12.11.1</a> operator, <a href="#6.4.6">6.4.6</a>
31386 new-line character, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a>, <a href="#6.10">6.10</a>, <a href="#6.10.4">6.10.4</a> operators, <a href="#6.5">6.5</a>
31387 new-line escape sequence (\n), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, additive, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.6">6.5.6</a>
31388 <a href="#7.4.1.10">7.4.1.10</a> alignof, <a href="#6.5.3.4">6.5.3.4</a>
31389 nextafter functions, <a href="#7.12.11.3">7.12.11.3</a>, <a href="#7.12.11.4">7.12.11.4</a>, <a href="#F.3">F.3</a>, assignment, <a href="#6.5.16">6.5.16</a>
31390 <a href="#F.10.8.3">F.10.8.3</a> associativity, <a href="#6.5">6.5</a>
31391 nextafter type-generic macro, <a href="#7.24">7.24</a> equality, <a href="#6.5.9">6.5.9</a>
31392 nexttoward functions, <a href="#7.12.11.4">7.12.11.4</a>, <a href="#F.3">F.3</a>, <a href="#F.10.8.4">F.10.8.4</a> multiplicative, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a>, <a href="#G.5.1">G.5.1</a>
31393 nexttoward type-generic macro, <a href="#7.24">7.24</a> postfix, <a href="#6.5.2">6.5.2</a>
31394 no linkage, <a href="#6.2.2">6.2.2</a> precedence, <a href="#6.5">6.5</a>
31395 no-return function, <a href="#6.7.4">6.7.4</a> preprocessing, <a href="#6.10.1">6.10.1</a>, <a href="#6.10.3.2">6.10.3.2</a>, <a href="#6.10.3.3">6.10.3.3</a>, <a href="#6.10.9">6.10.9</a>
31396 non-stop floating-point control mode, <a href="#7.6.4.2">7.6.4.2</a> relational, <a href="#6.5.8">6.5.8</a>
31397 nongraphic characters, <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a> shift, <a href="#6.5.7">6.5.7</a>
31398 nonlocal jumps header, <a href="#7.13">7.13</a> sizeof, <a href="#6.5.3.4">6.5.3.4</a>
31399 norm, complex, <a href="#7.3.8.1">7.3.8.1</a> unary, <a href="#6.5.3">6.5.3</a>
31400 normalized broken-down time, <a href="#K.3.8.1">K.3.8.1</a>, <a href="#K.3.8.2.1">K.3.8.2.1</a> unary arithmetic, <a href="#6.5.3.3">6.5.3.3</a>
31401 not macro, <a href="#7.9">7.9</a> optional features, see conditional features
31402 not-equal-to operator, see inequality operator or macro, <a href="#7.9">7.9</a>
31403 not_eq macro, <a href="#7.9">7.9</a> OR operators
31404 null character (\0), <a href="#5.2.1">5.2.1</a>, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a> bitwise exclusive (^), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.11">6.5.11</a>
31405 padding of binary stream, <a href="#7.21.2">7.21.2</a> bitwise exclusive assignment (^=), <a href="#6.5.16.2">6.5.16.2</a>
31406 NULL macro, <a href="#7.11">7.11</a>, <a href="#7.19">7.19</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.22">7.22</a>, <a href="#7.23.1">7.23.1</a>, bitwise inclusive (|), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.12">6.5.12</a>
31407 <a href="#7.26.1">7.26.1</a>, <a href="#7.28.1">7.28.1</a> bitwise inclusive assignment (|=), <a href="#6.5.16.2">6.5.16.2</a>
31408 null pointer, <a href="#6.3.2.3">6.3.2.3</a> logical (||), <a href="#5.1.2.4">5.1.2.4</a>, <a href="#6.5.14">6.5.14</a>
31409 null pointer constant, <a href="#6.3.2.3">6.3.2.3</a> or_eq macro, <a href="#7.9">7.9</a>
31410 null preprocessing directive, <a href="#6.10.7">6.10.7</a> order of allocated storage, <a href="#7.22.3">7.22.3</a>
31411 null statement, <a href="#6.8.3">6.8.3</a> order of evaluation, <a href="#6.5">6.5</a>, <a href="#6.5.16">6.5.16</a>, <a href="#6.10.3.2">6.10.3.2</a>, <a href="#6.10.3.3">6.10.3.3</a>,
31412 null wide character, <a href="#7.1.1">7.1.1</a> see also sequence points
31413 number classification macros, <a href="#7.12">7.12</a>, <a href="#7.12.3.1">7.12.3.1</a> ordinary identifier name space, <a href="#6.2.3">6.2.3</a>
31414 numeric conversion functions, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.22.1">7.22.1</a> orientation of stream, <a href="#7.21.2">7.21.2</a>, <a href="#7.28.3.5">7.28.3.5</a>
31415 wide string, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.28.4.1">7.28.4.1</a> out-of-bounds store, <a href="#L.2.1">L.2.1</a>
31416 numerical limits, <a href="#5.2.4.2">5.2.4.2</a> outer scope, <a href="#6.2.1">6.2.1</a>
31417 over-aligned, <a href="#6.2.8">6.2.8</a>
31418 object, <a href="#3.15">3.15</a>
31419 object representation, <a href="#6.2.6.1">6.2.6.1</a> padding
31420 object type, <a href="#6.2.5">6.2.5</a> binary stream, <a href="#7.21.2">7.21.2</a>
31421 object-like macro, <a href="#6.10.3">6.10.3</a> bits, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#7.20.1.1">7.20.1.1</a>
31422 observable behavior, <a href="#5.1.2.3">5.1.2.3</a> structure/union, <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.7.2.1">6.7.2.1</a>
31423 obsolescence, <a href="#6.11">6.11</a>, <a href="#7.30">7.30</a> parameter, <a href="#3.16">3.16</a>
31424 octal constant, <a href="#6.4.4.1">6.4.4.1</a> array, <a href="#6.9.1">6.9.1</a>
31425 octal digit, <a href="#6.4.4.1">6.4.4.1</a>, <a href="#6.4.4.4">6.4.4.4</a> ellipsis, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.10.3">6.10.3</a>
31426 octal-character escape sequence (\octal digits), function, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.7">6.7</a>, <a href="#6.9.1">6.9.1</a>
31427 <a href="#6.4.4.4">6.4.4.4</a> macro, <a href="#6.10.3">6.10.3</a>
31428 offsetof macro, <a href="#7.19">7.19</a> main function, <a href="#5.1.2.2.1">5.1.2.2.1</a>
31429 on-off switch, <a href="#6.10.6">6.10.6</a> program, <a href="#5.1.2.2.1">5.1.2.2.1</a>
31430 once_flag type, <a href="#7.25.1">7.25.1</a> parameter type list, <a href="#6.7.6.3">6.7.6.3</a>
31431 ONCE_FLAG_INIT macro, <a href="#7.25.1">7.25.1</a> parentheses punctuator (( )), <a href="#6.7.6.3">6.7.6.3</a>, <a href="#6.8.4">6.8.4</a>, <a href="#6.8.5">6.8.5</a>
31432 ones' complement, <a href="#6.2.6.2">6.2.6.2</a> parenthesized expression, <a href="#6.5.1">6.5.1</a>
31433 operand, <a href="#6.4.6">6.4.6</a>, <a href="#6.5">6.5</a> parse state, <a href="#7.21.2">7.21.2</a>
31434 <!--page 688 indent 0-->
31435 perform a trap, <a href="#3.19.5">3.19.5</a> preprocessor, <a href="#6.10">6.10</a>
31436 permitted form of initializer, <a href="#6.6">6.6</a> PRIcFASTN macros, <a href="#7.8.1">7.8.1</a>
31437 perror function, <a href="#7.21.10.4">7.21.10.4</a> PRIcLEASTN macros, <a href="#7.8.1">7.8.1</a>
31438 phase angle, complex, <a href="#7.3.9.1">7.3.9.1</a> PRIcMAX macros, <a href="#7.8.1">7.8.1</a>
31439 physical source lines, <a href="#5.1.1.2">5.1.1.2</a> PRIcN macros, <a href="#7.8.1">7.8.1</a>
31440 placemarker, <a href="#6.10.3.3">6.10.3.3</a> PRIcPTR macros, <a href="#7.8.1">7.8.1</a>
31441 plus operator, unary, <a href="#6.5.3.3">6.5.3.3</a> primary expression, <a href="#6.5.1">6.5.1</a>
31442 pointer arithmetic, <a href="#6.5.6">6.5.6</a> printf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.3">7.21.6.3</a>, <a href="#7.21.6.10">7.21.6.10</a>,
31443 pointer comparison, <a href="#6.5.8">6.5.8</a> <a href="#K.3.5.3.3">K.3.5.3.3</a>
31444 pointer declarator, <a href="#6.7.6.1">6.7.6.1</a> printf_s function, <a href="#K.3.5.3.3">K.3.5.3.3</a>
31445 pointer operator (->), <a href="#6.5.2.3">6.5.2.3</a> printing character, <a href="#5.2.2">5.2.2</a>, <a href="#7.4">7.4</a>, <a href="#7.4.1.8">7.4.1.8</a>
31446 pointer to function, <a href="#6.5.2.2">6.5.2.2</a> printing wide character, <a href="#7.29.2">7.29.2</a>
31447 pointer type, <a href="#6.2.5">6.2.5</a> program diagnostics, <a href="#7.2.1">7.2.1</a>
31448 pointer type conversion, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.3.2.3">6.3.2.3</a> program execution, <a href="#5.1.2.2.2">5.1.2.2.2</a>, <a href="#5.1.2.3">5.1.2.3</a>
31449 pointer, null, <a href="#6.3.2.3">6.3.2.3</a> program file, <a href="#5.1.1.1">5.1.1.1</a>
31450 pole error, <a href="#7.12.1">7.12.1</a>, <a href="#7.12.5.3">7.12.5.3</a>, <a href="#7.12.6.7">7.12.6.7</a>, <a href="#7.12.6.8">7.12.6.8</a>, program image, <a href="#5.1.1.2">5.1.1.2</a>
31451 <a href="#7.12.6.9">7.12.6.9</a>, <a href="#7.12.6.10">7.12.6.10</a>, <a href="#7.12.6.11">7.12.6.11</a>, <a href="#7.12.7.4">7.12.7.4</a>, program name (argv[0]), <a href="#5.1.2.2.1">5.1.2.2.1</a>
31452 <a href="#7.12.8.3">7.12.8.3</a>, <a href="#7.12.8.4">7.12.8.4</a> program parameters, <a href="#5.1.2.2.1">5.1.2.2.1</a>
31453 portability, <a href="#4">4</a>, <a href="#J">J</a> program startup, <a href="#5.1.2">5.1.2</a>, <a href="#5.1.2.1">5.1.2.1</a>, <a href="#5.1.2.2.1">5.1.2.2.1</a>
31454 position indicator, file, see file position indicator program structure, <a href="#5.1.1.1">5.1.1.1</a>
31455 positive difference, <a href="#7.12.12.1">7.12.12.1</a> program termination, <a href="#5.1.2">5.1.2</a>, <a href="#5.1.2.1">5.1.2.1</a>, <a href="#5.1.2.2.3">5.1.2.2.3</a>,
31456 positive difference functions, <a href="#7.12.12">7.12.12</a>, <a href="#F.10.9">F.10.9</a> <a href="#5.1.2.3">5.1.2.3</a>
31457 postfix decrement operator (--), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.4">6.5.2.4</a> program, conforming, <a href="#4">4</a>
31458 postfix expressions, <a href="#6.5.2">6.5.2</a> program, strictly conforming, <a href="#4">4</a>
31459 postfix increment operator (++), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.4">6.5.2.4</a> promotions
31460 pow functions, <a href="#7.12.7.4">7.12.7.4</a>, <a href="#F.10.4.4">F.10.4.4</a> default argument, <a href="#6.5.2.2">6.5.2.2</a>
31461 pow type-generic macro, <a href="#7.24">7.24</a> integer, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.3.1.1">6.3.1.1</a>
31462 power functions prototype, see function prototype
31463 complex, <a href="#7.3.8">7.3.8</a>, <a href="#G.6.4">G.6.4</a> pseudo-random sequence functions, <a href="#7.22.2">7.22.2</a>
31464 real, <a href="#7.12.7">7.12.7</a>, <a href="#F.10.4">F.10.4</a> PTRDIFF_MAX macro, <a href="#7.20.3">7.20.3</a>
31465 pp-number, <a href="#6.4.8">6.4.8</a> PTRDIFF_MIN macro, <a href="#7.20.3">7.20.3</a>
31466 pragma operator, <a href="#6.10.9">6.10.9</a> ptrdiff_t type, <a href="#7.17.1">7.17.1</a>, <a href="#7.19">7.19</a>, <a href="#7.20.3">7.20.3</a>, <a href="#7.21.6.1">7.21.6.1</a>,
31467 pragma preprocessing directive, <a href="#6.10.6">6.10.6</a>, <a href="#6.11.8">6.11.8</a> <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31468 precedence of operators, <a href="#6.5">6.5</a> punctuators, <a href="#6.4.6">6.4.6</a>
31469 precedence of syntax rules, <a href="#5.1.1.2">5.1.1.2</a> putc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.7">7.21.7.7</a>, <a href="#7.21.7.8">7.21.7.8</a>
31470 precision, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.2.1">7.28.2.1</a> putchar function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.8">7.21.7.8</a>
31471 excess, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a> puts function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.9">7.21.7.9</a>
31472 predefined macro names, <a href="#6.10.8">6.10.8</a>, <a href="#6.11.9">6.11.9</a> putwc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.8">7.28.3.8</a>, <a href="#7.28.3.9">7.28.3.9</a>
31473 prefix decrement operator (--), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.1">6.5.3.1</a> putwchar function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.9">7.28.3.9</a>
31474 prefix increment operator (++), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3.1">6.5.3.1</a>
31475 preprocessing concatenation, <a href="#6.10.3.3">6.10.3.3</a> qsort function, <a href="#7.22.5">7.22.5</a>, <a href="#7.22.5.2">7.22.5.2</a>
31476 preprocessing directives, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.10">6.10</a> qsort_s function, <a href="#K.3.6.3">K.3.6.3</a>, <a href="#K.3.6.3.2">K.3.6.3.2</a>
31477 preprocessing file, <a href="#5.1.1.1">5.1.1.1</a>, <a href="#6.10">6.10</a> qualified types, <a href="#6.2.5">6.2.5</a>
31478 preprocessing numbers, <a href="#6.4">6.4</a>, <a href="#6.4.8">6.4.8</a> qualified version of type, <a href="#6.2.5">6.2.5</a>
31479 preprocessing operators question-mark escape sequence (\?), <a href="#6.4.4.4">6.4.4.4</a>
31480 #, <a href="#6.10.3.2">6.10.3.2</a> quick_exit function, <a href="#7.22.4.3">7.22.4.3</a>, <a href="#7.22.4.4">7.22.4.4</a>,
31481 ##, <a href="#6.10.3.3">6.10.3.3</a> <a href="#7.22.4.7">7.22.4.7</a>
31482 _Pragma, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.10.9">6.10.9</a> quiet NaN, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31483 defined, <a href="#6.10.1">6.10.1</a>
31484 preprocessing tokens, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.4">6.4</a>, <a href="#6.10">6.10</a> raise function, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#7.14.2.1">7.14.2.1</a>, <a href="#7.22.4.1">7.22.4.1</a>
31485 preprocessing translation unit, <a href="#5.1.1.1">5.1.1.1</a> rand function, <a href="#7.22">7.22</a>, <a href="#7.22.2.1">7.22.2.1</a>, <a href="#7.22.2.2">7.22.2.2</a>
31486 <!--page 689 indent 0-->
31487 RAND_MAX macro, <a href="#7.22">7.22</a>, <a href="#7.22.2.1">7.22.2.1</a> restrict-qualified type, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.3">6.7.3</a>
31488 range return statement, <a href="#6.8.6.4">6.8.6.4</a>, <a href="#F.6">F.6</a>
31489 excess, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.8.6.4">6.8.6.4</a> rewind function, <a href="#7.21.5.3">7.21.5.3</a>, <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.21.9.5">7.21.9.5</a>,
31490 range error, <a href="#7.12.1">7.12.1</a>, <a href="#7.12.5.4">7.12.5.4</a>, <a href="#7.12.5.5">7.12.5.5</a>, <a href="#7.12.6.1">7.12.6.1</a>, <a href="#7.28.3.10">7.28.3.10</a>
31491 <a href="#7.12.6.2">7.12.6.2</a>, <a href="#7.12.6.3">7.12.6.3</a>, <a href="#7.12.6.5">7.12.6.5</a>, <a href="#7.12.6.6">7.12.6.6</a>, right-shift assignment operator (>>=), <a href="#6.5.16.2">6.5.16.2</a>
31492 <a href="#7.12.6.13">7.12.6.13</a>, <a href="#7.12.7.3">7.12.7.3</a>, <a href="#7.12.7.4">7.12.7.4</a>, <a href="#7.12.8.2">7.12.8.2</a>, right-shift operator (>>), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.7">6.5.7</a>
31493 <a href="#7.12.8.3">7.12.8.3</a>, <a href="#7.12.8.4">7.12.8.4</a>, <a href="#7.12.9.5">7.12.9.5</a>, <a href="#7.12.9.7">7.12.9.7</a>, rint functions, <a href="#7.12.9.4">7.12.9.4</a>, <a href="#F.3">F.3</a>, <a href="#F.10.6.4">F.10.6.4</a>
31494 <a href="#7.12.11.3">7.12.11.3</a>, <a href="#7.12.12.1">7.12.12.1</a>, <a href="#7.12.13.1">7.12.13.1</a> rint type-generic macro, <a href="#7.24">7.24</a>
31495 rank, see integer conversion rank round functions, <a href="#7.12.9.6">7.12.9.6</a>, <a href="#F.10.6.6">F.10.6.6</a>
31496 read-modify-write operations, <a href="#5.1.2.4">5.1.2.4</a> round type-generic macro, <a href="#7.24">7.24</a>
31497 real floating type conversion, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.5">6.3.1.5</a>, rounding mode, floating point, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31498 <a href="#6.3.1.7">6.3.1.7</a>, <a href="#F.3">F.3</a>, <a href="#F.4">F.4</a> RSIZE_MAX macro, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a>,
31499 real floating types, <a href="#6.2.5">6.2.5</a> <a href="#K.3.5.3.5">K.3.5.3.5</a>, <a href="#K.3.5.3.6">K.3.5.3.6</a>, <a href="#K.3.5.3.12">K.3.5.3.12</a>, <a href="#K.3.5.3.13">K.3.5.3.13</a>,
31500 real type domain, <a href="#6.2.5">6.2.5</a> <a href="#K.3.5.4.1">K.3.5.4.1</a>, <a href="#K.3.6.2.1">K.3.6.2.1</a>, <a href="#K.3.6.3.1">K.3.6.3.1</a>, <a href="#K.3.6.3.2">K.3.6.3.2</a>,
31501 real types, <a href="#6.2.5">6.2.5</a> <a href="#K.3.6.4.1">K.3.6.4.1</a>, <a href="#K.3.6.5.1">K.3.6.5.1</a>, <a href="#K.3.6.5.2">K.3.6.5.2</a>, <a href="#K.3.7.1.1">K.3.7.1.1</a>,
31502 real-floating, <a href="#7.12.3">7.12.3</a> <a href="#K.3.7.1.2">K.3.7.1.2</a>, <a href="#K.3.7.1.3">K.3.7.1.3</a>, <a href="#K.3.7.1.4">K.3.7.1.4</a>, <a href="#K.3.7.2.1">K.3.7.2.1</a>,
31503 realloc function, <a href="#7.22.3">7.22.3</a>, <a href="#7.22.3.5">7.22.3.5</a> <a href="#K.3.7.2.2">K.3.7.2.2</a>, <a href="#K.3.7.3.1">K.3.7.3.1</a>, <a href="#K.3.7.4.1">K.3.7.4.1</a>, <a href="#K.3.7.4.2">K.3.7.4.2</a>,
31504 recommended practice, <a href="#3.17">3.17</a> <a href="#K.3.8.2.1">K.3.8.2.1</a>, <a href="#K.3.8.2.2">K.3.8.2.2</a>, <a href="#K.3.9.1.3">K.3.9.1.3</a>, <a href="#K.3.9.1.4">K.3.9.1.4</a>,
31505 recursion, <a href="#6.5.2.2">6.5.2.2</a> <a href="#K.3.9.1.8">K.3.9.1.8</a>, <a href="#K.3.9.1.9">K.3.9.1.9</a>, <a href="#K.3.9.2.1.1">K.3.9.2.1.1</a>, <a href="#K.3.9.2.1.2">K.3.9.2.1.2</a>,
31506 recursive function call, <a href="#6.5.2.2">6.5.2.2</a> <a href="#K.3.9.2.1.3">K.3.9.2.1.3</a>, <a href="#K.3.9.2.1.4">K.3.9.2.1.4</a>, <a href="#K.3.9.2.2.1">K.3.9.2.2.1</a>,
31507 redefinition of macro, <a href="#6.10.3">6.10.3</a> <a href="#K.3.9.2.2.2">K.3.9.2.2.2</a>, <a href="#K.3.9.2.3.1">K.3.9.2.3.1</a>, <a href="#K.3.9.3.1.1">K.3.9.3.1.1</a>,
31508 reentrancy, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.3">5.2.3</a> <a href="#K.3.9.3.2.1">K.3.9.3.2.1</a>, <a href="#K.3.9.3.2.2">K.3.9.3.2.2</a>
31509 library functions, <a href="#7.1.4">7.1.4</a> rsize_t type, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a>, <a href="#K.3.5">K.3.5</a>, <a href="#K.3.5.3.2">K.3.5.3.2</a>,
31510 referenced type, <a href="#6.2.5">6.2.5</a> <a href="#K.3.6">K.3.6</a>, <a href="#K.3.7">K.3.7</a>, <a href="#K.3.8">K.3.8</a>, <a href="#K.3.9">K.3.9</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>
31511 register storage-class specifier, <a href="#6.7.1">6.7.1</a>, <a href="#6.9">6.9</a> runtime-constraint, <a href="#3.18">3.18</a>
31512 relational expressions, <a href="#6.5.8">6.5.8</a> Runtime-constraint handling functions, <a href="#K.3.6.1">K.3.6.1</a>
31513 relaxed atomic operations, <a href="#5.1.2.4">5.1.2.4</a> rvalue, <a href="#6.3.2.1">6.3.2.1</a>
31514 release fence, <a href="#7.17.4">7.17.4</a>
31515 release operation, <a href="#5.1.2.4">5.1.2.4</a> same scope, <a href="#6.2.1">6.2.1</a>
31516 release sequence, <a href="#5.1.2.4">5.1.2.4</a> save calling environment function, <a href="#7.13.1">7.13.1</a>
31517 reliability of data, interrupted, <a href="#5.1.2.3">5.1.2.3</a> scalar types, <a href="#6.2.5">6.2.5</a>
31518 remainder assignment operator (%=), <a href="#6.5.16.2">6.5.16.2</a> scalbln function, <a href="#7.12.6.13">7.12.6.13</a>, <a href="#F.3">F.3</a>, <a href="#F.10.3.13">F.10.3.13</a>
31519 remainder functions, <a href="#7.12.10">7.12.10</a>, <a href="#F.10.7">F.10.7</a> scalbln type-generic macro, <a href="#7.24">7.24</a>
31520 remainder functions, <a href="#7.12.10.2">7.12.10.2</a>, <a href="#7.12.10.3">7.12.10.3</a>, <a href="#F.3">F.3</a>, scalbn function, <a href="#7.12.6.13">7.12.6.13</a>, <a href="#F.3">F.3</a>, <a href="#F.10.3.13">F.10.3.13</a>
31521 <a href="#F.10.7.2">F.10.7.2</a> scalbn type-generic macro, <a href="#7.24">7.24</a>
31522 remainder operator (%), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.5">6.5.5</a> scanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.4">7.21.6.4</a>, <a href="#7.21.6.11">7.21.6.11</a>
31523 remainder type-generic macro, <a href="#7.24">7.24</a> scanf_s function, <a href="#K.3.5.3.4">K.3.5.3.4</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>
31524 remove function, <a href="#7.21.4.1">7.21.4.1</a>, <a href="#7.21.4.4">7.21.4.4</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a> scanlist, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>
31525 remquo functions, <a href="#7.12.10.3">7.12.10.3</a>, <a href="#F.3">F.3</a>, <a href="#F.10.7.3">F.10.7.3</a> scanset, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>
31526 remquo type-generic macro, <a href="#7.24">7.24</a> SCHAR_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>
31527 rename function, <a href="#7.21.4.2">7.21.4.2</a> SCHAR_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>
31528 representations of types, <a href="#6.2.6">6.2.6</a> SCNcFASTN macros, <a href="#7.8.1">7.8.1</a>
31529 pointer, <a href="#6.2.5">6.2.5</a> SCNcLEASTN macros, <a href="#7.8.1">7.8.1</a>
31530 rescanning and replacement, <a href="#6.10.3.4">6.10.3.4</a> SCNcMAX macros, <a href="#7.8.1">7.8.1</a>
31531 reserved identifiers, <a href="#6.4.1">6.4.1</a>, <a href="#7.1.3">7.1.3</a>, <a href="#K.3.1.2">K.3.1.2</a> SCNcN macros, <a href="#7.8.1">7.8.1</a>
31532 restartable multibyte/wide character conversion SCNcPTR macros, <a href="#7.8.1">7.8.1</a>
31533 functions, <a href="#7.27.1">7.27.1</a>, <a href="#7.28.6.3">7.28.6.3</a>, <a href="#K.3.9.3.1">K.3.9.3.1</a> scope of identifier, <a href="#6.2.1">6.2.1</a>, <a href="#6.9.2">6.9.2</a>
31534 restartable multibyte/wide string conversion search functions
31535 functions, <a href="#7.28.6.4">7.28.6.4</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a> string, <a href="#7.23.5">7.23.5</a>, <a href="#K.3.7.3">K.3.7.3</a>
31536 restore calling environment function, <a href="#7.13.2">7.13.2</a> utility, <a href="#7.22.5">7.22.5</a>, <a href="#K.3.6.3">K.3.6.3</a>
31537 restrict type qualifier, <a href="#6.7.3">6.7.3</a>, <a href="#6.7.3.1">6.7.3.1</a> wide string, <a href="#7.28.4.5">7.28.4.5</a>, <a href="#K.3.9.2.3">K.3.9.2.3</a>
31538 <!--page 690 indent 0-->
31539 SEEK_CUR macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.9.2">7.21.9.2</a> sign and magnitude, <a href="#6.2.6.2">6.2.6.2</a>
31540 SEEK_END macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.9.2">7.21.9.2</a> sign bit, <a href="#6.2.6.2">6.2.6.2</a>
31541 SEEK_SET macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.9.2">7.21.9.2</a> signal function, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#7.22.4.5">7.22.4.5</a>, <a href="#7.22.4.7">7.22.4.7</a>
31542 selection statements, <a href="#6.8.4">6.8.4</a> signal handler, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.3">5.2.3</a>, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#7.14.2.1">7.14.2.1</a>
31543 self-referential structure, <a href="#6.7.2.3">6.7.2.3</a> signal handling functions, <a href="#7.14.1">7.14.1</a>
31544 semicolon punctuator (;), <a href="#6.7">6.7</a>, <a href="#6.7.2.1">6.7.2.1</a>, <a href="#6.8.3">6.8.3</a>, signal.h header, <a href="#7.14">7.14</a>, <a href="#7.30.6">7.30.6</a>
31545 <a href="#6.8.5">6.8.5</a>, <a href="#6.8.6">6.8.6</a> signaling NaN, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#F.2.1">F.2.1</a>
31546 separate compilation, <a href="#5.1.1.1">5.1.1.1</a> signals, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.3">5.2.3</a>, <a href="#7.14.1">7.14.1</a>
31547 separate translation, <a href="#5.1.1.1">5.1.1.1</a> signbit macro, <a href="#7.12.3.6">7.12.3.6</a>, <a href="#F.3">F.3</a>
31548 sequence points, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.5.13">6.5.13</a>, <a href="#6.5.14">6.5.14</a>, signed char type, <a href="#6.2.5">6.2.5</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>,
31549 <a href="#6.5.15">6.5.15</a>, <a href="#6.5.17">6.5.17</a>, <a href="#6.7.3">6.7.3</a>, <a href="#6.7.3.1">6.7.3.1</a>, <a href="#6.7.6">6.7.6</a>, <a href="#6.8">6.8</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#K.3.5.3.2">K.3.5.3.2</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>
31550 <a href="#7.1.4">7.1.4</a>, <a href="#7.21.6">7.21.6</a>, <a href="#7.22.5">7.22.5</a>, <a href="#7.28.2">7.28.2</a>, <a href="#C">C</a>, <a href="#K.3.6.3">K.3.6.3</a> signed character, <a href="#6.3.1.1">6.3.1.1</a>
31551 sequenced after, see sequenced before signed integer types, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.4.4.1">6.4.4.1</a>
31552 sequenced before, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.5">6.5</a>, <a href="#6.5.2.2">6.5.2.2</a>, <a href="#6.5.2.4">6.5.2.4</a>, signed type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.3.1.4">6.3.1.4</a>,
31553 <a href="#6.5.16">6.5.16</a>, see also indeterminately sequenced, <a href="#6.3.1.8">6.3.1.8</a>
31554 unsequenced signed types, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2">6.7.2</a>
31555 sequencing of statements, <a href="#6.8">6.8</a> significand part, <a href="#6.4.4.2">6.4.4.2</a>
31556 set_constraint_handler_s function, SIGSEGV macro, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a>
31557 <a href="#K.3.1.4">K.3.1.4</a>, <a href="#K.3.6.1.1">K.3.6.1.1</a>, <a href="#K.3.6.1.2">K.3.6.1.2</a>, <a href="#K.3.6.1.3">K.3.6.1.3</a> SIGTERM macro, <a href="#7.14">7.14</a>
31558 setbuf function, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.5.1">7.21.5.1</a>, <a href="#7.21.5.5">7.21.5.5</a> simple assignment operator (=), <a href="#6.5.16.1">6.5.16.1</a>
31559 setjmp macro, <a href="#7.1.3">7.1.3</a>, <a href="#7.13.1.1">7.13.1.1</a>, <a href="#7.13.2.1">7.13.2.1</a> sin functions, <a href="#7.12.4.6">7.12.4.6</a>, <a href="#F.10.1.6">F.10.1.6</a>
31560 setjmp.h header, <a href="#7.13">7.13</a> sin type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
31561 setlocale function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.11.2.1">7.11.2.1</a> single-byte character, <a href="#3.7.1">3.7.1</a>, <a href="#5.2.1.2">5.2.1.2</a>
31562 setvbuf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.5.1">7.21.5.1</a>, single-byte/wide character conversion functions,
31563 <a href="#7.21.5.5">7.21.5.5</a>, <a href="#7.21.5.6">7.21.5.6</a> <a href="#7.28.6.1">7.28.6.1</a>
31564 shall, <a href="#4">4</a> single-precision arithmetic, <a href="#5.1.2.3">5.1.2.3</a>
31565 shift expressions, <a href="#6.5.7">6.5.7</a> single-quote escape sequence (\'), <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>
31566 shift sequence, <a href="#7.1.1">7.1.1</a> singularity, <a href="#7.12.1">7.12.1</a>
31567 shift states, <a href="#5.2.1.2">5.2.1.2</a> sinh functions, <a href="#7.12.5.5">7.12.5.5</a>, <a href="#F.10.2.5">F.10.2.5</a>
31568 short identifier, character, <a href="#5.2.4.1">5.2.4.1</a>, <a href="#6.4.3">6.4.3</a> sinh type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
31569 short int type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.21.6.1">7.21.6.1</a>, SIZE_MAX macro, <a href="#7.20.3">7.20.3</a>
31570 <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a> size_t type, <a href="#6.2.8">6.2.8</a>, <a href="#6.5.3.4">6.5.3.4</a>, <a href="#7.19">7.19</a>, <a href="#7.20.3">7.20.3</a>, <a href="#7.21.1">7.21.1</a>,
31571 short int type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22">7.22</a>, <a href="#7.23.1">7.23.1</a>, <a href="#7.26.1">7.26.1</a>, <a href="#7.27">7.27</a>,
31572 <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.8">6.3.1.8</a> <a href="#7.28.1">7.28.1</a>, <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a>,
31573 SHRT_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a> <a href="#K.3.5">K.3.5</a>, <a href="#K.3.6">K.3.6</a>, <a href="#K.3.7">K.3.7</a>, <a href="#K.3.8">K.3.8</a>, <a href="#K.3.9">K.3.9</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>
31574 SHRT_MIN macro, <a href="#5.2.4.2.1">5.2.4.2.1</a> sizeof operator, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.3">6.5.3</a>, <a href="#6.5.3.4">6.5.3.4</a>
31575 side effects, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.3.2.2">6.3.2.2</a>, <a href="#6.5">6.5</a>, <a href="#6.5.2.4">6.5.2.4</a>, snprintf function, <a href="#7.21.6.5">7.21.6.5</a>, <a href="#7.21.6.12">7.21.6.12</a>,
31576 <a href="#6.5.16">6.5.16</a>, <a href="#6.7.9">6.7.9</a>, <a href="#6.8.3">6.8.3</a>, <a href="#7.6">7.6</a>, <a href="#7.6.1">7.6.1</a>, <a href="#7.21.7.5">7.21.7.5</a>, <a href="#K.3.5.3.5">K.3.5.3.5</a>
31577 <a href="#7.21.7.7">7.21.7.7</a>, <a href="#7.28.3.6">7.28.3.6</a>, <a href="#7.28.3.8">7.28.3.8</a>, <a href="#F.8.1">F.8.1</a>, <a href="#F.9.1">F.9.1</a>, snprintf_s function, <a href="#K.3.5.3.5">K.3.5.3.5</a>, <a href="#K.3.5.3.6">K.3.5.3.6</a>
31578 <a href="#F.9.3">F.9.3</a> snwprintf_s function, <a href="#K.3.9.1.3">K.3.9.1.3</a>, <a href="#K.3.9.1.4">K.3.9.1.4</a>
31579 SIG_ATOMIC_MAX macro, <a href="#7.20.3">7.20.3</a> sorting utility functions, <a href="#7.22.5">7.22.5</a>, <a href="#K.3.6.3">K.3.6.3</a>
31580 SIG_ATOMIC_MIN macro, <a href="#7.20.3">7.20.3</a> source character set, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>
31581 sig_atomic_t type, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a>, source file, <a href="#5.1.1.1">5.1.1.1</a>
31582 <a href="#7.20.3">7.20.3</a> name, <a href="#6.10.4">6.10.4</a>, <a href="#6.10.8.1">6.10.8.1</a>
31583 SIG_DFL macro, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a> source file inclusion, <a href="#6.10.2">6.10.2</a>
31584 SIG_ERR macro, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a> source lines, <a href="#5.1.1.2">5.1.1.2</a>
31585 SIG_IGN macro, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a> source text, <a href="#5.1.1.2">5.1.1.2</a>
31586 SIGABRT macro, <a href="#7.14">7.14</a>, <a href="#7.22.4.1">7.22.4.1</a> space character (' '), <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a>, <a href="#7.4.1.3">7.4.1.3</a>,
31587 SIGFPE macro, <a href="#7.12.1">7.12.1</a>, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a>, <a href="#J.5.17">J.5.17</a> <a href="#7.4.1.10">7.4.1.10</a>, <a href="#7.29.2.1.3">7.29.2.1.3</a>
31588 SIGILL macro, <a href="#7.14">7.14</a>, <a href="#7.14.1.1">7.14.1.1</a> sprintf function, <a href="#7.21.6.6">7.21.6.6</a>, <a href="#7.21.6.13">7.21.6.13</a>, <a href="#K.3.5.3.6">K.3.5.3.6</a>
31589 SIGINT macro, <a href="#7.14">7.14</a> sprintf_s function, <a href="#K.3.5.3.5">K.3.5.3.5</a>, <a href="#K.3.5.3.6">K.3.5.3.6</a>
31590 <!--page 691 indent 0-->
31591 sqrt functions, <a href="#7.12.7.5">7.12.7.5</a>, <a href="#F.3">F.3</a>, <a href="#F.10.4.5">F.10.4.5</a> do, <a href="#6.8.5.2">6.8.5.2</a>
31592 sqrt type-generic macro, <a href="#7.24">7.24</a> else, <a href="#6.8.4.1">6.8.4.1</a>
31593 srand function, <a href="#7.22.2.2">7.22.2.2</a> expression, <a href="#6.8.3">6.8.3</a>
31594 sscanf function, <a href="#7.21.6.7">7.21.6.7</a>, <a href="#7.21.6.14">7.21.6.14</a> for, <a href="#6.8.5.3">6.8.5.3</a>
31595 sscanf_s function, <a href="#K.3.5.3.7">K.3.5.3.7</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a> goto, <a href="#6.8.6.1">6.8.6.1</a>
31596 standard error stream, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.10.4">7.21.10.4</a> if, <a href="#6.8.4.1">6.8.4.1</a>
31597 standard headers, <a href="#4">4</a>, <a href="#7.1.2">7.1.2</a> iteration, <a href="#6.8.5">6.8.5</a>
31598 <assert.h>, <a href="#7.2">7.2</a> jump, <a href="#6.8.6">6.8.6</a>
31599 <complex.h>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.3">7.3</a>, labeled, <a href="#6.8.1">6.8.1</a>
31600 <a href="#7.24">7.24</a>, <a href="#7.30.1">7.30.1</a>, <a href="#G.6">G.6</a>, <a href="#J.5.17">J.5.17</a> null, <a href="#6.8.3">6.8.3</a>
31601 <ctype.h>, <a href="#7.4">7.4</a>, <a href="#7.30.2">7.30.2</a> return, <a href="#6.8.6.4">6.8.6.4</a>, <a href="#F.6">F.6</a>
31602 <errno.h>, <a href="#7.5">7.5</a>, <a href="#7.30.3">7.30.3</a>, <a href="#K.3.2">K.3.2</a> selection, <a href="#6.8.4">6.8.4</a>
31603 <fenv.h>, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.6">7.6</a>, <a href="#7.12">7.12</a>, <a href="#F">F</a>, <a href="#H">H</a> sequencing, <a href="#6.8">6.8</a>
31604 <float.h>, <a href="#4">4</a>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.7">7.7</a>, <a href="#7.22.1.3">7.22.1.3</a>, switch, <a href="#6.8.4.2">6.8.4.2</a>
31605 <a href="#7.28.4.1.1">7.28.4.1.1</a> while, <a href="#6.8.5.1">6.8.5.1</a>
31606 <inttypes.h>, <a href="#7.8">7.8</a>, <a href="#7.30.4">7.30.4</a> static assertions, <a href="#6.7.10">6.7.10</a>
31607 <iso646.h>, <a href="#4">4</a>, <a href="#7.9">7.9</a> static storage duration, <a href="#6.2.4">6.2.4</a>
31608 <limits.h>, <a href="#4">4</a>, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#6.2.5">6.2.5</a>, <a href="#7.10">7.10</a> static storage-class specifier, <a href="#6.2.2">6.2.2</a>, <a href="#6.2.4">6.2.4</a>, <a href="#6.7.1">6.7.1</a>
31609 <locale.h>, <a href="#7.11">7.11</a>, <a href="#7.30.5">7.30.5</a> static, in array declarators, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.7.6.3">6.7.6.3</a>
31610 <math.h>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#6.5">6.5</a>, <a href="#7.12">7.12</a>, <a href="#7.24">7.24</a>, <a href="#F">F</a>, <a href="#F.10">F.10</a>, static_assert declaration, <a href="#6.7.10">6.7.10</a>
31611 <a href="#J.5.17">J.5.17</a> static_assert macro, <a href="#7.2">7.2</a>
31612 <setjmp.h>, <a href="#7.13">7.13</a> stdalign.h header, <a href="#4">4</a>, <a href="#7.15">7.15</a>
31613 <signal.h>, <a href="#7.14">7.14</a>, <a href="#7.30.6">7.30.6</a> stdarg.h header, <a href="#4">4</a>, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#7.16">7.16</a>
31614 <stdalign.h>, <a href="#4">4</a>, <a href="#7.15">7.15</a> stdatomic.h header, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.17">7.17</a>
31615 <stdarg.h>, <a href="#4">4</a>, <a href="#6.7.6.3">6.7.6.3</a>, <a href="#7.16">7.16</a> stdbool.h header, <a href="#4">4</a>, <a href="#7.18">7.18</a>, <a href="#7.30.7">7.30.7</a>, <a href="#H">H</a>
31616 <stdatomic.h>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.17">7.17</a> STDC, <a href="#6.10.6">6.10.6</a>, <a href="#6.11.8">6.11.8</a>
31617 <stdbool.h>, <a href="#4">4</a>, <a href="#7.18">7.18</a>, <a href="#7.30.7">7.30.7</a>, <a href="#H">H</a> stddef.h header, <a href="#4">4</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.3.2.3">6.3.2.3</a>, <a href="#6.4.4.4">6.4.4.4</a>,
31618 <stddef.h>, <a href="#4">4</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.3.2.3">6.3.2.3</a>, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#6.5.3.4">6.5.3.4</a>, <a href="#6.5.6">6.5.6</a>, <a href="#7.19">7.19</a>, <a href="#K.3.3">K.3.3</a>
31619 <a href="#6.4.5">6.4.5</a>, <a href="#6.5.3.4">6.5.3.4</a>, <a href="#6.5.6">6.5.6</a>, <a href="#7.19">7.19</a>, <a href="#K.3.3">K.3.3</a> stderr macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.3">7.21.3</a>
31620 <stdint.h>, <a href="#4">4</a>, <a href="#5.2.4.2">5.2.4.2</a>, <a href="#6.10.1">6.10.1</a>, <a href="#7.8">7.8</a>, <a href="#7.20">7.20</a>, stdin macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.6.4">7.21.6.4</a>,
31621 <a href="#7.30.8">7.30.8</a>, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a> <a href="#7.21.7.6">7.21.7.6</a>, <a href="#7.28.2.12">7.28.2.12</a>, <a href="#7.28.3.7">7.28.3.7</a>, <a href="#K.3.5.3.4">K.3.5.3.4</a>,
31622 <stdio.h>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21">7.21</a>, <a href="#7.30.9">7.30.9</a>, <a href="#F">F</a>, <a href="#K.3.5">K.3.5</a> <a href="#K.3.5.4.1">K.3.5.4.1</a>, <a href="#K.3.9.1.14">K.3.9.1.14</a>
31623 <stdlib.h>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.22">7.22</a>, <a href="#7.30.10">7.30.10</a>, <a href="#F">F</a>, stdint.h header, <a href="#4">4</a>, <a href="#5.2.4.2">5.2.4.2</a>, <a href="#6.10.1">6.10.1</a>, <a href="#7.8">7.8</a>, <a href="#7.20">7.20</a>,
31624 <a href="#K.3.1.4">K.3.1.4</a>, <a href="#K.3.6">K.3.6</a> <a href="#7.30.8">7.30.8</a>, <a href="#K.3.3">K.3.3</a>, <a href="#K.3.4">K.3.4</a>
31625 <string.h>, <a href="#7.23">7.23</a>, <a href="#7.30.11">7.30.11</a>, <a href="#K.3.7">K.3.7</a> stdio.h header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21">7.21</a>, <a href="#7.30.9">7.30.9</a>, <a href="#F">F</a>, <a href="#K.3.5">K.3.5</a>
31626 <tgmath.h>, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> stdlib.h header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.22">7.22</a>, <a href="#7.30.10">7.30.10</a>, <a href="#F">F</a>,
31627 <threads.h>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.25">7.25</a> <a href="#K.3.1.4">K.3.1.4</a>, <a href="#K.3.6">K.3.6</a>
31628 <time.h>, <a href="#7.26">7.26</a>, <a href="#K.3.8">K.3.8</a> stdout macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.6.3">7.21.6.3</a>,
31629 <uchar.h>, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#7.27">7.27</a> <a href="#7.21.7.8">7.21.7.8</a>, <a href="#7.21.7.9">7.21.7.9</a>, <a href="#7.28.2.11">7.28.2.11</a>, <a href="#7.28.3.9">7.28.3.9</a>
31630 <wchar.h>, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.28">7.28</a>, <a href="#7.30.12">7.30.12</a>, storage duration, <a href="#6.2.4">6.2.4</a>
31631 <a href="#F">F</a>, <a href="#K.3.9">K.3.9</a> storage order of array, <a href="#6.5.2.1">6.5.2.1</a>
31632 <wctype.h>, <a href="#7.29">7.29</a>, <a href="#7.30.13">7.30.13</a> storage unit (bit-field), <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.7.2.1">6.7.2.1</a>
31633 standard input stream, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> storage-class specifiers, <a href="#6.7.1">6.7.1</a>, <a href="#6.11.5">6.11.5</a>
31634 standard integer types, <a href="#6.2.5">6.2.5</a> strcat function, <a href="#7.23.3.1">7.23.3.1</a>
31635 standard output stream, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> strcat_s function, <a href="#K.3.7.2.1">K.3.7.2.1</a>
31636 standard signed integer types, <a href="#6.2.5">6.2.5</a> strchr function, <a href="#7.23.5.2">7.23.5.2</a>
31637 state-dependent encoding, <a href="#5.2.1.2">5.2.1.2</a>, <a href="#7.22.7">7.22.7</a>, <a href="#K.3.6.4">K.3.6.4</a> strcmp function, <a href="#7.23.4">7.23.4</a>, <a href="#7.23.4.2">7.23.4.2</a>
31638 statements, <a href="#6.8">6.8</a> strcoll function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.23.4.3">7.23.4.3</a>, <a href="#7.23.4.5">7.23.4.5</a>
31639 break, <a href="#6.8.6.3">6.8.6.3</a> strcpy function, <a href="#7.23.2.3">7.23.2.3</a>
31640 compound, <a href="#6.8.2">6.8.2</a> strcpy_s function, <a href="#K.3.7.1.3">K.3.7.1.3</a>
31641 continue, <a href="#6.8.6.2">6.8.6.2</a> strcspn function, <a href="#7.23.5.3">7.23.5.3</a>
31642 <!--page 692 indent 0-->
31643 streams, <a href="#7.21.2">7.21.2</a>, <a href="#7.22.4.4">7.22.4.4</a> <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.2.2">7.28.2.2</a>
31644 fully buffered, <a href="#7.21.3">7.21.3</a> strtoull function, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.22.1.2">7.22.1.2</a>, <a href="#7.22.1.4">7.22.1.4</a>
31645 line buffered, <a href="#7.21.3">7.21.3</a> strtoumax function, <a href="#7.8.2.3">7.8.2.3</a>
31646 orientation, <a href="#7.21.2">7.21.2</a> struct hack, see flexible array member
31647 standard error, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> struct lconv, <a href="#7.11">7.11</a>
31648 standard input, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> struct tm, <a href="#7.26.1">7.26.1</a>
31649 standard output, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.3">7.21.3</a> structure
31650 unbuffered, <a href="#7.21.3">7.21.3</a> arrow operator (->), <a href="#6.5.2.3">6.5.2.3</a>
31651 strerror function, <a href="#7.21.10.4">7.21.10.4</a>, <a href="#7.23.6.2">7.23.6.2</a> content, <a href="#6.7.2.3">6.7.2.3</a>
31652 strerror_s function, <a href="#K.3.7.4.2">K.3.7.4.2</a>, <a href="#K.3.7.4.3">K.3.7.4.3</a> dot operator (.), <a href="#6.5.2.3">6.5.2.3</a>
31653 strerrorlen_s function, <a href="#K.3.7.4.3">K.3.7.4.3</a> initialization, <a href="#6.7.9">6.7.9</a>
31654 strftime function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.26.3">7.26.3</a>, <a href="#7.26.3.5">7.26.3.5</a>, member alignment, <a href="#6.7.2.1">6.7.2.1</a>
31655 <a href="#7.28.5.1">7.28.5.1</a>, <a href="#K.3.8.2">K.3.8.2</a>, <a href="#K.3.8.2.1">K.3.8.2.1</a>, <a href="#K.3.8.2.2">K.3.8.2.2</a> member name space, <a href="#6.2.3">6.2.3</a>
31656 stricter, <a href="#6.2.8">6.2.8</a> member operator (.), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.3">6.5.2.3</a>
31657 strictly conforming program, <a href="#4">4</a> pointer operator (->), <a href="#6.5.2.3">6.5.2.3</a>
31658 string, <a href="#7.1.1">7.1.1</a> specifier, <a href="#6.7.2.1">6.7.2.1</a>
31659 comparison functions, <a href="#7.23.4">7.23.4</a> tag, <a href="#6.2.3">6.2.3</a>, <a href="#6.7.2.3">6.7.2.3</a>
31660 concatenation functions, <a href="#7.23.3">7.23.3</a>, <a href="#K.3.7.2">K.3.7.2</a> type, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2.1">6.7.2.1</a>
31661 conversion functions, <a href="#7.11.1.1">7.11.1.1</a> strxfrm function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.23.4.5">7.23.4.5</a>
31662 copying functions, <a href="#7.23.2">7.23.2</a>, <a href="#K.3.7.1">K.3.7.1</a> subnormal floating-point numbers, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31663 library function conventions, <a href="#7.23.1">7.23.1</a> subscripting, <a href="#6.5.2.1">6.5.2.1</a>
31664 literal, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1">5.2.1</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.4.5">6.4.5</a>, <a href="#6.5.1">6.5.1</a>, <a href="#6.7.9">6.7.9</a> subtraction assignment operator (-=), <a href="#6.5.16.2">6.5.16.2</a>
31665 miscellaneous functions, <a href="#7.23.6">7.23.6</a>, <a href="#K.3.7.4">K.3.7.4</a> subtraction operator (-), <a href="#6.2.6.2">6.2.6.2</a>, <a href="#6.5.6">6.5.6</a>, <a href="#F.3">F.3</a>, <a href="#G.5.2">G.5.2</a>
31666 numeric conversion functions, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.22.1">7.22.1</a> suffix
31667 search functions, <a href="#7.23.5">7.23.5</a>, <a href="#K.3.7.3">K.3.7.3</a> floating constant, <a href="#6.4.4.2">6.4.4.2</a>
31668 string handling header, <a href="#7.23">7.23</a>, <a href="#K.3.7">K.3.7</a> integer constant, <a href="#6.4.4.1">6.4.4.1</a>
31669 string.h header, <a href="#7.23">7.23</a>, <a href="#7.30.11">7.30.11</a>, <a href="#K.3.7">K.3.7</a> switch body, <a href="#6.8.4.2">6.8.4.2</a>
31670 stringizing, <a href="#6.10.3.2">6.10.3.2</a>, <a href="#6.10.9">6.10.9</a> switch case label, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.4.2">6.8.4.2</a>
31671 strlen function, <a href="#7.23.6.3">7.23.6.3</a> switch default label, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.4.2">6.8.4.2</a>
31672 strncat function, <a href="#7.23.3.2">7.23.3.2</a> switch statement, <a href="#6.8.1">6.8.1</a>, <a href="#6.8.4.2">6.8.4.2</a>
31673 strncat_s function, <a href="#K.3.7.2.2">K.3.7.2.2</a> swprintf function, <a href="#7.28.2.3">7.28.2.3</a>, <a href="#7.28.2.7">7.28.2.7</a>,
31674 strncmp function, <a href="#7.23.4">7.23.4</a>, <a href="#7.23.4.4">7.23.4.4</a> <a href="#K.3.9.1.3">K.3.9.1.3</a>, <a href="#K.3.9.1.4">K.3.9.1.4</a>
31675 strncpy function, <a href="#7.23.2.4">7.23.2.4</a> swprintf_s function, <a href="#K.3.9.1.3">K.3.9.1.3</a>, <a href="#K.3.9.1.4">K.3.9.1.4</a>
31676 strncpy_s function, <a href="#K.3.7.1.4">K.3.7.1.4</a> swscanf function, <a href="#7.28.2.4">7.28.2.4</a>, <a href="#7.28.2.8">7.28.2.8</a>
31677 strnlen_s function, <a href="#K.3.7.4.4">K.3.7.4.4</a> swscanf_s function, <a href="#K.3.9.1.5">K.3.9.1.5</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>
31678 stronger, <a href="#6.2.8">6.2.8</a> symbols, <a href="#3">3</a>
31679 strpbrk function, <a href="#7.23.5.4">7.23.5.4</a> synchronization operation, <a href="#5.1.2.4">5.1.2.4</a>
31680 strrchr function, <a href="#7.23.5.5">7.23.5.5</a> synchronize with, <a href="#5.1.2.4">5.1.2.4</a>
31681 strspn function, <a href="#7.23.5.6">7.23.5.6</a> syntactic categories, <a href="#6.1">6.1</a>
31682 strstr function, <a href="#7.23.5.7">7.23.5.7</a> syntax notation, <a href="#6.1">6.1</a>
31683 strtod function, <a href="#7.12.11.2">7.12.11.2</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22.1.3">7.22.1.3</a>, syntax rule precedence, <a href="#5.1.1.2">5.1.1.2</a>
31684 <a href="#7.28.2.2">7.28.2.2</a>, <a href="#F.3">F.3</a> syntax summary, language, <a href="#A">A</a>
31685 strtof function, <a href="#7.12.11.2">7.12.11.2</a>, <a href="#7.22.1.3">7.22.1.3</a>, <a href="#F.3">F.3</a> system function, <a href="#7.22.4.8">7.22.4.8</a>
31686 strtoimax function, <a href="#7.8.2.3">7.8.2.3</a>
31687 strtok function, <a href="#7.23.5.8">7.23.5.8</a> tab characters, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a>
31688 strtok_s function, <a href="#K.3.7.3.1">K.3.7.3.1</a> tag compatibility, <a href="#6.2.7">6.2.7</a>
31689 strtol function, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22.1.2">7.22.1.2</a>, tag name space, <a href="#6.2.3">6.2.3</a>
31690 <a href="#7.22.1.4">7.22.1.4</a>, <a href="#7.28.2.2">7.28.2.2</a> tags, <a href="#6.7.2.3">6.7.2.3</a>
31691 strtold function, <a href="#7.12.11.2">7.12.11.2</a>, <a href="#7.22.1.3">7.22.1.3</a>, <a href="#F.3">F.3</a> tan functions, <a href="#7.12.4.7">7.12.4.7</a>, <a href="#F.10.1.7">F.10.1.7</a>
31692 strtoll function, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.22.1.2">7.22.1.2</a>, <a href="#7.22.1.4">7.22.1.4</a> tan type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
31693 strtoul function, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22.1.2">7.22.1.2</a>, tanh functions, <a href="#7.12.5.6">7.12.5.6</a>, <a href="#F.10.2.6">F.10.2.6</a>
31694 <!--page 693 indent 0-->
31695 tanh type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> toupper function, <a href="#7.4.2.2">7.4.2.2</a>
31696 temporary lifetime, <a href="#6.2.4">6.2.4</a> towctrans function, <a href="#7.29.3.2.1">7.29.3.2.1</a>, <a href="#7.29.3.2.2">7.29.3.2.2</a>
31697 tentative definition, <a href="#6.9.2">6.9.2</a> towlower function, <a href="#7.29.3.1.1">7.29.3.1.1</a>, <a href="#7.29.3.2.1">7.29.3.2.1</a>
31698 terms, <a href="#3">3</a> towupper function, <a href="#7.29.3.1.2">7.29.3.1.2</a>, <a href="#7.29.3.2.1">7.29.3.2.1</a>
31699 text streams, <a href="#7.21.2">7.21.2</a>, <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.21.9.2">7.21.9.2</a>, <a href="#7.21.9.4">7.21.9.4</a> translation environment, <a href="#5">5</a>, <a href="#5.1.1">5.1.1</a>
31700 tgamma functions, <a href="#7.12.8.4">7.12.8.4</a>, <a href="#F.10.5.4">F.10.5.4</a> translation limits, <a href="#5.2.4.1">5.2.4.1</a>
31701 tgamma type-generic macro, <a href="#7.24">7.24</a> translation phases, <a href="#5.1.1.2">5.1.1.2</a>
31702 tgmath.h header, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a> translation unit, <a href="#5.1.1.1">5.1.1.1</a>, <a href="#6.9">6.9</a>
31703 thrd_create function, <a href="#7.25.1">7.25.1</a>, <a href="#7.25.5.1">7.25.5.1</a> trap, see perform a trap
31704 thrd_current function, <a href="#7.25.5.2">7.25.5.2</a> trap representation, <a href="#3.19.4">3.19.4</a>, <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.2.6.2">6.2.6.2</a>,
31705 thrd_detach function, <a href="#7.25.5.3">7.25.5.3</a> <a href="#6.3.2.3">6.3.2.3</a>, <a href="#6.5.2.3">6.5.2.3</a>
31706 thrd_equal function, <a href="#7.25.5.4">7.25.5.4</a> trigonometric functions
31707 thrd_exit function, <a href="#7.25.5.5">7.25.5.5</a> complex, <a href="#7.3.5">7.3.5</a>, <a href="#G.6.1">G.6.1</a>
31708 thrd_join function, <a href="#7.25.5.6">7.25.5.6</a> real, <a href="#7.12.4">7.12.4</a>, <a href="#F.10.1">F.10.1</a>
31709 thrd_sleep function, <a href="#7.25.5.7">7.25.5.7</a> trigraph sequences, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#5.2.1.1">5.2.1.1</a>
31710 thrd_start_t type, <a href="#7.25.1">7.25.1</a> true macro, <a href="#7.18">7.18</a>
31711 thrd_t type, <a href="#7.25.1">7.25.1</a> trunc functions, <a href="#7.12.9.8">7.12.9.8</a>, <a href="#F.10.6.8">F.10.6.8</a>
31712 thrd_yield function, <a href="#7.25.5.8">7.25.5.8</a> trunc type-generic macro, <a href="#7.24">7.24</a>
31713 thread of execution, <a href="#5.1.2.4">5.1.2.4</a>, <a href="#7.1.4">7.1.4</a>, <a href="#7.6">7.6</a>, <a href="#7.22.4.6">7.22.4.6</a> truncation, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#7.12.9.8">7.12.9.8</a>, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.5.3">7.21.5.3</a>
31714 thread storage duration, <a href="#6.2.4">6.2.4</a>, <a href="#7.6">7.6</a> truncation toward zero, <a href="#6.5.5">6.5.5</a>
31715 threads header, <a href="#7.25">7.25</a> tss_create function, <a href="#7.25.6.1">7.25.6.1</a>
31716 threads.h header, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.1.2">7.1.2</a>, <a href="#7.25">7.25</a> tss_delete function, <a href="#7.25.6.2">7.25.6.2</a>
31717 time TSS_DTOR_ITERATIONS macro, <a href="#7.25.1">7.25.1</a>
31718 broken down, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.3">7.26.2.3</a>, <a href="#7.26.3">7.26.3</a>, <a href="#7.26.3.1">7.26.3.1</a>, tss_dtor_t type, <a href="#7.25.1">7.25.1</a>
31719 <a href="#7.26.3.3">7.26.3.3</a>, <a href="#7.26.3.4">7.26.3.4</a>, <a href="#7.26.3.5">7.26.3.5</a>, <a href="#K.3.8.2.1">K.3.8.2.1</a>, tss_get function, <a href="#7.25.6.3">7.25.6.3</a>
31720 <a href="#K.3.8.2.3">K.3.8.2.3</a>, <a href="#K.3.8.2.4">K.3.8.2.4</a> tss_set function, <a href="#7.25.6.4">7.25.6.4</a>
31721 calendar, <a href="#7.26.1">7.26.1</a>, <a href="#7.26.2.2">7.26.2.2</a>, <a href="#7.26.2.3">7.26.2.3</a>, <a href="#7.26.2.4">7.26.2.4</a>, tss_t type, <a href="#7.25.1">7.25.1</a>
31722 <a href="#7.26.3.2">7.26.3.2</a>, <a href="#7.26.3.3">7.26.3.3</a>, <a href="#7.26.3.4">7.26.3.4</a>, <a href="#K.3.8.2.2">K.3.8.2.2</a>, two's complement, <a href="#6.2.6.2">6.2.6.2</a>, <a href="#7.20.1.1">7.20.1.1</a>
31723 <a href="#K.3.8.2.3">K.3.8.2.3</a>, <a href="#K.3.8.2.4">K.3.8.2.4</a> type category, <a href="#6.2.5">6.2.5</a>
31724 components, <a href="#7.26.1">7.26.1</a>, <a href="#K.3.8.1">K.3.8.1</a> type conversion, <a href="#6.3">6.3</a>
31725 conversion functions, <a href="#7.26.3">7.26.3</a>, <a href="#K.3.8.2">K.3.8.2</a> type definitions, <a href="#6.7.8">6.7.8</a>
31726 wide character, <a href="#7.28.5">7.28.5</a> type domain, <a href="#6.2.5">6.2.5</a>, <a href="#G.2">G.2</a>
31727 local, <a href="#7.26.1">7.26.1</a> type names, <a href="#6.7.7">6.7.7</a>
31728 manipulation functions, <a href="#7.26.2">7.26.2</a> type punning, <a href="#6.5.2.3">6.5.2.3</a>
31729 normalized broken down, <a href="#K.3.8.1">K.3.8.1</a>, <a href="#K.3.8.2.1">K.3.8.2.1</a> type qualifiers, <a href="#6.7.3">6.7.3</a>
31730 time function, <a href="#7.26.2.4">7.26.2.4</a> type specifiers, <a href="#6.7.2">6.7.2</a>
31731 time.h header, <a href="#7.26">7.26</a>, <a href="#K.3.8">K.3.8</a> type-generic macro, <a href="#7.24">7.24</a>, <a href="#G.7">G.7</a>
31732 time_t type, <a href="#7.26.1">7.26.1</a> typedef declaration, <a href="#6.7.8">6.7.8</a>
31733 TIME_UTC macro, <a href="#7.25.7.1">7.25.7.1</a> typedef storage-class specifier, <a href="#6.7.1">6.7.1</a>, <a href="#6.7.8">6.7.8</a>
31734 tm structure type, <a href="#7.26.1">7.26.1</a>, <a href="#7.28.1">7.28.1</a>, <a href="#K.3.8.1">K.3.8.1</a> types, <a href="#6.2.5">6.2.5</a>
31735 TMP_MAX macro, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.4.3">7.21.4.3</a>, <a href="#7.21.4.4">7.21.4.4</a> atomic, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.2.5">6.2.5</a>, <a href="#6.2.6.1">6.2.6.1</a>, <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.3">6.5.2.3</a>,
31736 TMP_MAX_S macro, <a href="#K.3.5">K.3.5</a>, <a href="#K.3.5.1.1">K.3.5.1.1</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a> <a href="#6.5.2.4">6.5.2.4</a>, <a href="#6.5.16.2">6.5.16.2</a>, <a href="#6.7.2.4">6.7.2.4</a>, <a href="#6.10.8.3">6.10.8.3</a>, <a href="#7.17.6">7.17.6</a>
31737 tmpfile function, <a href="#7.21.4.3">7.21.4.3</a>, <a href="#7.22.4.4">7.22.4.4</a> character, <a href="#6.7.9">6.7.9</a>
31738 tmpfile_s function, <a href="#K.3.5.1.1">K.3.5.1.1</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a> compatible, <a href="#6.2.7">6.2.7</a>, <a href="#6.7.2">6.7.2</a>, <a href="#6.7.3">6.7.3</a>, <a href="#6.7.6">6.7.6</a>
31739 tmpnam function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.4.3">7.21.4.3</a>, <a href="#7.21.4.4">7.21.4.4</a>, complex, <a href="#6.2.5">6.2.5</a>, <a href="#G">G</a>
31740 <a href="#K.3.5.1.2">K.3.5.1.2</a> composite, <a href="#6.2.7">6.2.7</a>
31741 tmpnam_s function, <a href="#K.3.5">K.3.5</a>, <a href="#K.3.5.1.1">K.3.5.1.1</a>, <a href="#K.3.5.1.2">K.3.5.1.2</a> const qualified, <a href="#6.7.3">6.7.3</a>
31742 token, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.4">6.4</a>, see also preprocessing tokens conversions, <a href="#6.3">6.3</a>
31743 token concatenation, <a href="#6.10.3.3">6.10.3.3</a> imaginary, <a href="#G">G</a>
31744 token pasting, <a href="#6.10.3.3">6.10.3.3</a> restrict qualified, <a href="#6.7.3">6.7.3</a>
31745 tolower function, <a href="#7.4.2.1">7.4.2.1</a> volatile qualified, <a href="#6.7.3">6.7.3</a>
31746 <!--page 694 indent 0-->
31747 uchar.h header, <a href="#6.4.4.4">6.4.4.4</a>, <a href="#6.4.5">6.4.5</a>, <a href="#7.27">7.27</a> universal character name, <a href="#6.4.3">6.4.3</a>
31748 UCHAR_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a> unnormalized floating-point numbers, <a href="#5.2.4.2.2">5.2.4.2.2</a>
31749 UINT_FASTN_MAX macros, <a href="#7.20.2.3">7.20.2.3</a> unqualified type, <a href="#6.2.5">6.2.5</a>
31750 uint_fastN_t types, <a href="#7.20.1.3">7.20.1.3</a> unqualified version of type, <a href="#6.2.5">6.2.5</a>
31751 uint_least16_t type, <a href="#7.27">7.27</a> unsequenced, <a href="#5.1.2.3">5.1.2.3</a>, <a href="#6.5">6.5</a>, <a href="#6.5.16">6.5.16</a>, see also
31752 uint_least32_t type, <a href="#7.27">7.27</a> indeterminately sequenced, sequenced
31753 UINT_LEASTN_MAX macros, <a href="#7.20.2.2">7.20.2.2</a> before
31754 uint_leastN_t types, <a href="#7.20.1.2">7.20.1.2</a> unsigned char type, <a href="#K.3.5.3.2">K.3.5.3.2</a>, <a href="#K.3.9.1.2">K.3.9.1.2</a>
31755 UINT_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a> unsigned integer suffix, u or <a href="#U">U</a>, <a href="#6.4.4.1">6.4.4.1</a>
31756 UINTMAX_C macro, <a href="#7.20.4.2">7.20.4.2</a> unsigned integer types, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.1.3">6.3.1.3</a>, <a href="#6.4.4.1">6.4.4.1</a>
31757 UINTMAX_MAX macro, <a href="#7.8.2.3">7.8.2.3</a>, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.20.2.5">7.20.2.5</a> unsigned type conversion, <a href="#6.3.1.1">6.3.1.1</a>, <a href="#6.3.1.3">6.3.1.3</a>,
31758 uintmax_t type, <a href="#7.20.1.5">7.20.1.5</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#6.3.1.4">6.3.1.4</a>, <a href="#6.3.1.8">6.3.1.8</a>
31759 <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a> unsigned types, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2">6.7.2</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>,
31760 UINTN_C macros, <a href="#7.20.4.1">7.20.4.1</a> <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31761 UINTN_MAX macros, <a href="#7.20.2.1">7.20.2.1</a> unspecified behavior, <a href="#3.4.4">3.4.4</a>, <a href="#4">4</a>, <a href="#J.1">J.1</a>
31762 uintN_t types, <a href="#7.20.1.1">7.20.1.1</a> unspecified value, <a href="#3.19.3">3.19.3</a>
31763 UINTPTR_MAX macro, <a href="#7.20.2.4">7.20.2.4</a> uppercase letter, <a href="#5.2.1">5.2.1</a>
31764 uintptr_t type, <a href="#7.20.1.4">7.20.1.4</a> use of library functions, <a href="#7.1.4">7.1.4</a>
31765 ULLONG_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, USHRT_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>
31766 <a href="#7.28.4.1.2">7.28.4.1.2</a> usual arithmetic conversions, <a href="#6.3.1.8">6.3.1.8</a>, <a href="#6.5.5">6.5.5</a>, <a href="#6.5.6">6.5.6</a>,
31767 ULONG_MAX macro, <a href="#5.2.4.2.1">5.2.4.2.1</a>, <a href="#7.22.1.4">7.22.1.4</a>, <a href="#6.5.8">6.5.8</a>, <a href="#6.5.9">6.5.9</a>, <a href="#6.5.10">6.5.10</a>, <a href="#6.5.11">6.5.11</a>, <a href="#6.5.12">6.5.12</a>, <a href="#6.5.15">6.5.15</a>
31768 <a href="#7.28.4.1.2">7.28.4.1.2</a> UTF-16, <a href="#6.10.8.2">6.10.8.2</a>
31769 unary arithmetic operators, <a href="#6.5.3.3">6.5.3.3</a> UTF-32, <a href="#6.10.8.2">6.10.8.2</a>
31770 unary expression, <a href="#6.5.3">6.5.3</a> UTF-8 string literal, see string literal
31771 unary minus operator (-), <a href="#6.5.3.3">6.5.3.3</a>, <a href="#F.3">F.3</a> utilities, general, <a href="#7.22">7.22</a>, <a href="#K.3.6">K.3.6</a>
31772 unary operators, <a href="#6.5.3">6.5.3</a> wide string, <a href="#7.28.4">7.28.4</a>, <a href="#K.3.9.2">K.3.9.2</a>
31773 unary plus operator (+), <a href="#6.5.3.3">6.5.3.3</a>
31774 unbuffered stream, <a href="#7.21.3">7.21.3</a> va_arg macro, <a href="#7.16">7.16</a>, <a href="#7.16.1">7.16.1</a>, <a href="#7.16.1.1">7.16.1.1</a>, <a href="#7.16.1.2">7.16.1.2</a>,
31775 undef preprocessing directive, <a href="#6.10.3.5">6.10.3.5</a>, <a href="#7.1.3">7.1.3</a>, <a href="#7.16.1.4">7.16.1.4</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.9">7.21.6.9</a>, <a href="#7.21.6.10">7.21.6.10</a>,
31776 <a href="#7.1.4">7.1.4</a> <a href="#7.21.6.11">7.21.6.11</a>, <a href="#7.21.6.12">7.21.6.12</a>, <a href="#7.21.6.13">7.21.6.13</a>, <a href="#7.21.6.14">7.21.6.14</a>,
31777 undefined behavior, <a href="#3.4.3">3.4.3</a>, <a href="#4">4</a>, <a href="#J.2">J.2</a> <a href="#7.28.2.5">7.28.2.5</a>, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.7">7.28.2.7</a>, <a href="#7.28.2.8">7.28.2.8</a>,
31778 underscore character, <a href="#6.4.2.1">6.4.2.1</a> <a href="#7.28.2.9">7.28.2.9</a>, <a href="#7.28.2.10">7.28.2.10</a>, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>,
31779 underscore, leading, in identifier, <a href="#7.1.3">7.1.3</a> <a href="#K.3.5.3.14">K.3.5.3.14</a>, <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a>
31780 ungetc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.7.10">7.21.7.10</a>, <a href="#7.21.9.2">7.21.9.2</a>, va_copy macro, <a href="#7.1.3">7.1.3</a>, <a href="#7.16">7.16</a>, <a href="#7.16.1">7.16.1</a>, <a href="#7.16.1.1">7.16.1.1</a>,
31781 <a href="#7.21.9.3">7.21.9.3</a> <a href="#7.16.1.2">7.16.1.2</a>, <a href="#7.16.1.3">7.16.1.3</a>
31782 ungetwc function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3.10">7.28.3.10</a> va_end macro, <a href="#7.1.3">7.1.3</a>, <a href="#7.16">7.16</a>, <a href="#7.16.1">7.16.1</a>, <a href="#7.16.1.3">7.16.1.3</a>,
31783 Unicode, <a href="#7.27">7.27</a>, see also char16_t type, <a href="#7.16.1.4">7.16.1.4</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.9">7.21.6.9</a>, <a href="#7.21.6.10">7.21.6.10</a>,
31784 char32_t type, wchar_t type <a href="#7.21.6.11">7.21.6.11</a>, <a href="#7.21.6.12">7.21.6.12</a>, <a href="#7.21.6.13">7.21.6.13</a>, <a href="#7.21.6.14">7.21.6.14</a>,
31785 Unicode required set, <a href="#6.10.8.2">6.10.8.2</a> <a href="#7.28.2.5">7.28.2.5</a>, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.2.7">7.28.2.7</a>, <a href="#7.28.2.8">7.28.2.8</a>,
31786 union <a href="#7.28.2.9">7.28.2.9</a>, <a href="#7.28.2.10">7.28.2.10</a>, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>,
31787 arrow operator (->), <a href="#6.5.2.3">6.5.2.3</a> <a href="#K.3.5.3.14">K.3.5.3.14</a>, <a href="#K.3.9.1.7">K.3.9.1.7</a>, <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a>
31788 content, <a href="#6.7.2.3">6.7.2.3</a> va_list type, <a href="#7.16">7.16</a>, <a href="#7.16.1.3">7.16.1.3</a>
31789 dot operator (.), <a href="#6.5.2.3">6.5.2.3</a> va_start macro, <a href="#7.16">7.16</a>, <a href="#7.16.1">7.16.1</a>, <a href="#7.16.1.1">7.16.1.1</a>,
31790 initialization, <a href="#6.7.9">6.7.9</a> <a href="#7.16.1.2">7.16.1.2</a>, <a href="#7.16.1.3">7.16.1.3</a>, <a href="#7.16.1.4">7.16.1.4</a>, <a href="#7.21.6.8">7.21.6.8</a>,
31791 member alignment, <a href="#6.7.2.1">6.7.2.1</a> <a href="#7.21.6.9">7.21.6.9</a>, <a href="#7.21.6.10">7.21.6.10</a>, <a href="#7.21.6.11">7.21.6.11</a>, <a href="#7.21.6.12">7.21.6.12</a>,
31792 member name space, <a href="#6.2.3">6.2.3</a> <a href="#7.21.6.13">7.21.6.13</a>, <a href="#7.21.6.14">7.21.6.14</a>, <a href="#7.28.2.5">7.28.2.5</a>, <a href="#7.28.2.6">7.28.2.6</a>,
31793 member operator (.), <a href="#6.3.2.1">6.3.2.1</a>, <a href="#6.5.2.3">6.5.2.3</a> <a href="#7.28.2.7">7.28.2.7</a>, <a href="#7.28.2.8">7.28.2.8</a>, <a href="#7.28.2.9">7.28.2.9</a>, <a href="#7.28.2.10">7.28.2.10</a>,
31794 pointer operator (->), <a href="#6.5.2.3">6.5.2.3</a> <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a>, <a href="#K.3.9.1.7">K.3.9.1.7</a>,
31795 specifier, <a href="#6.7.2.1">6.7.2.1</a> <a href="#K.3.9.1.10">K.3.9.1.10</a>, <a href="#K.3.9.1.12">K.3.9.1.12</a>
31796 tag, <a href="#6.2.3">6.2.3</a>, <a href="#6.7.2.3">6.7.2.3</a> value, <a href="#3.19">3.19</a>
31797 type, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.2.1">6.7.2.1</a> value bits, <a href="#6.2.6.2">6.2.6.2</a>
31798 <!--page 695 indent 0-->
31799 variable arguments, <a href="#6.10.3">6.10.3</a>, <a href="#7.16">7.16</a> vswscanf function, <a href="#7.28.2.8">7.28.2.8</a>
31800 variable arguments header, <a href="#7.16">7.16</a> vswscanf_s function, <a href="#K.3.9.1.10">K.3.9.1.10</a>
31801 variable length array, <a href="#6.7.6">6.7.6</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.10.8.3">6.10.8.3</a> vwprintf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.9">7.28.2.9</a>, <a href="#K.3.9.1.11">K.3.9.1.11</a>
31802 variably modified type, <a href="#6.7.6">6.7.6</a>, <a href="#6.7.6.2">6.7.6.2</a>, <a href="#6.10.8.3">6.10.8.3</a> vwprintf_s function, <a href="#K.3.9.1.11">K.3.9.1.11</a>
31803 vertical-tab character, <a href="#5.2.1">5.2.1</a>, <a href="#6.4">6.4</a> vwscanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.10">7.28.2.10</a>, <a href="#7.28.3.10">7.28.3.10</a>
31804 vertical-tab escape sequence (\v), <a href="#5.2.2">5.2.2</a>, <a href="#6.4.4.4">6.4.4.4</a>, vwscanf_s function, <a href="#K.3.9.1.12">K.3.9.1.12</a>
31805 <a href="#7.4.1.10">7.4.1.10</a>
31806 vfprintf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#K.3.5.3.8">K.3.5.3.8</a> warnings, <a href="#I">I</a>
31807 vfprintf_s function, <a href="#K.3.5.3.8">K.3.5.3.8</a>, <a href="#K.3.5.3.9">K.3.5.3.9</a>, wchar.h header, <a href="#5.2.4.2.2">5.2.4.2.2</a>, <a href="#7.21.1">7.21.1</a>, <a href="#7.28">7.28</a>, <a href="#7.30.12">7.30.12</a>,
31808 <a href="#K.3.5.3.11">K.3.5.3.11</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a> <a href="#F">F</a>, <a href="#K.3.9">K.3.9</a>
31809 vfscanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.9">7.21.6.9</a> WCHAR_MAX macro, <a href="#7.20.3">7.20.3</a>, <a href="#7.28.1">7.28.1</a>
31810 vfscanf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, WCHAR_MIN macro, <a href="#7.20.3">7.20.3</a>, <a href="#7.28.1">7.28.1</a>
31811 <a href="#K.3.5.3.14">K.3.5.3.14</a> wchar_t type, <a href="#3.7.3">3.7.3</a>, <a href="#6.4.5">6.4.5</a>, <a href="#6.7.9">6.7.9</a>, <a href="#6.10.8.2">6.10.8.2</a>, <a href="#7.19">7.19</a>,
31812 vfwprintf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.5">7.28.2.5</a>, <a href="#K.3.9.1.6">K.3.9.1.6</a> <a href="#7.20.3">7.20.3</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.22">7.22</a>, <a href="#7.28.1">7.28.1</a>,
31813 vfwprintf_s function, <a href="#K.3.9.1.6">K.3.9.1.6</a> <a href="#7.28.2.1">7.28.2.1</a>, <a href="#7.28.2.2">7.28.2.2</a>
31814 vfwscanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.6">7.28.2.6</a>, <a href="#7.28.3.10">7.28.3.10</a> wcrtomb function, <a href="#7.21.3">7.21.3</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>,
31815 vfwscanf_s function, <a href="#K.3.9.1.7">K.3.9.1.7</a> <a href="#7.28.6.3.3">7.28.6.3.3</a>, <a href="#7.28.6.4.2">7.28.6.4.2</a>, <a href="#K.3.6.5.2">K.3.6.5.2</a>, <a href="#K.3.9.3.1">K.3.9.3.1</a>,
31816 visibility of identifier, <a href="#6.2.1">6.2.1</a> <a href="#K.3.9.3.2.2">K.3.9.3.2.2</a>
31817 visible sequence of side effects, <a href="#5.1.2.4">5.1.2.4</a> wcrtomb_s function, <a href="#K.3.9.3.1">K.3.9.3.1</a>, <a href="#K.3.9.3.1.1">K.3.9.3.1.1</a>
31818 visible side effect, <a href="#5.1.2.4">5.1.2.4</a> wcscat function, <a href="#7.28.4.3.1">7.28.4.3.1</a>
31819 VLA, see variable length array wcscat_s function, <a href="#K.3.9.2.2.1">K.3.9.2.2.1</a>
31820 void expression, <a href="#6.3.2.2">6.3.2.2</a> wcschr function, <a href="#7.28.4.5.1">7.28.4.5.1</a>
31821 void function parameter, <a href="#6.7.6.3">6.7.6.3</a> wcscmp function, <a href="#7.28.4.4.1">7.28.4.4.1</a>, <a href="#7.28.4.4.4">7.28.4.4.4</a>
31822 void type, <a href="#6.2.5">6.2.5</a>, <a href="#6.3.2.2">6.3.2.2</a>, <a href="#6.7.2">6.7.2</a>, <a href="#K.3.5.3.2">K.3.5.3.2</a>, wcscoll function, <a href="#7.28.4.4.2">7.28.4.4.2</a>, <a href="#7.28.4.4.4">7.28.4.4.4</a>
31823 <a href="#K.3.9.1.2">K.3.9.1.2</a> wcscpy function, <a href="#7.28.4.2.1">7.28.4.2.1</a>
31824 void type conversion, <a href="#6.3.2.2">6.3.2.2</a> wcscpy_s function, <a href="#K.3.9.2.1.1">K.3.9.2.1.1</a>
31825 volatile storage, <a href="#5.1.2.3">5.1.2.3</a> wcscspn function, <a href="#7.28.4.5.2">7.28.4.5.2</a>
31826 volatile type qualifier, <a href="#6.7.3">6.7.3</a> wcsftime function, <a href="#7.11.1.1">7.11.1.1</a>, <a href="#7.28.5.1">7.28.5.1</a>
31827 volatile-qualified type, <a href="#6.2.5">6.2.5</a>, <a href="#6.7.3">6.7.3</a> wcslen function, <a href="#7.28.4.6.1">7.28.4.6.1</a>
31828 vprintf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.10">7.21.6.10</a>, wcsncat function, <a href="#7.28.4.3.2">7.28.4.3.2</a>
31829 <a href="#K.3.5.3.10">K.3.5.3.10</a> wcsncat_s function, <a href="#K.3.9.2.2.2">K.3.9.2.2.2</a>
31830 vprintf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.10">K.3.5.3.10</a>, wcsncmp function, <a href="#7.28.4.4.3">7.28.4.4.3</a>
31831 <a href="#K.3.5.3.11">K.3.5.3.11</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a> wcsncpy function, <a href="#7.28.4.2.2">7.28.4.2.2</a>
31832 vscanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.11">7.21.6.11</a> wcsncpy_s function, <a href="#K.3.9.2.1.2">K.3.9.2.1.2</a>
31833 vscanf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, wcsnlen_s function, <a href="#K.3.9.2.4.1">K.3.9.2.4.1</a>
31834 <a href="#K.3.5.3.14">K.3.5.3.14</a> wcspbrk function, <a href="#7.28.4.5.3">7.28.4.5.3</a>
31835 vsnprintf function, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.12">7.21.6.12</a>, wcsrchr function, <a href="#7.28.4.5.4">7.28.4.5.4</a>
31836 <a href="#K.3.5.3.12">K.3.5.3.12</a> wcsrtombs function, <a href="#7.28.6.4.2">7.28.6.4.2</a>, <a href="#K.3.9.3.2">K.3.9.3.2</a>
31837 vsnprintf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, wcsrtombs_s function, <a href="#K.3.9.3.2">K.3.9.3.2</a>, <a href="#K.3.9.3.2.2">K.3.9.3.2.2</a>
31838 <a href="#K.3.5.3.12">K.3.5.3.12</a>, <a href="#K.3.5.3.13">K.3.5.3.13</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a> wcsspn function, <a href="#7.28.4.5.5">7.28.4.5.5</a>
31839 vsnwprintf_s function, <a href="#K.3.9.1.8">K.3.9.1.8</a>, <a href="#K.3.9.1.9">K.3.9.1.9</a> wcsstr function, <a href="#7.28.4.5.6">7.28.4.5.6</a>
31840 vsprintf function, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.13">7.21.6.13</a>, wcstod function, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>
31841 <a href="#K.3.5.3.13">K.3.5.3.13</a> wcstod function, <a href="#7.28.4.1.1">7.28.4.1.1</a>
31842 vsprintf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, wcstof function, <a href="#7.28.4.1.1">7.28.4.1.1</a>
31843 <a href="#K.3.5.3.12">K.3.5.3.12</a>, <a href="#K.3.5.3.13">K.3.5.3.13</a>, <a href="#K.3.5.3.14">K.3.5.3.14</a> wcstoimax function, <a href="#7.8.2.4">7.8.2.4</a>
31844 vsscanf function, <a href="#7.21.6.8">7.21.6.8</a>, <a href="#7.21.6.14">7.21.6.14</a> wcstok function, <a href="#7.28.4.5.7">7.28.4.5.7</a>
31845 vsscanf_s function, <a href="#K.3.5.3.9">K.3.5.3.9</a>, <a href="#K.3.5.3.11">K.3.5.3.11</a>, wcstok_s function, <a href="#K.3.9.2.3.1">K.3.9.2.3.1</a>
31846 <a href="#K.3.5.3.14">K.3.5.3.14</a> wcstol function, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>,
31847 vswprintf function, <a href="#7.28.2.7">7.28.2.7</a>, <a href="#K.3.9.1.8">K.3.9.1.8</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>
31848 <a href="#K.3.9.1.9">K.3.9.1.9</a> wcstold function, <a href="#7.28.4.1.1">7.28.4.1.1</a>
31849 vswprintf_s function, <a href="#K.3.9.1.8">K.3.9.1.8</a>, <a href="#K.3.9.1.9">K.3.9.1.9</a> wcstoll function, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a>
31850 <!--page 696 indent 0-->
31851 wcstombs function, <a href="#7.22.8.2">7.22.8.2</a>, <a href="#7.28.6.4">7.28.6.4</a> <a href="#7.29.1">7.29.1</a>
31852 wcstombs_s function, <a href="#K.3.6.5.2">K.3.6.5.2</a> wmemchr function, <a href="#7.28.4.5.8">7.28.4.5.8</a>
31853 wcstoul function, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.21.6.2">7.21.6.2</a>, <a href="#7.28.2.2">7.28.2.2</a>, wmemcmp function, <a href="#7.28.4.4.5">7.28.4.4.5</a>
31854 <a href="#7.28.4.1.2">7.28.4.1.2</a> wmemcpy function, <a href="#7.28.4.2.3">7.28.4.2.3</a>
31855 wcstoull function, <a href="#7.8.2.4">7.8.2.4</a>, <a href="#7.28.4.1.2">7.28.4.1.2</a> wmemcpy_s function, <a href="#K.3.9.2.1.3">K.3.9.2.1.3</a>
31856 wcstoumax function, <a href="#7.8.2.4">7.8.2.4</a> wmemmove function, <a href="#7.28.4.2.4">7.28.4.2.4</a>
31857 wcsxfrm function, <a href="#7.28.4.4.4">7.28.4.4.4</a> wmemmove_s function, <a href="#K.3.9.2.1.4">K.3.9.2.1.4</a>
31858 wctob function, <a href="#7.28.6.1.2">7.28.6.1.2</a>, <a href="#7.29.2.1">7.29.2.1</a> wmemset function, <a href="#7.28.4.6.2">7.28.4.6.2</a>
31859 wctomb function, <a href="#7.22.7.3">7.22.7.3</a>, <a href="#7.22.8.2">7.22.8.2</a>, <a href="#7.28.6.3">7.28.6.3</a> wprintf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.9">7.28.2.9</a>, <a href="#7.28.2.11">7.28.2.11</a>,
31860 wctomb_s function, <a href="#K.3.6.4.1">K.3.6.4.1</a> <a href="#K.3.9.1.13">K.3.9.1.13</a>
31861 wctrans function, <a href="#7.29.3.2.1">7.29.3.2.1</a>, <a href="#7.29.3.2.2">7.29.3.2.2</a> wprintf_s function, <a href="#K.3.9.1.13">K.3.9.1.13</a>
31862 wctrans_t type, <a href="#7.29.1">7.29.1</a>, <a href="#7.29.3.2.2">7.29.3.2.2</a> wscanf function, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.2.10">7.28.2.10</a>, <a href="#7.28.2.12">7.28.2.12</a>,
31863 wctype function, <a href="#7.29.2.2.1">7.29.2.2.1</a>, <a href="#7.29.2.2.2">7.29.2.2.2</a> <a href="#7.28.3.10">7.28.3.10</a>
31864 wctype.h header, <a href="#7.29">7.29</a>, <a href="#7.30.13">7.30.13</a> wscanf_s function, <a href="#K.3.9.1.12">K.3.9.1.12</a>, <a href="#K.3.9.1.14">K.3.9.1.14</a>
31865 wctype_t type, <a href="#7.29.1">7.29.1</a>, <a href="#7.29.2.2.2">7.29.2.2.2</a>
31866 weaker, <a href="#6.2.8">6.2.8</a> xor macro, <a href="#7.9">7.9</a>
31867 WEOF macro, <a href="#7.28.1">7.28.1</a>, <a href="#7.28.3.1">7.28.3.1</a>, <a href="#7.28.3.3">7.28.3.3</a>, <a href="#7.28.3.6">7.28.3.6</a>, xor_eq macro, <a href="#7.9">7.9</a>
31868 <a href="#7.28.3.7">7.28.3.7</a>, <a href="#7.28.3.8">7.28.3.8</a>, <a href="#7.28.3.9">7.28.3.9</a>, <a href="#7.28.3.10">7.28.3.10</a>, xtime type, <a href="#7.25.1">7.25.1</a>, <a href="#7.25.3.5">7.25.3.5</a>, <a href="#7.25.4.4">7.25.4.4</a>, <a href="#7.25.5.7">7.25.5.7</a>,
31869 <a href="#7.28.6.1.1">7.28.6.1.1</a>, <a href="#7.29.1">7.29.1</a> <a href="#7.25.7.1">7.25.7.1</a>
31870 while statement, <a href="#6.8.5.1">6.8.5.1</a> xtime_get function, <a href="#7.25.7.1">7.25.7.1</a>
31871 white space, <a href="#5.1.1.2">5.1.1.2</a>, <a href="#6.4">6.4</a>, <a href="#6.10">6.10</a>, <a href="#7.4.1.10">7.4.1.10</a>,
31872 <a href="#7.29.2.1.10">7.29.2.1.10</a>
31873 white-space characters, <a href="#6.4">6.4</a>
31874 wide character, <a href="#3.7.3">3.7.3</a>
31875 case mapping functions, <a href="#7.29.3.1">7.29.3.1</a>
31876 extensible, <a href="#7.29.3.2">7.29.3.2</a>
31877 classification functions, <a href="#7.29.2.1">7.29.2.1</a>
31878 extensible, <a href="#7.29.2.2">7.29.2.2</a>
31879 constant, <a href="#6.4.4.4">6.4.4.4</a>
31880 formatted input/output functions, <a href="#7.28.2">7.28.2</a>,
31881 <a href="#K.3.9.1">K.3.9.1</a>
31882 input functions, <a href="#7.21.1">7.21.1</a>
31883 input/output functions, <a href="#7.21.1">7.21.1</a>, <a href="#7.28.3">7.28.3</a>
31884 output functions, <a href="#7.21.1">7.21.1</a>
31885 single-byte conversion functions, <a href="#7.28.6.1">7.28.6.1</a>
31886 wide string, <a href="#7.1.1">7.1.1</a>
31887 wide string comparison functions, <a href="#7.28.4.4">7.28.4.4</a>
31888 wide string concatenation functions, <a href="#7.28.4.3">7.28.4.3</a>,
31889 <a href="#K.3.9.2.2">K.3.9.2.2</a>
31890 wide string copying functions, <a href="#7.28.4.2">7.28.4.2</a>, <a href="#K.3.9.2.1">K.3.9.2.1</a>
31891 wide string literal, see string literal
31892 wide string miscellaneous functions, <a href="#7.28.4.6">7.28.4.6</a>,
31893 <a href="#K.3.9.2.4">K.3.9.2.4</a>
31894 wide string numeric conversion functions, <a href="#7.8.2.4">7.8.2.4</a>,
31895 <a href="#7.28.4.1">7.28.4.1</a>
31896 wide string search functions, <a href="#7.28.4.5">7.28.4.5</a>, <a href="#K.3.9.2.3">K.3.9.2.3</a>
31897 wide-oriented stream, <a href="#7.21.2">7.21.2</a>
31898 width, <a href="#6.2.6.2">6.2.6.2</a>
31899 WINT_MAX macro, <a href="#7.20.3">7.20.3</a>
31900 WINT_MIN macro, <a href="#7.20.3">7.20.3</a>
31901 wint_t type, <a href="#7.20.3">7.20.3</a>, <a href="#7.21.6.1">7.21.6.1</a>, <a href="#7.28.1">7.28.1</a>, <a href="#7.28.2.1">7.28.2.1</a>,