Rationale for International Standard— Programming Languages— C
Total Page:16
File Type:pdf, Size:1020Kb
Rationale for International Standard— Programming Languages— C Revision 5.10 April-2003 UNIX is a trademark of The Open Group. POSIX is a trademark of IEEE. Contents 0. Introduction ............................................................................................................................1 0.1 Organization of the document ......................................................................................5 1. Scope ......................................................................................................................................7 2. Normative References............................................................................................................9 5 3. Terms and definitions...........................................................................................................11 4. Conformance ........................................................................................................................13 5. Environment.........................................................................................................................15 5.1 Conceptual models......................................................................................................15 5.1.1 Translation environment.................................................................................15 10 5.1.2 Execution environments .................................................................................17 5.2 Environmental considerations....................................................................................19 5.2.1 Character sets..................................................................................................19 5.2.2 Character display semantics ...........................................................................23 5.2.3 Signals and interrupts.....................................................................................24 15 5.2.4 Environmental limits ......................................................................................24 6. Language ..............................................................................................................................31 6.2 Concepts .....................................................................................................................31 6.2.1 Scopes of identifiers .......................................................................................31 6.2.2 Linkages of identifiers ....................................................................................32 20 6.2.3 Name spaces of identifiers..............................................................................34 6.2.4 Storage durations of objects............................................................................34 6.2.5 Types...............................................................................................................36 6.2.6 Representations of types.................................................................................43 6.2.7 Compatible type and composite type..............................................................43 25 6.3 Conversions ................................................................................................................44 6.3.1 Arithmetic operands........................................................................................44 6.3.1.6 Complex types ................................................................................................46 6.3.1.7 Real and complex ...........................................................................................46 6.3.2 Other operands................................................................................................48 30 6.4 Lexical Elements ........................................................................................................49 6.4.1 Keywords........................................................................................................50 6.4.2 Identifiers........................................................................................................50 6.4.3 Universal character names..............................................................................51 6.4.4 Constants.........................................................................................................51 35 6.4.5 String literals...................................................................................................55 6.4.6 Punctuators .....................................................................................................57 6.4.7 Header names..................................................................................................57 6.4.8 Preprocessing numbers ...................................................................................57 6.4.9 Comments.......................................................................................................58 40 6.5 Expressions.................................................................................................................58 6.5.1 Primary expressions........................................................................................61 6.5.2 Postfix operators.............................................................................................61 6.5.3 Unary operators..............................................................................................64 6.5.4 Cast operators.................................................................................................66 ii Contents 6.5.5 Multiplicative operators..................................................................................67 6.5.6 Additive operators ..........................................................................................67 6.5.7 Bitwise shift operators ....................................................................................68 6.5.8 Relational operators........................................................................................69 5 6.5.9 Equality operators...........................................................................................69 6.5.15 Conditional operator .......................................................................................69 6.5.16 Assignment operators.....................................................................................69 6.5.17 Comma operator .............................................................................................71 6.6 Constant expressions..................................................................................................71 10 6.7 Declarations ................................................................................................................72 6.7.1 Storage-class specifiers...................................................................................72 6.7.2 Type specifiers................................................................................................72 6.7.3 Type qualifiers................................................................................................75 6.7.4 Function specifiers..........................................................................................80 15 6.7.5 Declarators......................................................................................................81 6.7.6 Type names.....................................................................................................87 6.7.7 Type definitions..............................................................................................87 6.7.8 Initialization....................................................................................................88 6.8 Statements and blocks.................................................................................................90 20 6.8.1 Labeled statements..........................................................................................91 6.8.2 Compound statement ......................................................................................92 6.8.3 Expression and null statements.......................................................................92 6.8.4 Selection statements........................................................................................92 6.8.5 Iteration statements.........................................................................................93 25 6.8.6. Jump statements..............................................................................................94 6.9 External definitions.....................................................................................................95 6.9.1 Function definitions........................................................................................95 6.9.2 External object definitions..............................................................................97 6.10 Preprocessing directives.............................................................................................97 30 6.10.1 Conditional inclusion......................................................................................97 6.10.2 Source file inclusion.......................................................................................98 6.10.3 Macro replacement .........................................................................................99 6.10.4 Line control...................................................................................................105 6.10.5 Error directive...............................................................................................105