《n1256原版完整文件.pdf》由会员分享,可在线阅读,更多相关《n1256原版完整文件.pdf(552页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、WG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9899:TC3ContentsForeword.xiIntroduction.xiv1.Scope.12.Normative references.23.Terms,definitions,and symbols.34.Conformance.75.Environment.95.1 Conceptual models.95.1.1 Translation environment.95.1.2 Execution environments.115.2 Environmental consid
2、erations.175.2.1 Character sets.175.2.2 Character display semantics.195.2.3 Signals and interrupts.205.2.4 Environmental limits.206.Language.296.1 Notation.296.2 Concepts.296.2.1 Scopes of identifiers.296.2.2 Linkages of identifiers.306.2.3 Name spaces of identifiers.316.2.4 Storage durations of obj
3、ects.326.2.5 Types.336.2.6 Representations of types.376.2.7 Compatible type and composite type.406.3 Conversions.426.3.1 Arithmetic operands.426.3.2 Other operands.466.4 Lexical elements.496.4.1 Keywords.506.4.2 Identifiers.516.4.3 Universal character names.536.4.4 Constants.546.4.5 String literals.
4、626.4.6 Punctuators.636.4.7 Header names.646.4.8 Preprocessing numbers.656.4.9 Comments.666.5 Expressions.67Contents iiiISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N12566.5.1 Primary expressions.696.5.2 Postfix operators.696.5.3 Unary operators.786.5.4 Cast operators.816.5.5 Multiplicative
5、 operators.826.5.6 Additive operators.826.5.7 Bitwise shift operators.846.5.8 Relational operators.856.5.9 Equality operators.866.5.10 BitwiseANDoperator.876.5.11 Bitwise exclusiveORoperator.886.5.12 Bitwise inclusiveORoperator.886.5.13 LogicalANDoperator.896.5.14 LogicalORoperator.896.5.15 Conditio
6、nal operator.906.5.16 Assignment operators.916.5.17 Comma operator.946.6 Constant expressions.956.7 Declarations.976.7.1 Storage-class specifiers.986.7.2 Type specifiers.996.7.3 Type qualifiers.1086.7.4 Function specifiers.1126.7.5 Declarators.1146.7.6 Type names.1226.7.7 Type definitions.1236.7.8 I
7、nitialization.1256.8 Statements and blocks.1316.8.1 Labeled statements.1316.8.2 Compound statement.1326.8.3 Expression and null statements.1326.8.4 Selection statements.1336.8.5 Iteration statements.1356.8.6 Jump statements.1366.9 External definitions.1406.9.1 Function definitions.1416.9.2 External
8、object definitions.1436.10 Preprocessing directives.1456.10.1 Conditional inclusion.1476.10.2 Source file inclusion.1496.10.3 Macro replacement.1516.10.4 Line control.1586.10.5 Error directive.1596.10.6 Pragma directive.159iv ContentsWG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9899:TC36.10.7
9、 Null directive.1606.10.8 Predefined macro names.1606.10.9 Pragma operator.1616.11 Future language directions.1636.11.1 Floating types.1636.11.2 Linkages of identifiers.1636.11.3 External names.1636.11.4 Character escape sequences.1636.11.5 Storage-class specifiers.1636.11.6 Function declarators.163
10、6.11.7 Function definitions.1636.11.8 Pragma directives.1636.11.9 Predefined macro names.1637.Library.1647.1 Introduction.1647.1.1 Definitions of terms.1647.1.2 Standard headers.1657.1.3 Reserved identifiers.1667.1.4 Use of library functions.1667.2 Diagnostics.1697.2.1 Program diagnostics.1697.3 Com
11、plex arithmetic.1707.3.1 Introduction.1707.3.2 Conventions.1717.3.3 Branch cuts.1717.3.4 The CX_LIMITED_RANGE pragma.1717.3.5 Trigonometric functions.1727.3.6 Hyperbolic functions.1747.3.7 Exponential and logarithmic functions.1767.3.8 Power and absolute-value functions.1777.3.9 Manipulation functio
12、ns.1787.4 Character handling.1817.4.1 Character classification functions.1817.4.2 Character case mapping functions.1847.5 Errors.1867.6 Floating-point environment.1877.6.1 The FENV_ACCESS pragma.1897.6.2 Floating-point exceptions.1907.6.3 Rounding.1937.6.4 Environment.1947.7 Characteristics of float
13、ing types.1977.8 Format conversion of integer types.1987.8.1 Macros for format specifiers.1987.8.2 Functions for greatest-width integer types.199Contents vISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N12567.9 Alternative spellings.2027.10 Sizes of integer types.2037.11 Localization.2047.11.
14、1 Locale control.2057.11.2 Numeric formatting convention inquiry.2067.12 Mathematics.2127.12.1 Treatment of error conditions.2147.12.2 The FP_CONTRACT pragma.2157.12.3 Classification macros.2167.12.4 Trigonometric functions.2187.12.5 Hyperbolic functions.2217.12.6 Exponential and logarithmic functio
15、ns.2237.12.7 Power and absolute-value functions.2287.12.8 Error and gamma functions.2307.12.9 Nearest integer functions.2317.12.10 Remainder functions.2357.12.11 Manipulation functions.2367.12.12 Maximum,minimum,and positive difference functions.2387.12.13 Floating multiply-add.2397.12.14 Comparison
16、 macros.2407.13 Nonlocal jumps.2437.13.1 Save calling environment.2437.13.2 Restore calling environment.2447.14 Signal handling.2467.14.1 Specify signal handling.2477.14.2 Send signal.2487.15 Variable arguments.2497.15.1 Variable argument list access macros.2497.16 Boolean type and values.2537.17 Co
17、mmon definitions.2547.18 Integer types.2557.18.1 Integer types.2557.18.2 Limits of specified-width integer types.2577.18.3 Limits of other integer types.2597.18.4 Macros for integer constants.2607.19 Input/output.2627.19.1 Introduction.2627.19.2 Streams.2647.19.3 Files.2667.19.4 Operations on files.
18、2687.19.5 File access functions.2707.19.6 Formatted input/output functions.2747.19.7 Character input/output functions.2967.19.8 Direct input/output functions.301vi ContentsWG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9899:TC37.19.9 File positioning functions.3027.19.10 Error-handling function
19、s.3047.20 General utilities.3067.20.1 Numeric conversion functions.3077.20.2 Pseudo-random sequence generation functions.3127.20.3 Memory management functions.3137.20.4 Communication with the environment.3157.20.5 Searching and sorting utilities.3187.20.6 Integer arithmetic functions.3207.20.7 Multi
20、byte/wide character conversion functions.3217.20.8 Multibyte/wide string conversion functions.3237.21 String handling.3257.21.1 String function conventions.3257.21.2 Copying functions.3257.21.3 Concatenation functions.3277.21.4 Comparison functions.3287.21.5 Search functions.3307.21.6 Miscellaneous
21、functions.3337.22 Type-generic math.3357.23 Date and time.3387.23.1 Components of time.3387.23.2 Time manipulation functions.3397.23.3 Time conversion functions.3417.24 Extended multibyte and wide character utilities.3487.24.1 Introduction.3487.24.2 Formatted wide character input/output functions.34
22、97.24.3 Wide character input/output functions.3677.24.4 General wide string utilities.3717.24.5 Wide character time conversion functions.3857.24.6 Extended multibyte/wide character conversion utilities.3867.25 Wide character classification and mapping utilities.3937.25.1 Introduction.3937.25.2 Wide
23、character classification utilities.3947.25.3 Wide character case mapping utilities.3997.26 Future library directions.4017.26.1 Complex arithmetic.4017.26.2 Character handling.4017.26.3 Errors.4017.26.4 Format conversion of integer types.4017.26.5 Localization.4017.26.6 Signal handling.4017.26.7 Bool
24、ean type and values.4017.26.8 Integer types.4017.26.9 Input/output.402Contents viiISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N12567.26.10 General utilities.4027.26.11 String handling.4027.26.12 Extended multibyte and wide character utilities.4027.26.13 Wide character classification and ma
25、pping utilities.402Annex A(informative)Language syntax summary.403A.1 Lexical grammar.403A.2 Phrase structure grammar.409A.3 Preprocessing directives.416Annex B(informative)Library summary.419B.1 Diagnostics.419B.2 Complex.419B.3 Character handling.421B.4 Errors.421B.5 Floating-point environment.421
26、B.6 Characteristics of floating types.422B.7 Format conversion of integer types.422B.8 Alternative spellings.423B.9 Sizes of integer types.423B.10 Localization.423B.11 Mathematics.423B.12 Nonlocal jumps.428B.13 Signal handling.428B.14 Variable arguments.428B.15 Boolean type and values.428B.16 Common
27、 definitions.429B.17 Integer types.429B.18 Input/output.429B.19 General utilities.431B.20 String handling.433B.21 Type-generic math.434B.22 Date and time.434B.23 Extended multibyte/wide character utilities.435B.24 Wide character classification and mapping utilities.437Annex C(informative)Sequence po
28、ints.439Annex D(normative)Universal character names for identifiers.440Annex E(informative)Implementation limits.442Annex F(normative)IEC 60559 floating-point arithmetic.444F.1Introduction.444F.2Types.444F.3Operators and functions.445viii ContentsWG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9
29、899:TC3F.4Floating to integer conversion.447F.5Binary-decimal conversion.447F.6Contracted expressions.448F.7Floating-point environment.448F.8Optimization.451F.9Mathematics.454Annex G(informative)IEC 60559-compatible complex arithmetic.467G.1 Introduction.467G.2 Types.467G.3 Conventions.467G.4 Conver
30、sions.468G.5 Binary operators.468G.6 Complex arithmetic.472G.7 Type-generic math.480Annex H(informative)Language independent arithmetic.481H.1 Introduction.481H.2 Types.481H.3 Notification.485Annex I(informative)Common warnings.487Annex J(informative)Portability issues.489J.1 Unspecified behavior.48
31、9J.2 Undefined behavior.492J.3 Implementation-defined behavior.505J.4 Locale-specific behavior.512J.5 Common extensions.513Bibliography.516Index.519Contents ixISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N1256xContentsWG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9899:TC3Foreword1ISO(
32、the International Organization for Standardization)and IEC(the InternationalElectrotechnical Commission)form the specialized system for worldwidestandardization.National bodies that are member of ISO or IEC participate in thedevelopment of International Standards through technical committees establi
33、shed by therespective org anization to deal with particular fields of technical activity.ISO and IECtechnical committees collaborate in fields of mutual interest.Other internationalorganizations,governmental and non-governmental,in liaison with ISO and IEC,alsotake part in the work.2International St
34、andards are drafted in accordance with the rules given in the ISO/IECDirectives,Part 3.3In the field of information technology,ISO and IEC have established a joint technicalcommittee,ISO/IEC JTC 1.Draft International Standards adopted by the joint technicalcommittee are circulated to national bodies
35、 for voting.Publication as an InternationalStandard requires approval by at least 75%of the national bodies casting a vote.4International Standard ISO/IEC 9899 was prepared by Joint Technical CommitteeISO/IEC JTC 1,Information technology,Subcommittee SC 22,Programming languages,their environments an
36、d system software interfaces.The Working Group responsible forthis standard(WG 14)maintains a site on the World Wide Web athttp:/www.open-std.org/JTC1/SC22/WG14/containing additionalinformation relevant to this standard such as a Rationale for many of the decisions madeduring its preparation and a l
37、og of Defect Reports and Responses.5This second edition cancels and replaces the first edition,ISO/IEC 9899:1990,asamended and corrected by ISO/IEC 9899/COR1:1994,ISO/IEC 9899/AMD1:1995,andISO/IEC 9899/COR2:1996.Major changes from the previous edition include:restricted character set support via dig
38、raphs and (originally specifiedin AMD1)wide character library support in and (originallyspecified in AMD1)more precise aliasing rules via effective type restricted pointers variable length arrays flexible array members static and type qualifiers in parameter array declarators complex(and imaginary)s
39、upport in type-generic math macros in the long long int type and library functionsForeword xiISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N1256 increased minimum translation limits additional floating-point characteristics in remove implicit int reliable integer division universal character
40、 names(u and U)extended identifiers hexadecimal floating-point constants and%a and%A printf/scanf conversionspecifiers compound literals designated initializers/comments extended integer types and library functions in and remove implicit function declaration preprocessor arithmetic done in intmax_t/
41、uintmax_t mixed declarations and code new block scopes for selection and iteration statements integer constant type rules integer promotion rules macros with a variable number of arguments the vscanf family of functions in and additional math library functions in treatment of error conditions by mat
42、h library functions(math_errhandling)floating-point environment access in IEC 60559(also known as IEC 559 or IEEE arithmetic)support trailing comma allowed in enum declaration%lf conversion specifier allowed in printf inline functions the snprintf family of functions in boolean type in idempotent ty
43、pe qualifiers empty macro argumentsxii ForewordWG14/N1256 Committee Draft Septermber 7,2007ISO/IEC 9899:TC3 new structure type compatibility rules(tag compatibility)additional predefined macro names _Pragma preprocessing operator standard pragmas _func_ _ predefined identifier va_copymacro additiona
44、l strftime conversion specifiers LIA compatibility annex deprecate ungetc at the beginning of a binary file remove deprecation of aliased array parameters conversion of array to pointer not limited to lvalues relaxed constraints on aggregate and union initialization relaxed restrictions on portable
45、header names return without expression not permitted in function that returns a value(and viceversa)6Annexes D and F form a normative part of this standard;annexes A,B,C,E,G,H,I,J,the bibliography,and the index are for information only.In accordance with Part 3 of theISO/IEC Directives,this foreword
46、,the introduction,notes,footnotes,and examples arealso for information only.Foreword xiiiISO/IEC 9899:TC3Committee Draft Septermber 7,2007WG14/N1256Introduction1With the introduction of new devices and extended character sets,new features may beadded to this International Standard.Subclauses in the
47、language and library clauses warnimplementors and programmers of usages which,though valid in themselves,mayconflict with future additions.2Certain features are obsolescent,which means that they may be considered forwithdrawal in future revisions of this International Standard.They are retained beca
48、useof their widespread use,but their use in new implementations(for implementationfeatures)or new programs(for language 6.11 or library features 7.26)is discouraged.3This International Standard is divided into four major subdivisions:preliminary elements(clauses 14);the characteristics of environmen
49、ts that translate and execute C programs(clause 5);the language syntax,constraints,and semantics(clause 6);the library facilities(clause 7).4Examples are provided to illustrate possible forms of the constructions described.Footnotes are provided to emphasize consequences of the rules described in th
50、atsubclause or elsewhere in this International Standard.References are used to refer toother related subclauses.Recommendations are provided to give advice or guidance toimplementors.Annexes provide additional information and summarize the informationcontained in this International Standard.A biblio