Rationale for International Standard— Programming Languages— C
Total Page:16
File Type:pdf, Size:1020Kb
Rationale for International Standard— Programming Languages— C Revision 2 20 October 1999 UNIX is a trademark of The Open Group. DEC and PDP-11 are trademarks of Compaq Computer Corporation. POSIX is a trademark of IEEE. CONTENTS 0. Introduction .............................................................................................................................. 1 0.1 Organization of the document............................................................................................ 5 1. Scope ........................................................................................................................................ 6 2. Normative References .............................................................................................................. 6 3. Terms and definitions............................................................................................................... 6 4. Conformance ............................................................................................................................ 7 5. Environment............................................................................................................................. 9 5.1 Conceptual models............................................................................................................. 9 5.1.1 Translation environment.............................................................................................. 9 5.1.2 Execution environments............................................................................................ 11 5.2 Environmental considerations.......................................................................................... 13 5.2.1 Character sets ............................................................................................................ 13 5.2.2 Character display semantics ...................................................................................... 17 5.2.3 Signals and interrupts ................................................................................................ 18 5.2.4 Environmental limits................................................................................................. 18 6. Language ................................................................................................................................ 23 6.2 Concepts........................................................................................................................... 23 6.2.1 Scopes of identifiers ..................................................................................................23 6.2.2 Linkages of identifiers............................................................................................... 24 6.2.3 Name spaces of identifiers ........................................................................................ 26 6.2.4 Storage durations of objects ...................................................................................... 26 6.2.5 Types ......................................................................................................................... 28 6.2.6 Representations of types............................................................................................ 30 6.2.7 Compatible type and composite type......................................................................... 31 6.3 Conversions...................................................................................................................... 31 6.3.1 Arithmetic operands .................................................................................................. 31 6.3.2 Other operands .......................................................................................................... 35 6.4 Lexical Elements.............................................................................................................. 37 6.4.1 Keywords................................................................................................................... 37 6.4.2 Identifiers................................................................................................................... 37 6.4.3 Universal character names......................................................................................... 38 6.4.4 Constants ................................................................................................................... 38 6.4.5 String literals ............................................................................................................. 41 6.4.6 Punctuators ................................................................................................................ 43 6.4.7 Header names ............................................................................................................ 44 6.4.8 Preprocessing numbers.............................................................................................. 44 6.4.9 Comments.................................................................................................................. 44 6.5 Expressions ...................................................................................................................... 45 6.5.1 Primary expressions .................................................................................................. 48 6.5.2 Postfix operators........................................................................................................ 48 6.5.3 Unary operators ......................................................................................................... 51 6.5.4 Cast operators............................................................................................................ 53 i CONTENTS 6.5.5 Multiplicative operators ............................................................................................ 54 6.5.6 Additive operators .....................................................................................................54 6.5.7 Bitwise shift operators............................................................................................... 55 6.5.8 Relational operators...................................................................................................56 6.5.9 Equality operators...................................................................................................... 56 6.5.15 Conditional operator................................................................................................ 56 6.5.16 Assignment operators.............................................................................................. 57 6.5.17 Comma operator...................................................................................................... 58 6.6 Constant expressions........................................................................................................ 58 6.7 Declarations...................................................................................................................... 59 6.7.1 Storage-class specifiers ............................................................................................. 59 6.7.2 Type specifiers........................................................................................................... 59 6.7.3 Type qualifiers........................................................................................................... 66 6.7.4 Function specifiers .................................................................................................... 71 6.7.5 Declarators................................................................................................................. 72 6.7.6 Type names................................................................................................................ 78 6.7.7 Type definitions......................................................................................................... 79 6.7.8 Initialization............................................................................................................... 79 6.8 Statements and blocks...................................................................................................... 81 6.8.1 Labeled statements .................................................................................................... 83 6.8.2 Compound statement................................................................................................. 83 6.8.3 Expression and null statements ................................................................................. 83 6.8.4 Selection statements .................................................................................................. 83 6.8.5 Iteration statements.................................................................................................... 84 6.8.6. Jump statements .......................................................................................................86 6.9 External definitions .......................................................................................................... 87 6.9.1 Function definitions...................................................................................................87 6.10 Preprocessing directives................................................................................................. 88 6.10.1 Conditional inclusion .............................................................................................. 89 6.10.2 Source file inclusion...............................................................................................