Linguagem de Programação C - NORMA ISO/IEC 9899TC2

Linguagem de Programação C - NORMA ISO/IEC 9899TC2

(Parte 4 de 11)

2NOTE Whenreferenced, an object may be interpreted as having a particular type; see

3.15 1 parameter formal parameter formal argument (deprecated) object declared as part of a function declaration or definition that acquires a value on entry to the function, or an identifier from the comma-separated list bounded by the parentheses immediately following the macro name in a function-likemacro definition

3.16 1 recommended practice specification that is strongly recommended as being in keeping with the intent of the standard, but that may be impractical for some implementations

3.17 1 value precise meaning of the contents of an object when interpreted as having a specific type

3.17.1 1 implementation-defined value unspecified value where each implementation documents howthe choice is made

3.17.2 1 indeterminate value either an unspecified value or a trap representation

3.17.3 1unspecified value valid value of the relevant type where this International Standard imposes no requirements on which value is chosen in anyinstance

2NOTE Anunspecified value cannot be a trap representation.

6General §3.19

WG14/N1124 CommitteeDraft — May 6, 2005ISO/IEC 9899:TC2

4. Conformance

1In this International Standard, ‘‘shall’’istobeinterpreted as a requirement on an implementation or on a program; conversely,‘‘shall not’’istobeinterpreted as a prohibition.

2If a ‘‘shall’’or‘‘shall not’’requirement that appears outside of a constraint is violated, the behavior is undefined.Undefined behavior is otherwise indicated in this International Standard by the words ‘‘undefined behavior’’orbythe omission of anyexplicit definition of behavior.There is no difference in emphasis among these three; theyall describe ‘‘behavior that is undefined’’.

3Aprogram that is correct in all other aspects, operating on correct data, containing unspecified behavior shall be a correct program and act in accordance with

4The implementation shall not successfully translate a preprocessing translation unit containing a#errorpreprocessing directive unless it is part of a group skipped by conditional inclusion.

5Astrictly conforming programshall use only those features of the language and library specified in this International Standard.2)It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior,and shall not exceed any minimum implementation limit.

6The twoforms ofconforming implementationare hosted and freestanding.Aconforming hosted implementationshall accept anystrictly conforming program.Aconforming freestanding implementationshall accept anystrictly conforming program that does not use complextypes and in which the use of the features specified in the library clause (clause 7) is confined to the contents of the standard headers<float.h>, <iso646.h>, <limits.h>, <stdarg.h>, <stdbool.h>, <stddef.h>, and

<stdint.h>.Aconforming implementation may have extensions (including additional library functions), provided theydonot alter the behavior of anystrictly conforming program.3)

2)Astrictly conforming program can use conditional features (such as those in annexF)provided the use is guarded by a#ifdefdirective with the appropriate macro.Forexample:


#ifdef __STDC_IEC_559_ _/* FE_UPWARD defined */ fesetround(FE_UPWARD); #endif

3)This implies that a conforming implementation reserves no identifiers other than those explicitly reserved in this International Standard.

§4 General7

ISO/IEC 9899:TC2Committee Draft — May 6, 2005WG14/N1124

7Aconforming programis one that is acceptable to a conforming implementation.4)

8An implementation shall be accompanied by a document that defines all implementationdefined and locale-specific characteristics and all extensions.

Forward references:conditional inclusion (6.10.1), error directive (6.10.5), characteristics of floating types<float.h>(7.7), alternative spellings<iso646.h> (7.9), sizes of integer types<limits.h>(7.10), variable arguments<stdarg.h> (7.15), boolean type and values<stdbool.h>(7.16), common definitions <stddef.h> (7.17), integer types <stdint.h> (7.18).

4)Strictly conforming programs are intended to be maximally portable among conforming implementations. Conformingprograms may depend upon nonportable features of a conforming implementation.

8General §4

WG14/N1124 CommitteeDraft — May 6, 2005ISO/IEC 9899:TC2

5. Environment

1An implementation translates C source files and executes C programs in twodataprocessing-system environments, which will be called thetranslation environmentand theexecution environmentin this International Standard.Their characteristics define and constrain the results of executing conforming C programs constructed according to the syntactic and semantic rules for conforming implementations.

Forward references:In this clause, only a fewofmanypossible forward references have been noted.

5.1 Conceptual models

5.1.1 Translation environment Program structure

1ACprogram need not all be translated at the same time.The text of the program is kept in units calledsource files,(orpreprocessing files)inthis International Standard.A source file together with all the headers and source files included via the preprocessing directive#includeis known as apreprocessing translation unit.After preprocessing, a preprocessing translation unit is called atranslation unit.Previously translated translation units may be preserved individually or in libraries.The separate translation units of a program communicate by (for example) calls to functions whose identifiers have external linkage, manipulation of objects whose identifiers have external linkage, or manipulation of data files.Translation units may be separately translated and then later linked to produce an executable program.

Forward references:linkages of identifiers (6.2.2), external definitions (6.9), preprocessing directives (6.10). Translation phases

1The precedence among the syntax rules of translation is specified by the following phases.5)

1. Physical source file multibyte characters are mapped, in an implementationdefined manner,tothe source character set (introducing new-line characters for end-of-line indicators) if necessary.Trigraph sequences are replaced by corresponding single-character internal representations.

2. Eachinstance of a backslash character (\)immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on anyphysical source line shall be eligible for being part

5)Implementations shall behave asifthese separate phases occur,eventhough manyare typically folded together in practice.

§ Environment 9

ISO/IEC 9899:TC2Committee Draft — May 6, 2005WG14/N1124 of such a splice.Asource file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before anysuch splicing takes place.

3. Thesource file is decomposed into preprocessing tokens6)and sequences of white-space characters (including comments).Asource file shall not end in a partial preprocessing token or in a partial comment.Each comment is replaced by one space character.New-line characters are retained.Whether each nonempty sequence of white-space characters other than new-line is retained or replaced by one space character is implementation-defined.

4. Preprocessingdirectivesare executed, macro invocations are expanded, and

_Pragmaunary operator expressions are executed. Ifacharacter sequence that matches the syntax of a universal character name is produced by token concatenation (, the behavior is undefined.A#includepreprocessing directive causes the named header or source file to be processed from phase 1 through phase 4, recursively.All preprocessing directivesare then deleted.

5. Eachsource character set member and escape sequence in character constants and string literals is converted to the corresponding member of the execution character set; if there is no corresponding member,itisconverted to an implementation-

6. Adjacentstring literal tokens are concatenated.

7. White-spacecharacters separating tokens are no longer significant.Each preprocessing token is converted into a token. Theresulting tokens are syntactically and semantically analyzed and translated as a translation unit.

8. Allexternal object and function references are resolved. Librarycomponents are linked to satisfy external references to functions and objects not defined in the current translation.All such translator output is collected into a program image which contains information needed for execution in its execution environment.

(Parte 4 de 11)