1、 INCITS/ISO/IEC 9899-20112012 (ISO/IEC 9899-2011, IDT) Information technology Programming languages C Copyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,-INCITS/ISO/IEC 9899-2011201
2、2 PDF disclaimer This PDF file may contain embedded typefaces. In accordance with Adobes licensing policy, this file may be printed or viewed but shall not be edited unless the typefaces which are embedded are licensed to and installed on the computer performing the editing. In downloading this file
3、, parties accept therein the responsibility of not infringing Adobes licensing policy. The ISO Central Secretariat accepts no liability in this area. Adobe is a trademark of Adobe Systems Incorporated. Details of the software products used to create this PDF file can be found in the General Info rel
4、ative to the file; the PDF-creation parameters were optimized for printing. Every care has been taken to ensure that the file is suitable for use by ISO member bodies. In the unlikely event that a problem relating to it is found, please inform the Central Secretariat at the address given below. Adop
5、ted by INCITS (InterNational Committee for Information Technology Standards) as an American National Standard. Date of ANSI Approval: 5/23/2012 Published by American National Standards Institute, 25 West 43rd Street, New York, New York 10036 Copyright 2012 by Information Technology Industry Council
6、(ITI). All rights reserved. These materials are subject to copyright claims of International Standardization Organization (ISO), International Electrotechnical Commission (IEC), American National Standards Institute (ANSI), and Information Technology Industry Council (ITI). Not for resale. No part o
7、f this publication may be reproduced in any form, including an electronic retrieval system, without the prior written permission of ITI. All requests pertaining to this standard should be submitted to ITI, 1250 Eye Street NW, Washington, DC 20005. Printed in the United States of America ii ITIC 2012
8、 All rights reserved Copyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,- ISO/IEC 2011 All rights reserved ISO/IEC 9899:2011 (E)ContentsForeword . xiiiIntroduction xvii1. Scope . 12
9、. Normative references . 23. Terms, definitions, and symbols . 34. Conformance 85. Environment 105.1 Conceptual models . 105.1.1 Translation environment 105.1.2 Execution environments 125.2 Environmental considerations . 225.2.1 Character sets 225.2.2 Character display semantics 245.2.3 Signals and
10、interrupts . 255.2.4 Environmental limits . 256. Language 356.1 Notation 356.2 Concepts . 356.2.1 Scopes of identifiers . 356.2.2 Linkages of identifiers . 366.2.3 Name spaces of identifiers . 376.2.4 Storage durations of objects 386.2.5 Types . 396.2.6 Representations of types 446.2.7 Compatible ty
11、pe and composite type . 476.2.8 Alignment of objects . 486.3 Conversions 506.3.1 Arithmetic operands . 506.3.2 Other operands . 546.4 Lexical elements 576.4.1 Keywords 586.4.2 Identifiers 596.4.3 Universal character names . 616.4.4 Constants 626.4.5 String literals 706.4.6 Punctuators . 726.4.7 Head
12、er names 736.4.8 Preprocessing numbers 746.4.9 Comments . 75Contents iiiCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,-ISO/IEC 9899:2011 (E) ISO/IEC 2011 All rights reserved6.5
13、 Expressions 766.5.1 Primary expressions . 786.5.2 Postfix operators . 796.5.3 Unary operators . 886.5.4 Cast operators 916.5.5 Multiplicative operators 926.5.6 Additive operators 926.5.7 Bitwise shift operators . 946.5.8 Relational operators 956.5.9 Equality operators 966.5.10 Bitwise AND operator
14、. 976.5.11 Bitwise exclusive OR operator . 986.5.12 Bitwise inclusive OR operator 986.5.13 Logical AND operator . 996.5.14 Logical OR operator . 996.5.15 Conditional operator .1006.5.16 Assignment operators .1016.5.17 Comma operator .1056.6 Constant expressions .1066.7 Declarations 1086.7.1 Storage-
15、class specifiers 1096.7.2 Type specifiers 1116.7.3 Type qualifiers 1216.7.4 Function specifiers 1256.7.5 Alignment specifier 1276.7.6 Declarators .1286.7.7 Type names .1366.7.8 Type definitions .1376.7.9 Initialization 1396.7.10 Static assertions .1456.8 Statements and blocks 1466.8.1 Labeled statem
16、ents 1466.8.2 Compound statement .1476.8.3 Expression and null statements .1476.8.4 Selection statements .1486.8.5 Iteration statements 1506.8.6 Jump statements .1516.9 External definitions .1556.9.1 Function definitions 1566.9.2 External object definitions .1586.10 Preprocessing directives .1606.10
17、.1 Conditional inclusion .1626.10.2 Source file inclusion .1646.10.3 Macro replacement 166iv ContentsCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,- ISO/IEC 2011 All rights res
18、erved ISO/IEC 9899:2011 (E)6.10.4 Line control .1736.10.5 Error directive 1746.10.6 Pragma directive .1746.10.7 Null directive 1756.10.8 Predefined macro names 1756.10.9 Pragma operator .1786.11 Future language directions 1796.11.1 Floating types 1796.11.2 Linkages of identifiers .1796.11.3 External
19、 names .1796.11.4 Character escape sequences 1796.11.5 Storage-class specifiers 1796.11.6 Function declarators .1796.11.7 Function definitions 1796.11.8 Pragma directives 1796.11.9 Predefined macro names 1797. Library .1807.1 Introduction 1807.1.1 Definitions of terms 1807.1.2 Standard headers .1817
20、.1.3 Reserved identifiers 1827.1.4 Use of library functions 1837.2 Diagnostics 1867.2.1 Program diagnostics .1867.3 Complex arithmetic 1887.3.1 Introduction .1887.3.2 Conventions .1897.3.3 Branch cuts .1897.3.4 The CX_LIMITED_RANGE pragma .1897.3.5 Trigonometric functions 1907.3.6 Hyperbolic functio
21、ns .1927.3.7 Exponential and logarithmic functions 1947.3.8 Power and absolute-value functions .1957.3.9 Manipulation functions 1967.4 Character handling 2007.4.1 Character classification functions 2007.4.2 Character case mapping functions 2037.5 Errors .2057.6 Floating-point environment .2067.6.1 T
22、he FENV_ACCESS pragma 2087.6.2 Floating-point exceptions .2097.6.3 Rounding 2127.6.4 Environment 2137.7 Characteristics of floating types .216Contents vCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted withou
23、t license from IHS-,-,-ISO/IEC 9899:2011 (E) ISO/IEC 2011 All rights reserved7.8 Format conversion of integer types 2177.8.1 Macros for format specifiers 2177.8.2 Functions for greatest-width integer types .2187.9 Alternative spellings .2217.10 Sizes of integer types 2227.11 Localization 2237.11.1 L
24、ocale control 2247.11.2 Numeric formatting convention inquiry 2257.12 Mathematics .2317.12.1 Treatment of error conditions 2337.12.2 The FP_CONTRACT pragma 2357.12.3 Classification macros .2357.12.4 Trigonometric functions 2387.12.5 Hyperbolic functions .2407.12.6 Exponential and logarithmic functio
25、ns 2427.12.7 Power and absolute-value functions .2477.12.8 Error and gamma functions .2497.12.9 Nearest integer functions 2517.12.10 Remainder functions .2547.12.11 Manipulation functions 2557.12.12 Maximum, minimum, and positive difference functions .2577.12.13 Floating multiply-add .2587.12.14 Com
26、parison macros 2597.13 Nonlocal jumps 2627.13.1 Save calling environment .2627.13.2 Restore calling environment 2637.14 Signal handling .2657.14.1 Specify signal handling 2667.14.2 Send signal .2677.15 Alignment .2687.16 Variable arguments .2697.16.1 Variable argument list access macros .2697.17 Ato
27、mics 2737.17.1 Introduction .2737.17.2 Initialization 2747.17.3 Order and consistency .2757.17.4 Fences .2787.17.5 Lock-free property 2797.17.6 Atomic integer types .2807.17.7 Operations on atomic types .2827.17.8 Atomic flag type and operations .2857.18 Boolean type and values 2877.19 Common defini
28、tions .2887.20 Integer types 289vi ContentsCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,- ISO/IEC 2011 All rights reserved ISO/IEC 9899:2011 (E)7.20.1 Integer types 2897.20.2
29、Limits of specified-width integer types 2917.20.3 Limits of other integer types 2937.20.4 Macros for integer constants 2947.21 Input/output 2967.21.1 Introduction .2967.21.2 Streams 2987.21.3 Files 3007.21.4 Operations on files 3027.21.5 File access functions .3047.21.6 Formatted input/output functi
30、ons 3097.21.7 Character input/output functions .3307.21.8 Direct input/output functions 3357.21.9 File positioning functions .3367.21.10 Error-handling functions 3387.22 General utilities 3407.22.1 Numeric conversion functions 3417.22.2 Pseudo-random sequence generation functions .3467.22.3 Memory m
31、anagement functions .3477.22.4 Communication with the environment 3507.22.5 Searching and sorting utilities 3547.22.6 Integer arithmetic functions 3567.22.7 Multibyte/wide character conversion functions .3577.22.8 Multibyte/wide string conversion functions 3597.23 _Noreturn 3617.24 String handling .
32、3627.24.1 String function conventions .3627.24.2 Copying functions 3627.24.3 Concatenation functions 3647.24.4 Comparison functions .3657.24.5 Search functions .3677.24.6 Miscellaneous functions 3717.25 Type-generic math .3737.26 Threads .3767.26.1 Introduction .3767.26.2 Initialization functions .3
33、787.26.3 Condition variable functions 3787.26.4 Mutex functions .3807.26.5 Thread functions .3837.26.6 Thread-specific storage functions 3867.27 Date and time 3887.27.1 Components of time .3887.27.2 Time manipulation functions 3897.27.3 Time conversion functions .392Contents viiCopyright American Na
34、tional Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,-ISO/IEC 9899:2011 (E) ISO/IEC 2011 All rights reserved7.28 Unicode utilities .3987.28.1 Restartable multibyte/wide character conversion functions 3987
35、.29 Extended multibyte and wide character utilities .4027.29.1 Introduction .4027.29.2 Formatted wide character input/output functions 4037.29.3 Wide character input/output functions 4217.29.4 General wide string utilities 4267.29.4.1 Wide string numeric conversion functions .4267.29.4.2 Wide string
36、 copying functions 4307.29.4.3 Wide string concatenation functions .4327.29.4.4 Wide string comparison functions 4337.29.4.5 Wide string search functions 4357.29.4.6 Miscellaneous functions 4397.29.5 Wide character time conversion functions .4397.29.6 Extended multibyte/wide character conversion uti
37、lities 4407.29.6.1 Single-byte/wide character conversion functions .4417.29.6.2 Conversion state functions .4417.29.6.3 Restartable multibyte/wide character conversionfunctions 4427.29.6.4 Restartable multibyte/wide string conversionfunctions 4447.30 Wide character classification and mapping utiliti
38、es .4477.30.1 Introduction .4477.30.2 Wide character classification utilities .4487.30.2.1 Wide character classification functions 4487.30.2.2 Extensible wide character classificationfunctions 4517.30.3 Wide character case mapping utilities .4537.30.3.1 Wide character case mapping functions 4537.30.
39、3.2 Extensible wide character case mappingfunctions 4537.31 Future library directions .4557.31.1 Complex arithmetic .4557.31.2 Character handling 4557.31.3 Errors .4557.31.4 Floating-point environment 4557.31.5 Format conversion of integer types 4557.31.6 Localization 4557.31.7 Signal handling .4557
40、.31.8 Atomics 4557.31.9 Boolean type and values .4567.31.10 Integer types 4567.31.11 Input/output .4567.31.12 General utilities .456viii ContentsCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without licen
41、se from IHS-,-,- ISO/IEC 2011 All rights reserved ISO/IEC 9899:2011 (E)7.31.13 String handling .4567.31.14 Date and time .4567.31.15 Threads 4567.31.16 Extended multibyte and wide character utilities4567.31.17 Wide character classification and mapping utilities457Annex A (informative) Language synta
42、x summary 458A.1 Lexical grammar 458A.2 Phrase structure grammar .465A.3 Preprocessing directives .473Annex B (informative) Library summary 475B.1 Diagnostics 475B.2 Complex .475B.3 Character handling 477B.4 Errors .477B.5 Floating-point environment .477B.6 Characteristics of floating types .478B.7
43、Format conversion of integer types 478B.8 Alternative spellings .479B.9 Sizes of integer types 479B.10 Localization 479B.11 Mathematics .479B.12 Nonlocal jumps 484B.13 Signal handling .484B.14 Alignment .485B.15 Variable arguments .485B.16 Atomics 485B.17 Boolean type and values 487B.18 Common defin
44、itions .487B.19 Integer types 487B.20 Input/output 488B.21 General utilities 491B.22 _Noreturn 493B.23 String handling .493B.24 Type-generic math .495B.25 Threads .495B.26 Date and time 496B.27 Unicode utilities .497B.28 Extended multibyte/wide character utilities 497B.29 Wide character classificati
45、on and mapping utilities .502Annex C (informative) Sequence points .503Contents ixCopyright American National Standards Institute Provided by IHS under license with ANSI Not for ResaleNo reproduction or networking permitted without license from IHS-,-,-ISO/IEC 9899:2011 (E) ISO/IEC 2011 All rights r
46、eservedAnnex D (normative) Universal character names for identifiers .504D.1 Ranges of characters allowed .504D.2 Ranges of characters disallowed initially .504Annex E (informative) Implementation limits 505Annex F (normative) IEC 60559 floating-point arithmetic 507F.1 Introduction 507F.2 Types .507
47、F.3 Operators and functions .508F.4 Floating to integer conversion .510F.5 Binary-decimal conversion 510F.6 The return statement 511F.7 Contracted expressions 511F.8 Floating-point environment 511F.9 Optimization 514F.10 Mathematics .517F.10.1 Trigonometric functions 518F.10.2 Hyperbolic functions .
48、520F.10.3 Exponential and logarithmic functions 520F.10.4 Power and absolute value functions .524F.10.5 Error and gamma functions .525F.10.6 Nearest integer functions 526F.10.7 Remainder functions .528F.10.8 Manipulation functions 529F.10.9 Maximum, minimum, and positive difference functions .530F.10.10 Floating multiply-add .530F.10.11 Comparison macros 531Annex G (normative) IEC 60559-compatible complex arithmetic .532G.1 Introduction 532G.2 Types .532G.3 Conventions 532G.4 Conversions