Programming Languages — C - DKUUG

2y ago
10 Views
2 Downloads
1.34 MB
550 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Xander Jaffe
Transcription

Programming languages — CABSTRACT(Cover sheet to be provided by ISO Secretariat.)This International Standard specifies the form and establishes the interpretation ofprograms expressed in the programming language C. Its purpose is to promoteportability, reliability, maintainability, and efficient execution of C language programs ona variety of computing systems.Clauses are included that detail the C language itself and the contents of the C languageexecution library. Annexes summarize aspects of both of them, and enumerate factorsthat influence the portability of C programs.Although this International Standard is intended to guide knowledgeable C languageprogrammers as well as implementors of C language translation systems, the documentitself is not designed to serve as a tutorial.

Foreword1ISO (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 established by therespective organization 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 Standards are drafted in accordance with the rules given in the ISO/IECDirectives, Part 3. Accordingly, annexes F and I form a normative part of this standard;this foreword, the introduction, notes, footnotes, examples, annexes A, B, C, D, E, G, H,J, K, the bibliography, and the index are for information only.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 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 22, ‘‘Programminglanguages, their environments and system software interfaces’’.

Introduction1With the introduction of new devices and extended character sets, new features may beadded to this International Standard. Subclauses in the 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 becauseof 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:— the introduction and preliminary elements;— the characteristics of environments that translate and execute C programs;— the language syntax, constraints, and semantics;— the library facilities.4Examples are provided to illustrate possible forms of the constructions described.Footnotes are provided to emphasize consequences of the rules described in thatsubclause 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 bibliography lists documents that werereferred to during the preparation of the standard.5The language clause (clause 6) is derived from ‘‘The C Reference Manual’’.6The library clause (clause 7) is based on the 1984 /usr/group Standard.

Contents1. Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . .12. Normative references. . . . . . . . . . . . . . . . . . . . . . .23. Terms and definitions. . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . .54. Conformance5. Environment . . . . . . . . . . . .5.1 Conceptual models . . . . . . .5.1.1Translation environment .5.1.2Execution environments.5.2 Environmental considerations. .5.2.1Character sets. . . . .5.2.2Character display semantics5.2.3Signals and interrupts . .5.2.4Environmental limits. .777914141617176. Language . . . . . . . . . . . . . . . .6.1 Notation . . . . . . . . . . . . . .6.2 Concepts . . . . . . . . . . . . . .6.2.1Scopes of identifiers . . . . . .6.2.2Linkages of identifiers . . . . .6.2.3Name spaces of identifiers. . .6.2.4Storage durations of objects . . .6.2.5Types. . . . . . . . . . .6.2.6Representations of types . . . .6.2.7Compatible type and composite type6.3 Conversions. . . . . . . . . . . .6.3.1Arithmetic operands . . . . . .6.3.2Other operands . . . . . . . .6.4 Lexical elements . . . . . . . . . . .6.4.1Keywords . . . . . . . . . .6.4.2Identifiers . . . . . . . . . .6.4.3Universal character names. . .6.4.4Constants . . . . . . . . . .6.4.5String literals. . . . . . . .6.4.6Punctuators . . . . . . . . .6.4.7Header names. . . . . . . .6.4.8Preprocessing numbers . . . . .6.4.9Comments. . . . . . . . .6.5 Expressions . . . . . . . . . . . . .6.5.1Primary expressions . . . . . .6.5.2Postfix operators . . . . . . .6.5.3Unary operators. . . . . . 96068i.

6.5.4Cast operators . . . . . .6.5.5Multiplicative operators. .6.5.6Additive operators. . . .6.5.7Bitwise shift operators . . .6.5.8Relational operators . . . .6.5.9Equality operators. . . .6.5.10 Bitwise AND operator . . .6.5.11 Bitwise exclusive OR operator6.5.12 Bitwise inclusive OR operator6.5.13 Logical AND operator . . .6.5.14 Logical OR operator . . . .6.5.15 Conditional operator . . . .6.5.16 Assignment operators . . .6.5.17 Comma operator . . . . .6.6 Constant expressions . . . . . . .6.7 Declarations. . . . . . . . . .6.7.1Storage-class specifiers. .6.7.2Type specifiers . . . . . .6.7.3Type qualifiers . . . . . .6.7.4Function specifiers. . . .6.7.5Declarators. . . . . . .6.7.6Type names . . . . . . .6.7.7Type definitions. . . . .6.7.8Initialization . . . . . . .6.8 Statements . . . . . . . . . . .6.8.1Labeled statements. . . .6.8.2Compound statement, or block6.8.3Expression and null statements6.8.4Selection statements . . . .6.8.5Iteration statements . . . .6.8.6Jump statements. . . . .6.9 External definitions. . . . . . .6.9.1Function definitions . . . .6.9.2External object definitions.6.10 Preprocessing directives . . . . . .6.10.1 Conditional inclusion. . .6.10.2 Source file inclusion . . . .6.10.3 Macro replacement . . . .6.10.4 Line control . . . . . . .6.10.5 Error directive . . . . . .6.10.6 Pragma directive . . . . .6.10.7 Null directive. . . . . .6.10.8 Predefined macro names . .6.10.9 Pragma operator. . . . 44145145146146147

6.11 Future language directions . . . .6.11.1 Character escape sequences6.11.2 Storage-class specifiers.6.11.3 Function declarators . . .6.11.4 Function definitions . . .6.11.5 Pragma directives . . . .1481481481481481487. Library . . . . . . . . . . . . . . . . . . . . . . . .7.1 Introduction. . . . . . . . . . . . . . . . . . .7.1.1Definitions of terms . . . . . . . . . . . . .7.1.2Standard headers . . . . . . . . . . . . . .7.1.3Reserved identifiers . . . . . . . . . . . . .7.1.4Use of library functions. . . . . . . . . . .7.2 Diagnostics assert.h . . . . . . . . . . . . .7.2.1Program diagnostics . . . . . . . . . . . . .7.3 Complex arithmetic complex.h . . . . . . . . . .7.3.1Introduction . . . . . . . . . . . . . . . .7.3.2Conventions . . . . . . . . . . . . . . . .7.3.3Branch cuts . . . . . . . . . . . . . . . .7.3.4The CX LIMITED RANGE pragma. . . . . .7.3.5Trigonometric functions . . . . . . . . . . .7.3.6Hyperbolic functions. . . . . . . . . . . .7.3.7Exponential and logarithmic functions. . . . .7.3.8Power and absolute-value functions . . . . . . .7.3.9Manipulation functions. . . . . . . . . . .7.4 Character handling ctype.h . . . . . . . . . . .7.4.1Character testing functions . . . . . . . . . .7.4.2Character case mapping functions. . . . . . .7.5 Errors errno.h . . . . . . . . . . . . . . . .7.6 Floating-point environment fenv.h . . . . . . . .7.6.1The FENV ACCESS pragma. . . . . . . . .7.6.2Exceptions. . . . . . . . . . . . . . . .7.6.3Rounding . . . . . . . . . . . . . . . . .7.6.4Environment . . . . . . . . . . . . . . . .7.7 Characteristics of floating types float.h . . . . . .7.8 Format conversion of integer types inttypes.h . . .7.8.1Macros for format specifiers. . . . . . . . .7.8.2Conversion functions for greatest-width integer types7.9 Alternative spellings iso646.h . . . . . . . . . .7.10 Sizes of integer types limits.h . . . . . . . . . .7.11 Localization locale.h . . . . . . . . . . . . .7.11.1 Locale control . . . . . . . . . . . . . . .7.11.2 Numeric formatting convention inquiry . . . . .7.12 Mathematics math.h . . . . . . . . . . . . . .7.12.1 Treatment of error conditions . . . . . . . . 189190191196198iii.

7.137.147.157.167.177.187.197.207.12.2 The FP CONTRACT pragma. . . . . . . . . .7.12.3 Classification macros. . . . . . . . . . . . .7.12.4 Trigonometric functions . . . . . . . . . . . .7.12.5 Hyperbolic functions. . . . . . . . . . . . .7.12.6 Exponential and logarithmic functions. . . . . .7.12.7 Power and absolute-value functions . . . . . . . .7.12.8 Error and gamma functions . . . . . . . . . . .7.12.9 Nearest integer functions . . . . . . . . . . . .7.12.10 Remainder functions. . . . . . . . . . . . .7.12.11 Manipulation functions. . . . . . . . . . . .7.12.12 Maximum, minimum, and positive difference functions7.12.13 Floating multiply-add . . . . . . . . . . . . .7.12.14 Comparison macros . . . . . . . . . . . . . .Nonlocal jumps setjmp.h . . . . . . . . . . . . .7.13.1 Save calling environment . . . . . . . . . . . .7.13.2 Restore calling environment . . . . . . . . . . .Signal handling signal.h . . . . . . . . . . . . .7.14.1 Specify signal handling. . . . . . . . . . . .7.14.2 Send signal. . . . . . . . . . . . . . . . .Variable arguments stdarg.h . . . . . . . . . . .7.15.1 Variable argument list access macros . . . . . . .Boolean type and values stdbool.h . . . . . . . . .Common definitions stddef.h . . . . . . . . . . .Integer types stdint.h . . . . . . . . . . . . . .7.18.1 Integer types . . . . . . . . . . . . . . . . .7.18.2 Limits of specified-width integer types. . . . . .7.18.3 Limits of other integer types. . . . . . . . . .7.18.4 Macros for integer constants. . . . . . . . . .Input/output stdio.h . . . . . . . . . . . . . . .7.19.1 Introduction . . . . . . . . . . . . . . . . .7.19.2 Streams . . . . . . . . . . . . . . . . . . .7.19.3 Files . . . . . . . . . . . . . . . . . . . .7.19.4 Operations on files. . . . . . . . . . . . . .7.19.5 File access functions . . . . . . . . . . . . . .7.19.6 Formatted input/output functions . . . . . . . . .7.19.7 Character input/output functions . . . . . . . . .7.19.8 Direct input/output functions. . . . . . . . . .7.19.9 File positioning functions . . . . . . . . . . . .7.19.10 Error-handling functions . . . . . . . . . . . .General utilities stdlib.h . . . . . . . . . . . . .7.20.1 String conversion functions . . . . . . . . . . .7.20.2 Pseudo-random sequence generation functions. . .7.20.3 Memory management functions . . . . . . . . .7.20.4 Communication with the environment . . . . . . 252254258280285286289291291296297299

7.217.227.237.247.257.267.20.5 Searching and sorting utilities . . . . . . . . . . .7.20.6 Integer arithmetic functions . . . . . . . . . . . .7.20.7 Multibyte character functions . . . . . . . . . . .7.20.8 Multibyte string functions. . . . . . . . . . . .String handling string.h . . . . . . . . . . . . . .7.21.1 String function conventions . . . . . . . . . . . .7.21.2 Copying functions. . . . . . . . . . . . . . .7.21.3 Concatenation functions . . . . . . . . . . . . .7.21.4 Comparison functions . . . . . . . . . . . . . .7.21.5 Search functions. . . . . . . . . . . . . . . .7.21.6 Miscellaneous functions . . . . . . . . . . . . .Type-generic math tgmath.h . . . . . . . . . . . . .7.22.1 Type-generic macros. . . . . . . . . . . . . .Date and time time.h . . . . . . . . . . . . . . . .7.23.1 Components of time . . . . . . . . . . . . . . .7.23.2 Time manipulation functions. . . . . . . . . . .7.23.3 Time conversion functions. . . . . . . . . . . .Extended multibyte and wide-character utilities wchar.h . .7.24.1 Introduction . . . . . . . . . . . . . . . . . .7.24.2 Formatted wide-character input/output functions. . .7.24.3 Wide-character input/output functions . . . . . . . .7.24.4 General wide-string utilities . . . . . . . . . . . .7.24.5 Wide-character time conversion functions. . . . . .7.24.6 Extended multibyte and wide-character conversionutilities . . . . . . . . . . . . . . . . . . . .Wide-character classification and mapping utilities wctype.h 7.25.1 Introduction . . . . . . . . . . . . . . . . . .7.25.2 Wide-character classification utilities . . . . . . . .7.25.3 Wide-character mapping utilities . . . . . . . . . .Future library directions . . . . . . . . . . . . . . . . .7.26.1 Complex arithmetic complex.h . . . . . . . .7.26.2 Character handling ctype.h . . . . . . . . . .7.26.3 Errors errno.h . . . . . . . . . . . . . . .7.26.4 Format conversion of integer types inttypes.h .7.26.5 Localization locale.h . . . . . . . . . . . .7.26.6 Signal handling signal.h . . . . . . . . . .7.26.7 Boolean type and values stdbool.h . . . . . .7.26.8 Integer types stdint.h . . . . . . . . . . .7.26.9 Input/output stdio.h . . . . . . . . . . . .7.26.10 General utilities stdlib.h . . . . . . . . . .7.26.11 String handling string.h . . . . . . . . . .7.26.12 Extended multibyte and wide-character utilities wchar.h . . . . . . . . . . . . . . . . 390390390391391391391391. . . 391

7.26.13 Wide-character classification and mapping utilities wctype.h . . . . . . . . . . . . . . . . . . . . 391Annex A (informative) Language syntax summaryA.1 Lexical grammar. . . . . . . . .A.2 Phrase structure grammar . . . . . .A.3 Preprocessing directives . . . . . . .392392397404Annex B (informative) Library summary. . . . . . . . . . . . .B.1 Diagnostics assert.h . . . . . . . . . . . . . . .B.2 Complex complex.h . . . . . . . . . . . . . . . .B.3 Character handling ctype.h . . . . . . . . . . . . .B.4 Errors errno.h . . . . . . . . . . . . . . . . . .B.5 Floating-point environment fenv.h . . . . . . . . . .B.6 Characteristics of floating types float.h . . . . . . . .B.7 Format conversion of integer types inttypes.h . . . . .B.8 Alternative spellings iso646.h . . . . . . . . . . . .B.9 Sizes of integer types limits.h . . . . . . . . . . . .B.10 Localization locale.h . . . . . . . . . . . . . . .B.11 Mathematics math.h . . . . . . . . . . . . . . . .B.12 Nonlocal jumps setjmp.h . . . . . . . . . . . . . .B.13 Signal handling signal.h . . . . . . . . . . . . . .B.14 Variable arguments stdarg.h . . . . . . . . . . . .B.15 Boolean type and values stdbool.h . . . . . . . . . .B.16 Common definitions stddef.h . . . . . . . . . . . .B.17 Integer types stdint.h . . . . . . . . . . . . . . .B.18 Input/output stdio.h . . . . . . . . . . . . . . . .B.19 General utilities stdlib.h . . . . . . . . . . . . . .B.20 String handling string.h . . . . . . . . . . . . . .B.21 Type-generic math tgmath.h . . . . . . . . . . . . .B.22 Date and time time.h . . . . . . . . . . . . . . . .B.23 Extended multibyte and wide-character utilities wchar.h . .B.24 Wide-character classification and mapping utilities wctype.h 16416417419420421421422424Annex C (informative) Sequence points. . . . . . . . . . . . . . . . . 426Annex D (informative) Formal model of sequence pointsD.1 Introduction. . . . . . . . . . . . .D.2 Basic concepts. . . . . . . . . . . .D.3 Operation of the model . . . . . . . . .D.4 Application . . . . . . . . . . . . . .D.5 Examples. . . . . . . . . . . . . .427427427429432433Annex E (informative) Implementation limits . . . . . . . . . . . . . . . 442Annex F (normative) IEC 60559 floating-point arithmetic . . . . . . . . . . 444F.1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . 444vi

F.2F.3F.4F.5F.6F.7F.8F.9Types . . . . . . . . .Operators and functions . .Floating to integer conversionBinary-decimal conversion .Contracted expressions . .Environment. . . . . .Optimization . . . . . .Mathematics math.h . . . . . . . . . . . . . . . .444445447447447447450454Annex G (informative) IEC 60559-compatible complex arithmeticG.1 Introduction. . . . . . . . . . . . . . . . .G.2 Types . . . . . . . . . . . . . . . . . . . .G.3 Conversions. . . . . . . . . . . . . . . . .G.4 Binary operators . . . . . . . . . . . . . . . .G.5 Complex arithmetic complex.h . . . . . . . .G.6 Type-generic math tgmath.h . . . . . . . . .467467467467468473480Annex H (informative) Language independent arithmetic . .H.1 Introduction. . . . . . . . . . . . . . . .H.2 Types . . . . . . . . . . . . . . . . . . .H.3 Notification . . . . . . . . . . . . . . . . .481481481484Annex I (normative) Universal character names for identifiers. . . . . . . . 487Annex J (informative) Common warningsAnnex K (informative) Portability issuesK.1 Unspecified behavior . . . .K.2 Undefined behavior. . . .K.3 Implementation-defined

ISO/IEC JTC 1, ‘‘Information Technology’’, subcommittee 22, ‘‘Programming languages, their environments and system software interfaces’’. Introduction 1 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

Related Documents:

-graphical programming languages PLC ladder diagram Classification according to programming language paradigm -procedural programming languages C, Ada83 -functional programming languages LISP -logical programming languages PROLOG -object-oriented programming languages C , Smalltalk, Ada95 Classification according to language level

1 Languages at Harvard 2014 – 2015 Why Study a Foreign Language? 2 Planning Your Language Study 5 Languages Offered 2014-2015 (by Department) 6 African Languages 7 Celtic Languages 9 Classical Languages 10 East Asian Languages 11 English 17 Germanic Languages 17 Linguistics 20 Near Eastern Languages 21 Romance La

the bit patterns. So, these machine languages were the rst programming languages, and went hand-in-hand with general-purpose computers. So, programming languages are a fundamental aspect of general-purpose computing, in contrast with e.g., networks, operating systems, and databases. 1.1 The Pre-History of Programming Languages

The study of programming languages is valuable for a number of reasons: Increase our capacity to use different constructs Enable us to choose languages more intelligently Makes learning new languages easier Most important criteria for evaluating programming languages include: Readability, writability, reliability, cost

targeted at a particular type of programming practice. Domain-specific languages are programming languages designed for writing programs for a particular kind of work or practice. End-user programming may or may not involve such languages, since what de-fines end-user programming is the intent, not the choice of languages or tools. 2.3.

Applications of traditional scripting languages are: 1. system administration, 2. experimental programming, 3. controlling applications. Application areas : Four main usage areas for scripting languages: 1. Command scripting languages 2.Application scripting languages 3.Markup language 4. Universal scripting languages 1.

Arduino Programming Part 6: EAS 199B Programming Paradigms To think about styles of programming, we can organize programming languages into paradigms Note that many modern program languages have features of more than one paradigm 26 Paradigm Representative Languages Procedural or Sequential Fortran, C, Basic Object-oriented C , smalltalk

in advanced mathematics used in US universities are also popular in Australian universities for students studying engineering and some areas of applied sciences. However, the advanced mathematics .