ISO/IEC9899:201xCommittee Draft August 11, 2008WG14/N1336converted to a token), the behavior is undefined4A letter is an uppercase letter or a lowercase letter as defined above; in this InternationalStandardthetermdoesnot includeothercharactersthatarelettersinotheralphabetsTheuniversalcharacternameconstructprovidesawaytonameothercharactersForward references: universal character names (6.4.3), character constants (6.4.4.4),preprocessing directives (6.10), string literals (6.4.5), comments (6.4.9), string (7.1.1)5.2.1.1 Trigraph sequencesBefore any other processing takes place, each occurrence of one of the followingsequences of three characters (called trigraph sequences13) is replaced with thecorresponding single character.??=#??)??!111??([??!??>1??/\??<{??-No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listedabove is not changed.EXAMPLE12??=define arraycheck(a,b)a??(b??)??!??!b??(a??)becomes#define arraycheck(a,b)a[b] Il b[a]EXAMPLE2The following source line3printf("Eh???/n");becomes(afterreplacement of thetrigraphsequence??/)printf("Eh?In");5.2.1.2Multibyte charactersThe source character set may contain multibyte characters, used to represent members ofthe extended character set.The execution character set may also contain multibytecharacters, which need not have the same encoding as for the source character set.Forboth character sets, the following shall hold:The basic character set shall be present and each character shall be encoded as asingle byteThe presence, meaning, and representation of any additional members is locale-specific.I3)Thetrigraph sequences enablethe input of characters that arenotdefined in the Invariant Code Set asdescribed in ISO/IEC646,which is a subset of the seven-bitUSASCII code set.18$5.2.1.2Environment
ISO/IEC 9899:201x Committee Draft — August 11, 2008 WG14/N1336 converted to a token), the behavior is undefined. 4 A letter is an uppercase letter or a lowercase letter as defined above; in this International Standard the term does not include other characters that are letters in other alphabets. 5 The universal character name construct provides a way to name other characters. Forward references: universal character names (6.4.3), character constants (6.4.4.4), preprocessing directives (6.10), string literals (6.4.5), comments (6.4.9), string (7.1.1). 5.2.1.1 Trigraph sequences 1 Before any other processing takes place, each occurrence of one of the following sequences of three characters (called trigraph sequences13)) is replaced with the corresponding single character. ??= # ??( [ ??/ \ ??) ] ??' ^ ??< { ??! | ??> } ??- ~ No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listed above is not changed. 2 EXAMPLE 1 ??=define arraycheck(a, b) a??(b??) ??!??! b??(a??) becomes #define arraycheck(a, b) a[b] || b[a] 3 EXAMPLE 2 The following source line printf("Eh???/n"); becomes (after replacement of the trigraph sequence ??/) printf("Eh?\n"); 5.2.1.2 Multibyte characters 1 The source character set may contain multibyte characters, used to represent members of the extended character set. The execution character set may also contain multibyte characters, which need not have the same encoding as for the source character set. For both character sets, the following shall hold: — The basic character set shall be present and each character shall be encoded as a single byte. — The presence, meaning, and representation of any additional members is localespecific. 13) The trigraph sequences enable the input of characters that are not defined in the Invariant Code Set as described in ISO/IEC 646, which is a subset of the seven-bit US ASCII code set. 18 Environment §5.2.1.2
WG14/N1336Committee Draft — August 11, 2008ISO/IEC9899:201xA multibyte character set may have a state-dependent encoding, wherein eachsequence of multibyte characters begins in an initial shift state and enters otherlocale-specificshiftstateswhenspecificmultibytecharacters areencountered inthesequence. While in the initial shift state, all single-byte characters retain their usualinterpretation and do not alter the shift state. The interpretation for subsequent bytesinthesequenceisafunctionofthecurrentshiftstate.-A byte with all bits zero shall be interpreted as a null character independent of shiftstate.Such a byte shall not occur as part of any other multibyte character.2For source files, thefollowing shall hold:-Anidentifier,comment,stringliteral,characterconstant.orheadernameshallbeginand end in the initial shift state.An identifier, comment, string literal, character constant, or header name shall consistofa sequenceofvalidmultibytecharacters.5.2.2CharacterdisplaysemanticsThe active position is that location on a display device where the next character output bythe fputc function would appear.The intent of writing a printing character (as definedby the isprint function) to a display device is to display a graphic representation ofthat character at the active position and then advance the active position to the nextposition on the current line.The direction of writing is locale-specific. If the activeposition is at the final position of a line (if there is one), the behavior of the display deviceis unspecified.2Alphabetic escape sequences representing nongraphic characters in the executioncharacter set are intended to produce actions on display devices as follows:Ia (alert) Produces an audible or visible alert without changing the active position.Ib (backspace) Moves the active position to the previous position on the current line. Ifthe active position is at the initial position of a line, the behavior of the displaydevice is unspecified.If (form feed)Moves the activeposition to the initial position at the start of the nextlogical page.In(new line)Movestheactive position tothe initial position of the next lineIr (carriage return) Moves the activeposition to the initial position of the current line.It (horizontal tab) Moves the active position to the next horizontal tabulation positionon the current line. If the active position is at or past the last defined horizontaltabulation position, the behavior of the display device is unspecified.Iv (vertical tab) Moves the active position to the initial position of the next verticaltabulation position. If the active position is at or past the last defined vertical19$5.2.2Environment
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x —A multibyte character set may have a state-dependent encoding, wherein each sequence of multibyte characters begins in an initial shift state and enters other locale-specific shift states when specific multibyte characters are encountered in the sequence. While in the initial shift state, all single-byte characters retain their usual interpretation and do not alter the shift state. The interpretation for subsequent bytes in the sequence is a function of the current shift state. — A byte with all bits zero shall be interpreted as a null character independent of shift state. Such a byte shall not occur as part of any other multibyte character. 2 For source files, the following shall hold: — An identifier, comment, string literal, character constant, or header name shall begin and end in the initial shift state. — An identifier, comment, string literal, character constant, or header name shall consist of a sequence of valid multibyte characters. 5.2.2 Character display semantics 1 The active position is that location on a display device where the next character output by the fputc function would appear. The intent of writing a printing character (as defined by the isprint function) to a display device is to display a graphic representation of that character at the active position and then advance the active position to the next position on the current line. The direction of writing is locale-specific. If the active position is at the final position of a line (if there is one), the behavior of the display device is unspecified. 2 Alphabetic escape sequences representing nongraphic characters in the execution character set are intended to produce actions on display devices as follows: \a (alert) Produces an audible or visible alert without changing the active position. \b (backspace) Moves the active position to the previous position on the current line. If the active position is at the initial position of a line, the behavior of the display device is unspecified. \f ( form feed) Moves the active position to the initial position at the start of the next logical page. \n (new line) Moves the active position to the initial position of the next line. \r (carriage return) Moves the active position to the initial position of the current line. \t (horizontal tab) Moves the active position to the next horizontal tabulation position on the current line. If the active position is at or past the last defined horizontal tabulation position, the behavior of the display device is unspecified. \v (vertical tab) Moves the active position to the initial position of the next vertical tabulation position. If the active position is at or past the last defined vertical §5.2.2 Environment 19
ISO/IEC9899:201xCommittee Draft — August 11, 2008WG14/N1336tabulation position, the behavior of the display device is unspecified3Each of these escape sequences shall produce a unique implementation-defined valuewhich can be stored in a single char object.The external representations in a text fileneed not be identical to the internal representations, and are outside the scope of thisInternational Standard.Forward references:the isprint function (7.4.1.8),thefputcfunction (7.19.7.3)5.2.3 Signals and interruptsFunctions shall be implemented such that they maybe interrupted at any time by a signal.or may be called by a signal handler, or both, with no alteration to earlier, but still active.invocations' control flow (after the interruption), function return values, or objects withautomatic storage duration. All such objects shall be maintained outside the functionimage (the instructions that compose the executable representation of a function) on aper-invocation basis.5.2.4 Environmental limitsBoth the translation and execution environments constrain the implementation oflanguage translators and libraries.The following summarizes the language-relatedenvironmental limits on a conforming implementation, the library-related limits arediscussed in clause 7.5.2.4.1Translation limitsThe implementation shall be able to translate and execute at least one program thatcontains at least one instance of every one of the following limits:14)127nestinglevelsofblocks63nestinglevelsofconditional inclusion—12pointer,array,and function declarators (in any combinations)modifying anarithmetic, structure, union, or incomplete type in a declaration63 nesting levels of parenthesized declarators within a full declarator 63 nesting levels of parenthesized expressions within a full expression—63 significant initial characters in an internal identifier or a macro name (eachuniversal character name or extended source character is considered a singlecharacter)31 significant initial characters in an external identifier (each universal character namespecifying a short identifier of 0000FFFF or less is considered 6 characters, each14)Implementations should avoid imposing fixed translation limits whenever possible.20Environment$5.2.4.1
ISO/IEC 9899:201x Committee Draft — August 11, 2008 WG14/N1336 tabulation position, the behavior of the display device is unspecified. 3 Each of these escape sequences shall produce a unique implementation-defined value which can be stored in a single char object. The external representations in a text file need not be identical to the internal representations, and are outside the scope of this International Standard. Forward references: the isprint function (7.4.1.8), the fputc function (7.19.7.3). 5.2.3 Signals and interrupts 1 Functions shall be implemented such that they may be interrupted at any time by a signal, or may be called by a signal handler, or both, with no alteration to earlier, but still active, invocations’ control flow (after the interruption), function return values, or objects with automatic storage duration. All such objects shall be maintained outside the function image (the instructions that compose the executable representation of a function) on a per-invocation basis. 5.2.4 Environmental limits 1 Both the translation and execution environments constrain the implementation of language translators and libraries. The following summarizes the language-related environmental limits on a conforming implementation; the library-related limits are discussed in clause 7. 5.2.4.1 Translation limits 1 The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:14) — 127 nesting levels of blocks — 63 nesting levels of conditional inclusion — 12 pointer, array, and function declarators (in any combinations) modifying an arithmetic, structure, union, or incomplete type in a declaration — 63 nesting levels of parenthesized declarators within a full declarator — 63 nesting levels of parenthesized expressions within a full expression — 63 significant initial characters in an internal identifier or a macro name (each universal character name or extended source character is considered a single character) — 31 significant initial characters in an external identifier (each universal character name specifying a short identifier of 0000FFFF or less is considered 6 characters, each 14) Implementations should avoid imposing fixed translation limits whenever possible. 20 Environment §5.2.4.1
WG14/N1336Committee Draft — August 11, 2008ISO/IEC9899:201xuniversal character name specifying a short identifier of 00010000 or more isconsidered 10 characters, and each extended source character is considered the samenumber of characters as the corresponding universal character name, if any)15)4095external identifiers inone translationunit-511identifierswithblockscopedeclared inoneblock4095macro identifiers simultaneouslydefined inonepreprocessingtranslation unit-127parameters in onefunction definition 127 arguments in one function call—127parametersinonemacrodefinition127arguments in one macro invocation—4095 characters in a logical source line4095 characters in a character string literal or wide string literal (after concatenation)— 65535 bytes in an object (in a hosted environment only)—15nestinglevelsfor#includedfiles1023caselabelsforaswitch statement (excludingthoseforany nested switchstatements)1023membersinasinglestructureorunion—1023enumerationconstantsinasingleenumeration 63 levels of nested structure or union definitions in a single struct-declaration-list5.2.4.2 Numerical limitsAn implementation is required to document all the limits specified in this subclause,which are specified in the headers<1imits.h>and<f1oat.h>.Additional limits arespecifiedin<stdint.h>.Forwardreferences:integertypes<stdint.h>(7.18)5.2.4.2.1 Sizes ofinteger types <limits.h>The values given below shall be replaced by constant expressions suitable for use in #if1preprocessing directives. Moreover, except for CHAR BIT and MB LEN MAX, thefollowing shall be replaced by expressions that have the same type as would anexpression that is an object of the corresponding type converted according to the integerpromotions.Their implementation-defined values shall be equal or greater in magnitude15)See“future language directions"(6.11.3).21$5.2.4.2.1Environment
WG14/N1336 Committee Draft — August 11, 2008 ISO/IEC 9899:201x universal character name specifying a short identifier of 00010000 or more is considered 10 characters, and each extended source character is considered the same number of characters as the corresponding universal character name, if any)15) — 4095 external identifiers in one translation unit — 511 identifiers with block scope declared in one block — 4095 macro identifiers simultaneously defined in one preprocessing translation unit — 127 parameters in one function definition — 127 arguments in one function call — 127 parameters in one macro definition — 127 arguments in one macro invocation — 4095 characters in a logical source line — 4095 characters in a character string literal or wide string literal (after concatenation) — 65535 bytes in an object (in a hosted environment only) — 15 nesting levels for #included files — 1023 case labels for a switch statement (excluding those for any nested switch statements) — 1023 members in a single structure or union — 1023 enumeration constants in a single enumeration — 63 lev els of nested structure or union definitions in a single struct-declaration-list 5.2.4.2 Numerical limits 1 An implementation is required to document all the limits specified in this subclause, which are specified in the headers <limits.h> and <float.h>. Additional limits are specified in <stdint.h>. Forward references: integer types <stdint.h> (7.18). 5.2.4.2.1 Sizes of integer types <limits.h> 1 The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. Moreover, except for CHAR_BIT and MB_LEN_MAX, the following shall be replaced by expressions that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. Their implementation-defined values shall be equal or greater in magnitude 15) See ‘‘future language directions’’ (6.11.3). §5.2.4.2.1 Environment 21
ISO/IEC9899:201xCommittee Draft—August 11, 2008WG14/N1336(absolute value) to those shown, with the same sign.number of bits for smallest object that is not a bit-field (byte)8CHAR BITminimum value for an objectoftype signed char-127 / / -(27-1)SCHAR MINmaximum valuefor anobjectoftype signed char+127 // 27-1SCHAR MAXmaximum value for an object of type unsigned char255 // 28-1UCHAR MAXminimum valuefor an object of type charCHAR MINsee belowmaximum value for an object of type charCHAR MAXsee belowmaximum numberofbytes in a multibytecharacter,for anysupported localeMB LEN MAX1minimum valueforanobjectoftype short int-32767 / / -(215-1)SHRT MINmaximum value for an object oftype short int+32767 // 215-1SHRT MAXmaximum value for an object oftype unsigned short int65535//2161USHRT MAXminimumvalueforanobjectoftypeint-32767 / / -(2151)INT MINmaximum value for an object oftype int+32767 // 215-1INT MAXmaximum value for an object oftype unsigned int65535 //2161UINT MAXminimumvalueforan objectoftypelong int-2147483647 // -(231-1)LONG MINmaximum value for an object oftype long int+2147483647//231-1LONG MAXmaximum value for an objectoftype unsigned long int4294967295//232-1ULONG MAX22Environment$5.2.4.2.1
ISO/IEC 9899:201x Committee Draft — August 11, 2008 WG14/N1336 (absolute value) to those shown, with the same sign. — number of bits for smallest object that is not a bit-field (byte) CHAR_BIT 8 — minimum value for an object of type signed char SCHAR_MIN -127 // −(27 − 1) — maximum value for an object of type signed char SCHAR_MAX +127 // 2 7 − 1 — maximum value for an object of type unsigned char UCHAR_MAX 255 // 2 8 − 1 — minimum value for an object of type char CHAR_MIN see below — maximum value for an object of type char CHAR_MAX see below — maximum number of bytes in a multibyte character, for any supported locale MB_LEN_MAX 1 — minimum value for an object of type short int SHRT_MIN -32767 // −(215 − 1) — maximum value for an object of type short int SHRT_MAX +32767 // 2 15 − 1 — maximum value for an object of type unsigned short int USHRT_MAX 65535 // 2 16 − 1 — minimum value for an object of type int INT_MIN -32767 // −(215 − 1) — maximum value for an object of type int INT_MAX +32767 // 2 15 − 1 — maximum value for an object of type unsigned int UINT_MAX 65535 // 2 16 − 1 — minimum value for an object of type long int LONG_MIN -2147483647 // −(231 − 1) — maximum value for an object of type long int LONG_MAX +2147483647 // 2 31 − 1 — maximum value for an object of type unsigned long int ULONG_MAX 4294967295 // 2 32 − 1 22 Environment §5.2.4.2.1