1.
This 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 knowledgeable programmers, and is not a
tutorial. It is accompanied by a
Rationale document that explains many of the decisions of the Technical
Committee that produced it.
2.
Strictly conforming programs are intended to be maximally portable among
conforming implementations. Conforming
programs may depend upon nonportable features of a conforming implementation.
3.
Implementations must behave as if these separate phases occur, even though many
are typically folded together in practice.
4.
As described in $3.1, the process of dividing a source file's characters into
preprocessing tokens is context-dependent.
For example, see the handling of < within a #include preprocessing
directive.
5.
The trigraph sequences enable the input of characters that are not defined in
the "ISO 646-1983"
Invariant Code Set, which is a subset of the seven-bit
ASCII code set.
6.
Implementations should avoid imposing fixed translation limits whenever
possible.
7.
See $3.1.2.5.
8.
This model precludes floating-point representations other than sign-magnitude.
9.
The floating-point model in that standard sums powers of from zero, so the
values of the exponent limits are one less than shown here.
10.
See ``future language directions'' ($3.9.1).
11.
There is only one name space for tags even though three are possible.
12.
In the case of a volatile object, the last store may not be explicit in the
program.
13.
A positional representation for integers that uses the binary digits 0 and 1, in
which the values represented by successive bits are additive, begin with 1, and
are multiplied by successive integral powers of 2, except perhaps the bit with
the highest position. (Adapted from
the
14.
Note that aggregate type does not include union type because an object with
union type can only contain one member at a time.
15.
There are three distinct combinations of qualified types.
16.
Two types need not be identical to be compatible.
17.
The semantics of these characters were discussed in $2.2.2.
18.
See ``future language directions'' ($3.9.2).
19.
A character string literal need not be a string (see $4.1.1), because a null
character may be embedded in it by a \0 escape sequence.
20.
Thus, sequences of characters that resemble escape sequences cause undefined
behavior.
21.
Thus comments do not nest.
22.
In a two's-complement representation, there is no actual change in the bit
pattern except filling the high-order bits with copies of the sign bit if the
unsigned integer has greater size.
23.
The remaindering operation done when a value of integral type is converted to
unsigned type need not be done when a value of floating type is converted to
unsigned type. Thus the range of
portable values is [0, U type _MAX
+1).
24.
The name ``lvalue'' comes originally from the assignment expression E1 = E2 , in
which the left operand E1 must be a (modifiable) lvalue.
It is perhaps better considered as representing an object ``locator
value.'' What is sometimes called ``rvalue'' is in this Standard described as
the ``value of an expression.'' An obvious example of an lvalue is an identifier
of an object. As a further example, if E is a unary expression that is a
pointer to an object, *E is an lvalue that designates the object to which E
points.
25.
Because this conversion does not occur, the operand of the sizeof operator
remains a function designator and violates the constraint in $3.3.3.4.
26.
This paragraph renders undefined statement expressions such as
i = ++i + 1; while allowing
i = i + 1;
27.
The syntax specifies the precedence of operators in the evaluation of an
expression, which is the same as the order of the major subsections of this
section, highest precedence first. Thus,
for example, the expressions allowed as the operands of the binary + operator
($3.3.6) shall be those expressions defined in $3.3.1 through $3.3.6.
The exceptions are cast expressions ($3.3.4) as operands of unary
operators ($3.3.3), and an operand contained between any of the following pairs
of operators: grouping parentheses () ($3.3.1), subscripting brackets []
($3.3.2.1), function-call parentheses () ($3.3.2.2), and the conditional
operator ?: ($3.3.15). Within each
major subsection, the operators have the same precedence.
Left- or right-associativity is indicated in each subsection by the
syntax for the expressions discussed therein.
28.
The intent of this list is to specify those circumstances in which an object may
or may not be aliased.
29.
Most often, this is the result of converting an identifier that is a function
designator.
30.
That is, a function with external linkage and no information about its
parameters that returns an int . If
in fact it is not defined as having type ``function returning int ,'' the
behavior is undefined.
31.
A function may change the values of its parameters, but these changes cannot
affect the values of the arguments. On
the other hand, it is possible to pass a pointer to an object, and the function
may change the value of the object pointed to.
A parameter declared to have array or function type is converted to a
parameter with a pointer type as described in
32.
If &E is a valid pointer expression (where & is the ``address-of''
operator, which generates a pointer to its operand) the expression
(&E)->MOS is the same as E.MOS .
33.
The ``byte orders'' for scalar types are invisible to isolated programs that do
not indulge in type punning (for example, by assigning to one member of a union
and inspecting the storage by accessing another member that is an appropriately
sized array of character type), but must be accounted for when conforming to
externally-imposed storage layouts.
34.
It is always true that if E is a function designator or an lvalue that is a
valid operand of the unary & operator, *&E is a function designator or
an lvalue equal to E . If *P is an
lvalue and T is the name of an object pointer type, the cast expression *(T)P is
an lvalue that has a type compatible with that to which T points.
Among the invalid values for dereferencing a pointer by the unary *
operator are a null pointer, an address inappropriately aligned for the type of
object pointed to, or the address of an object that has automatic storage
duration when execution of the block in which the object is declared and of all
enclosed blocks has terminated.
35.
When applied to a parameter declared to have array or function type, the sizeof
operator yields the size of the pointer obtained by converting as in $3.2.2.1;
see $3.7.1.
36.
A cast does not yield an lvalue.
37.
The mapping functions for converting a pointer to an integer or an integer to a
pointer are intended to be consistent with the addressing structure of the
execution environment.
38.
The expression a<b<c is not interpreted as in ordinary mathematics.
As the syntax indicates, it means (a<b)<c ; in other words, ``if a
is less than b compare 1 to c ; otherwise compare 0 to c .''
39.
Because of the precedences, a<b =^= c<d is 1 whenever a<b and c<d
have the same truth-value.
40.
If invalid prior pointer operations, such as accesses outside array bounds,
produced undefined behavior, the effect of subsequent comparisons is undefined.
41.
A conditional expression does not yield an lvalue.
42.
The asymmetric appearance of these constraints with respect to type qualifiers
is due to the conversion (specified in $3.2.2.1) that changes lvalues to ``the
value of the expression'' which removes any type qualifiers from the top type of
the expression.
43.
A comma operator does not yield an lvalue.
44.
The operand of a sizeof operator is not evaluated ($3.3.3.4), and thus any
operator in $3.3 may be used.
45.
An integral constant expression must be used to specify the size of a bit-field
member of a structure, the value of an enumeration constant, the size of an
array, or the value of a case constant. Further
constraints that apply to the integral constant expressions used in
conditional-inclusion preprocessing directives are discussed in $3.8.1.
46.
Thus in the following initialization,
static int i = 2 || 1 / 0; the expression is a valid integral constant
expression with value one.
47.
Function definitions have a different syntax, described in $3.7.1.
48.
See ``future language directions'' ($3.9.3).
49.
The implementation may treat any register declaration simply as an auto
declaration. However, whether or
not addressable storage is actually used, the address of any part of an object
declared with storage-class specifier register may not be computed, either
explicitly (by use of the unary & operator as discussed in $3.3.3.2) or
implicitly (by converting an array name to a pointer as discussed in $3.2.2.1).
Thus the only operator that can be applied to an array declared with
storage-class specifier register is sizeof .
50.
The unary & (address-of) operator may not be applied to a bit-field object;
thus there are no pointers to or arrays of bit-field objects.
51.
An unnamed bit-field is useful for padding to conform to externally-imposed
layouts.
52.
Thus, the identifiers of enumeration constants in the same scope shall all be
distinct from each other and from other identifiers declared in ordinary
declarators.
53.
A similar construction with enum does not exist and is not necessary as there
can be no mutual dependencies between the declaration of an enumerated type and
any other type.
54.
It is not needed, for example, when a typedef name is declared to be a specifier
for a structure or union, or when a pointer to or a function returning a
structure or union is being declared. (See
incomplete types in $3.1.2.5.) The specification shall be complete before such a
function is called or defined.
55.
Of course, when the declaration is of a typedef name, subsequent declarations
can make use of the typedef name to declare objects having the specified
structure, union, or enumerated type.
56.
The implementation may place a const object that is not volatile in a read-only
region of storage. Moreover, the
implementation need not allocate storage for such an object if its address is
never used.
57.
This applies to those objects that behave as if they were defined with qualified
types, even if they are never actually defined as objects in the program (such
as an object at a memory-mapped input/output address).
58.
A volatile declaration may be used to describe an object corresponding to a
memory-mapped input/output port or an object accessed by an asynchronously
interrupting function. Actions on
objects so declared shall not be ``optimized out'' by an implementation or
reordered except as permitted by the rules for evaluating expressions.
59.
Both of these can only occur through the use of typedef s.
60.
When several ``array of'' specifications are adjacent, a multi-dimensional array
is declared.
61.
The macros defined in the <stdarg.h> header ($4.8) may be used to access
arguments that follow an ellipsis.
62.
See ``future language directions'' ($3.9.4).
63.
If both function types are ``old style,'' parameter types are not compared.
64.
As indicated by the syntax, empty parentheses in a type name are interpreted as
``function with no parameter specification,'' rather than redundant parentheses
around the omitted identifier.
65.
Unlike in the base document, any automatic duration object may be initialized.
66.
Such as assignments, and function calls which have side effects.
67.
Thus specifies initialization for the loop; the controlling expression,
specifies an evaluation made before each iteration, such that execution of the loop continues until the
expression compares equal to 0; specifies an operation (such as incrementing)
that is performed after each iteration.
68.
Following the contin: label is a null statement.
69.
Thus, if an identifier declared with external linkage is not used in an
expression, there need be no external definition for it.
70.
The intent is that the top type in a function definition cannot be inherited
from a typedef: typedef int F(void);
/* type F
is ``function of no arguments returning int '' */ F f, g;
/* f
and g both have type
compatible with F */ F f { /*...*/ }
/* WRONG: syntax/constraint
error */ F g() { /*...*/ }
/* WRONG: declares that g
returns a function */ int f(void) { /*...*/ }
/* RIGHT: f
has type compatible with F */ int g() { /*...*/ }
/* RIGHT: g
has type compatible with F */ F *e(void) { /*...*/ }
/* e
returns a pointer to a function */ F *((e))(void) { /*...*/ } /*
same: parentheses irrelevant */ int (*fp)(void);
/* fp points to a function
that has type F */ F *Fp;
/* Fp points to a function
that has type F */
71.
See ``future language directions'' ($3.9.5).
72.
A parameter is in effect declared at the head of the compound statement that
constitutes the function body, and therefore may not be redeclared in the
function body (except in an enclosed block).
73.
Thus preprocessing directives are commonly called ``lines.'' These ``lines''
have no other syntactic significance, as all white space is equivalent except in
certain situations during preprocessing (see the # character string literal
creation operator in $3.8.3.2, for example).
74.
Because the controlling constant expression is evaluated during translation
phase 4, all identifiers either are or are not macro names --- there simply are
no keywords, enumeration constants, and so on.
75.
Thus the constant expression in the following #if directive and if statement is
not guaranteed to evaluate to the same value in these two contexts.
#if 'z' - 'a' =^= 25
if ('z' - 'a' =^= 25)
76.
As indicated by the syntax, a preprocessing token shall not follow a #else or
#endif directive before the terminating new-line character.
However, comments may appear anywhere in a source file, including within
a preprocessing directive.
77.
Note that adjacent string literals are not concatenated into a single string
literal (see the translation phases in $2.1.1.2); thus an expansion that results
in two string literals is an invalid directive.
78.
Since, by macro-replacement time, all character constants and string literals
are preprocessing tokens, not sequences possibly containing identifier-like
subsequences (see $2.1.1.2, translation phases), they are never scanned for
macro names or parameters.
79.
Thus indicating a Standard-conforming implementation.
80.
The functions that make use of the decimal-point character are localeconv ,
fprintf , fscanf , printf , scanf , sprintf , sscanf , vfprintf , vprintf ,
vsprintf , atof , and strtod .
81.
A header is not necessarily a source file, nor are the < and > delimited
sequences in header names necessarily valid source file names.
82.
The list of reserved external identifiers includes errno , setjmp , and va_end .
83.
The macro errno need not be the identifier of an object. It might be a modifiable lvalue resulting from a function
call (for example, *errno() ).
84.
Thus, a program that uses errno for error checking should set it to zero before
a library function call, then inspect it before a subsequent library function
call.
85.
See ``future library directions'' ($4.13.1).
86.
This means that an implementation must provide an actual function for each
library function, even if it also provides a macro for that function.
87.
Because external identifiers and some macro names beginning with an underscore
are reserved, implementations may provide special semantics for such names.
For example, the identifier _BUILTIN_abs could be used to indicate
generation of in-line code for the abs function.
Thus, the appropriate header could specify
#define abs(x) _BUILTIN_abs(x) for a compiler whose code generator will
accept it. In this manner, a user
desiring to guarantee that a given library function such as abs will be a
genuine function may write
#undef abs whether the implementation's header provides a macro
implementation of abs or a builtin implementation.
The prototype for the function, which precedes and is hidden by any macro
definition, is thereby revealed also.
88.
The message written might be of the form Assertion failed: file line
89.
See ``future library directions'' ($4.13.2).
90.
In an implementation that uses the seven-bit
ASCII character set, the printing characters are those whose values lie
from 0x20 (space) through 0x7E (tilde); the control characters are those whose
values lie from 0 (NUL) through 0x1F (US), and the character 0x7F (DEL).
91.
See ``future library directions'' ($4.13.3).
92.
The only functions in $4.3 whose behavior is not affected by the current locale
are isdigit and isxdigit .
93.
See ``future library directions'' ($4.13.4).
94.
In an implementation that supports infinities, this allows infinity as an
argument to be a domain error if the mathematical domain of the function does
not include infinity.
95.
These functions are useful for dealing with unusual conditions encountered in a
low-level function of a program.
96.
For example, by executing a return statement or because another longjmp call has
caused a transfer to a setjmp invocation in a function earlier in the set of
nested calls.
97.
See ``future library directions'' ($4.13.5).
The names of the signal numbers reflect the following terms
(respectively): abort, floating-point exception, illegal instruction, interrupt,
segmentation violation, and termination.
98.
Of course, the contents of the file name strings are subject to other
system-specific constraints.
99.
An implementation need not distinguish between text streams and binary streams.
In such an implementation, there need be no new-line characters in a text
stream nor any limit to the length of a line.
100.
This is described in the Base Document as a That term is not used in this
Standard to avoid confusion with a pointer to an object that has type FILE .
101.
Among the reasons the implementation may cause the rename function to fail are
that the file is open or that it is necessary to copy its contents to effectuate
its renaming.
102.
Files created using strings generated by the tmpnam function are temporary only
in the sense that their names should not collide with those generated by
conventional naming rules for the implementation. It is still necessary to use the remove function to remove
such files when their use is ended, and before program termination.
103.
Additional characters may follow these sequences.
104.
The primary use of the freopen function is to change the file associated with a
standard text stream ( stderr , stdin , or stdout ), as those identifiers need
not be modifiable lvalues to which the value returned by the fopen function may
be assigned.
105.
The buffer must have a lifetime at least as great as the open stream, so the
stream should be closed before a buffer that has automatic storage duration is
deallocated upon block exit.
106.
Note that 0 is taken as a flag, not as the beginning of a field width.
107.
No special provisions are made for multibyte characters.
108.
See ``future library directions'' ($4.13.6).
109.
No special provisions are made for multibyte characters.
110.
See ``future library directions'' ($4.13.6).
111.
As vfprintf , vsprintf , and vprintf invoke the va_arg macro, the value of arg
after the return is indeterminate.
112.
An end-of-file and a read error can be distinguished by use of the feof and
ferror functions.
113.
See ``future library directions'' ($4.13.7).
114.
Note that this need not be the same as the representation of floating-point zero
or a null pointer constant.
115.
Each function is called as many times as it was registered.
116.
Notice that the key-to-member comparison an ordering on the array.
117.
In a two's complement representation, the absolute value of the most negative
number cannot be represented.
118.
The array will not be null- or zero-terminated if the value returned is n .
119.
See ``future library directions'' ($4.13.8).
120.
Thus, if there is no null character in the first n characters of the array
pointed to by s2 , the result will not be null-terminated.
121.
Thus the maximum number of characters that end up in the array pointed to by s1
is strlen(s1)+n+1 .
122.
The contents of ``holes'' used as padding for purposes of alignment within
structure objects are indeterminate, unless the contents of the entire object
have been set explicitly, as by the calloc or memset function. Strings
shorter than their allocated space and unions may also cause problems in
comparison.
123.
The range [0, 60] for tm_sec allows for the occasional leap second.
124.
Thus, a positive or zero value for tm_isdst causes the mktime function initially
to presume that Daylight Saving Time, respectively, is or is not in effect for
the specified time. A negative
value for tm_isdst causes the mktime function to attempt to determine whether
Daylight Saving Time is in effect for the specified time.
NDP77
http://www.ndp77.net
webmaster Massimo F. ARENA
webmaster@ndp77.net