INTERNATIONAL STANDARD ISOIIEC 9899 First edition 1990-12-15 Programming languages - C Langages de programmation - C E - w - E = z 2 z 3 = = = = - = s E- E Z C - Reference number ISOAEC 9899 : 1990 (El
Contents 1 Scope 2 Normative references 1 3 Definitions and conventions 2 4 Compliance 5 Environment 5 51 Conceptual models 5 511 Translation environment 5 512 Execution environments 6 52 Environmental considerations 10 521 Character sets 10 522 Character display semantics 12 523 Signals and interrupts 12 524 Environmental limits 12 6 Language 61 Lexical elements 611 Keywords 612 Identifiers 613 Constants 614 String literals 615 Operators 616 Punctuators 617 Header names 618 Preprocessing numbers 619 Comments 62 Conversions 621 Arithmetic operands 622 Other operands 63 Expressions 631 Primary expressions 632 Postfix operators 633 Unary operators 634 Cast operators 635 Multiplicative operators 636 Additive operators 637 Bitwise shift operators 638 Relational operators 639 Equality operators 6310 Bitwise AND operator 6311 Bitwise exclusive OR operator 6312 Bitwise inclusive OR operator 6313 Logical AND operator 6314 Logical OR operator 6315 Conditional operator 1 3 18 18 19 19 25 30 31 32 32 33 33 34 34 36 38 39 39 43 45 46 46 48 48 49 50 50 50 51 51 51 0 ISO/IEC 1990 All rights reserved No part of this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from the publisher ISO/IEC Copyright Office l Case postale 56 l CH-1211 Geneve 20 l Switzerland Printed in Switzerland ii
64 65 66 67 68 69 l 6316 Assignment operators 6317 Comma operator 1 Constant expressions Declarations 651 Storage-class specifiers 652 Type specifiers 653 Type qualifiers 654 Declarators 655 Type names 656 Type definitions 657 Initialization Statements 661 Labeled statements 662 Compound statement, or block 663 Expression and null statements 664 Selection statements 665 Iteration statements 666 Jump statements External definitions 671 Function definitions 672 External object definitions Preprocessing directives 681 Conditional inclusion 682 Source file inclusion 683 Macro replacement 684 Line control 685 Error directive 686 Pragma directive 687 Null directive 688 Predefined macro names Future language directions 691 External names 692 Character escape sequences 693 Storage-class specifiers 694 Function declarators 6 Function definitions 696 Array parameters l I* 7 Library 71 Introduction 711 Definitibns of terms 712 Standard headers 713 Reserved identifiers 714 Errors <errnoh> 715 Limits <floath> and <limitsh> ' 716 Common definitions <stddef h> 717 Use of library functions 72 Diagnostics <asserth> 721 Program diagnostics 73 Character handling <ctype h> 731 Character testing functions 732 Character case mapping functions 74 Localization <localeh> 741 Locale control 742 Numeric formatting convention inquiry 53 54 55 57 58 58 64 65 69 70 71 75 75 75 76 77 78 79 81 81 83 85 86 87 89 93 93 93 94 94 96 96 96 96 97 97 98 98 99 101 101 102 102 104 106 107 108 111
75 Mathematics <mathh> 111 751 Treatment of error conditions 111 752 Trigonometric functions 111 753 Hyperbolic functions 113 754 Exponential and logarithmic functions 114 755 Power functions 115 756 Nearest integer, absoke value, and rem ainder fun ctions 116 76 Nonlocaljumps <set jmp h> 118 761 Save calling environment 118 762 Restore calling environment 119 77 Signal handling <signalh> 120 771 Specify signal handling 120 772 Send signal 121 78 Variable arguments <stdarg h> 122 781 Variable argument list access macros 122 79 Input/output <stdioh> 124 791 Introduction 124 792 Streams 125 793 Files 126 794 Operations on files 127 7 File access functions 128 796 Formatted input/output functions 131 797 Character input/output functions 141 798 Direct input/output functions 144 799 File positioning functions 145 7910 Error-handling functions 147 710 General utilities <&dlibh> 149 7101 String conversion functions 149 7102 Pseudo-random sequence generation functions 153 7103 Memory management functions 154 7104 Communication with the environment 155 7105 Searching and sorting utilities 157 7106 Integer arithmetic functions 158 7107 Multibyte character functions 159 7108 Multibyte string functions 161 711 String handling <stringh> 162 7111 String function conventions 162 7112 Copying functions 162 7113 Concatenation functions 163 7114 Comparison functions 164 7115 Search functions 165 7116 Miscellaneous functions 168 712 Dateandtime<timeh> 170 7121 Components of time 170 7122 Time manipulation functions 170 7123 Time conversion functions 172 713 Future library directions 176 7131 Errors<errnoh> 176 7132 Character handling <ctype h> 176 7133 Localization <localeh> 176 7134 Mathematics <math h> 176 7135 Signal handling <signal h> 176 7136 Input/output <stdioh> 176 7137 General utilities <stdlib h; 176 7138 String handling <string h> 176 iv
Annexes A Bibliography B Language syntax summary B1 Lexical grammar B2 Phrase structure grammar B3 Preprocessing directives C Sequence points D Library summary D1 Errors <errnoh> D2 Common definitions <stddef h> D3 Diagnostics <asserth> D4 Character handling <ctype h> D5 Localization <localeh> D6 Mathematics <math h> D7 Nonlocal jumps <set jmp h> D8 Signal handling <signal h> D9 Variable arguments <stdarg h> D10 Input/output <stdioh> D11 General utilities <stdlib h> D12 String handling <string h> D13 Date and time <time h> E Implementation limits l F Common warnings G Portability issues Gl Unspecified behavior G2 Undefined behavior G3 Implementation-defined behavior G4 Locale-specific behavior G5 Common extensions 177 e 178 178 182 187 189 191 191 191 192 192 194 1 1 196 198 Index - 210 199 199 200 204 207 208
Foreword IS0 (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization National bodies that are members of IS0 or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity IS0 and IEC technical committees collaborate in fields of mutual interest Other international organizations, governmental and non-governmental, in liaison with IS0 and IEC, also take part in the work In the field of information technology, IS0 and IEC have established a joint technical committee, ISO/IEC JTC 1 Draft International Standards adopted by the joint technical committee are circulated to national bodies for voting Publication as an International Standard requires approval by at least 75?70 of the national bodies casting a vote International Standard ISO/IEC 9899 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology Annexes A, B, C, D, E, F and G are for information only vi
Introduction With the introduction of new devices and extended character sets, new features may be added to this International Standard Subclauses in the language and library clauses warn implementors and programmers of usages which, though valid in themselves, may conflict with future additions Certain features are obsolescent, which means that they may be considered for withdrawal in future revisions of this International Standard They are retained because of their widespread use, but their use in new implementations (for implementation features) or new programs (for language [69] or library features [713]) is discouraged This International Standard is divided into four major subdivisions: - the introduction and preliminary elements; - the characteristics of environments that translate and execute C programs; - the language syntax, constraints, and semantics; - the library facilities Examples are provided to illustrate possible forms of the constructions described Footnotes are provided to emphasize consequences of the rules described in that subclause or elsewhere in this International Standard References are used to refer to other related subclauses A set of annexes summarizes information contained in this International Standard The introduction, the examples, the footnotes, the references, and the annexes are not part of this International Standard The language clause (clause 7) is derived from The C Reference Manual (see annex A) The library clause (clause 8) is based on the 1984 lusr-/group Standard (see annex A) vii
This page intentionally left blank
INTERNATIONAL STANDARD ISO/IEC 9899 : 1990 (E) Programming languages - C 1 Scope This International Standard specifies the form and establishes the interpretation of programs written in the C programming language It specifies - the representation of C programs; - the syntax and constraints of the C language; - the semantic rules for interpreting C programs; - the representation of input data to be processed by C programs; - the representation of output data produced by C programs; - the restrictions and limits imposed by a conforming implementation of C This International Standard does not specify - the mechanism by which C programs are transformed for use by a data-processing system; - the mechanism by which C programs are invoked for use by a data-processing system; - the mechanism by which input data are transformed for use by a C program; - the mechanism by which output data are transformed after being produced by a C program; - the size or complexity of a program and its data that will exceed the capacity of any specific data-processing system or the capacity of a particular processor; - all minimal requirements of a data-processing system that is capable of supporting a conforming implementation 2 Normative references The following standards contain provisions which, through reference in this text, constitute provisions of this International Standard At the time of publication, the editions indicated were valid All standards are subject to revision, and parties to agreements based on this International Standard are encouraged to investigate the possibility of applying the most recent editions of the standards indicated below Members of IEC and IS0 maintain registers of currently valid International Standards IS0 646: 1983, Information processing - IS0 7-bit coded character set for information interchange IS0 4217: 1987, Codes for the representation of currencies and funds 1 This International Standard is designed to promote the portability of C programs among a variety of data-processing systems It is intended for use by implementors and programmers It is accompanied by a Rationale document that explains many of the decisions of the Technical Committee that produced it General