Стандарт языка Си С99 TC (1113411), страница 14
Текст из файла (страница 14)
Except as previously specified, theresult is implementation-defined, might not be correctly aligned, might not point to anentity of the referenced type, and might be a trap representation.56)6Any pointer type may be converted to an integer type.
Except as previously specified, theresult is implementation-defined. If the result cannot be represented in the integer type,the behavior is undefined. The result need not be in the range of values of any integertype.7A pointer to an object or incomplete type may be converted to a pointer to a differentobject or incomplete type. If the resulting pointer is not correctly aligned57) for thepointed-to type, the behavior is undefined.
Otherwise, when converted back again, theresult shall compare equal to the original pointer. When a pointer to an object is55) The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.17.56) The mapping functions for converting a pointer to an integer or an integer to a pointer are intended tobe consistent with the addressing structure of the execution environment.57) In general, the concept ‘‘correctly aligned’’ is transitive: if a pointer to type A is correctly aligned for apointer to type B, which in turn is correctly aligned for a pointer to type C, then a pointer to type A iscorrectly aligned for a pointer to type C.§6.3.2.3Language47ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256converted to a pointer to a character type, the result points to the lowest addressed byte ofthe object.
Successive increments of the result, up to the size of the object, yield pointersto the remaining bytes of the object.8A pointer to a function of one type may be converted to a pointer to a function of anothertype and back again; the result shall compare equal to the original pointer. If a convertedpointer is used to call a function whose type is not compatible with the pointed-to type,the behavior is undefined.Forward references: cast operators (6.5.4), equality operators (6.5.9), integer typescapable of holding object pointers (7.18.1.4), simple assignment (6.5.16.1).48Language§6.3.2.3WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC36.4 Lexical elementsSyntax1token:keywordidentifierconstantstring-literalpunctuatorpreprocessing-token:header-nameidentifierpp-numbercharacter-constantstring-literalpunctuatoreach non-white-space character that cannot be one of the aboveConstraints2Each preprocessing token that is converted to a token shall have the lexical form of akeyword, an identifier, a constant, a string literal, or a punctuator.Semantics3A token is the minimal lexical element of the language in translation phases 7 and 8.
Thecategories of tokens are: keywords, identifiers, constants, string literals, and punctuators.A preprocessing token is the minimal lexical element of the language in translationphases 3 through 6. The categories of preprocessing tokens are: header names,identifiers, preprocessing numbers, character constants, string literals, punctuators, andsingle non-white-space characters that do not lexically match the other preprocessingtoken categories.58) If a ' or a " character matches the last category, the behavior isundefined. Preprocessing tokens can be separated by white space; this consists ofcomments (described later), or white-space characters (space, horizontal tab, new-line,vertical tab, and form-feed), or both. As described in 6.10, in certain circumstancesduring translation phase 4, white space (or the absence thereof) serves as more thanpreprocessing token separation.
White space may appear within a preprocessing tokenonly as part of a header name or between the quotation characters in a character constantor string literal.58) An additional category, placemarkers, is used internally in translation phase 4 (see 6.10.3.3); it cannotoccur in source files.§6.4Language49ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12564If the input stream has been parsed into preprocessing tokens up to a given character, thenext preprocessing token is the longest sequence of characters that could constitute apreprocessing token. There is one exception to this rule: header name preprocessingtokens are recognized only within #include preprocessing directives and inimplementation-defined locations within #pragma directives.
In such contexts, asequence of characters that could be either a header name or a string literal is recognizedas the former.5EXAMPLE 1 The program fragment 1Ex is parsed as a preprocessing number token (one that is not avalid floating or integer constant token), even though a parse as the pair of preprocessing tokens 1 and Exmight produce a valid expression (for example, if Ex were a macro defined as +1). Similarly, the programfragment 1E1 is parsed as a preprocessing number (one that is a valid floating constant token), whether ornot E is a macro name.6EXAMPLE 2 The program fragment x+++++y is parsed as x ++ ++ + y, which violates a constraint onincrement operators, even though the parse x ++ + ++ y might yield a correct expression.Forward references: character constants (6.4.4.4), comments (6.4.9), expressions (6.5),floating constants (6.4.4.2), header names (6.4.7), macro replacement (6.10.3), postfixincrement and decrement operators (6.5.2.4), prefix increment and decrement operators(6.5.3.1), preprocessing directives (6.10), preprocessing numbers (6.4.8), string literals(6.4.5).6.4.1 KeywordsSyntax1keyword: one ofautobreakcasecharconstcontinuedefaultdodoubleelseenumexternfloatforgotoifinlineintlongregisterrestrictreturnshortsignedsizeofstaticstructswitchtypedefunionunsignedvoidvolatilewhile_Bool_Complex_ImaginarySemantics2The above tokens (case sensitive) are reserved (in translation phases 7 and 8) for use askeywords, and shall not be used otherwise.
The keyword _Imaginary is reserved forspecifying imaginary types.59)59) One possible specification for imaginary types appears in annex G.50Language§6.4.1WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC36.4.2 Identifiers6.4.2.1 GeneralSyntax1identifier:identifier-nondigitidentifier identifier-nondigitidentifier digitidentifier-nondigit:nondigituniversal-character-nameother implementation-defined charactersnondigit: one of_ a bn oA BN OcpCPdqDQerERfsFSgtGThuHUivIVdigit: one of0 134567892jwJWkxKXlyLYmzMZSemantics2An identifier is a sequence of nondigit characters (including the underscore _, thelowercase and uppercase Latin letters, and other characters) and digits, which designatesone or more entities as described in 6.2.1.
Lowercase and uppercase letters are distinct.There is no specific limit on the maximum length of an identifier.3Each universal character name in an identifier shall designate a character whose encodingin ISO/IEC 10646 falls into one of the ranges specified in annex D.60) The initialcharacter shall not be a universal character name designating a digit.
An implementationmay allow multibyte characters that are not part of the basic source character set toappear in identifiers; which characters and their correspondence to universal characternames is implementation-defined.4When preprocessing tokens are converted to tokens during translation phase 7, if apreprocessing token could be converted to either a keyword or an identifier, it is convertedto a keyword.60) On systems in which linkers cannot accept extended characters, an encoding of the universal charactername may be used in forming valid external identifiers. For example, some otherwise unusedcharacter or sequence of characters may be used to encode the \u in a universal character name.Extended characters may produce a long external identifier.§6.4.2.1Language51ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256Implementation limits5As discussed in 5.2.4.1, an implementation may limit the number of significant initialcharacters in an identifier; the limit for an external name (an identifier that has externallinkage) may be more restrictive than that for an internal name (a macro name or anidentifier that does not have external linkage).
The number of significant characters in anidentifier is implementation-defined.6Any identifiers that differ in a significant character are different identifiers. If twoidentifiers differ only in nonsignificant characters, the behavior is undefined.Forward references: universal character names (6.4.3), macro replacement (6.10.3).6.4.2.2 Predefined identifiersSemantics1The identifier _ _func_ _ shall be implicitly declared by the translator as if,immediately following the opening brace of each function definition, the declarationstatic const char _ _func_ _[] = "function-name";appeared, where function-name is the name of the lexically-enclosing function.61)2This name is encoded as if the implicit declaration had been written in the sourcecharacter set and then translated into the execution character set as indicated in translationphase 5.3EXAMPLEConsider the code fragment:#include <stdio.h>void myfunc(void){printf("%s\n", _ _func_ _);/* ...