1 .\" Copyright (C) Caldera International Inc. 2001-2002. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions are
7 .\" Redistributions of source code and documentation must retain the above
8 .\" copyright notice, this list of conditions and the following
11 .\" Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
18 .\" This product includes software developed or owned by Caldera
19 .\" International, Inc. Neither the name of Caldera International, Inc.
20 .\" nor the names of other contributors may be used to endorse or promote
21 .\" products derived from this software without specific prior written
24 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
25 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
26 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 .\" DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
34 .\" OR OTHERWISE) RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
35 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 .\" @(#)Clang.ms 8.1 (Berkeley) 6/8/93
40 The C Programming Language - Reference Manual
44 AT&T Bell Laboratories
47 This manual is a reprint, with updates to the current C standard, from
48 \fIThe C Programming Language\fR,
49 by Brian W. Kernighan and Dennis M. Ritchie, Prentice-Hall, Inc., 1978.
51 \fBThis document is of historical interest only. Do not use it as a reference
52 for modern implementations of C.\fP
53 .EH 'PSD:6-%''The C Programming Language - Reference Manual'
54 .OH 'The C Programming Language - Reference Manual''PSD:6-%'
58 This manual describes the C language on the DEC PDP-11\(dg, the DEC VAX-11,
61 \(dg DEC PDP-11, and DEC VAX-11 are trademarks of Digital Equipment Corporation.
63 \(dd 3B 20 is a trademark of AT&T.
65 and the AT&T 3B 20\(dd.
66 Where differences exist, it concentrates on the VAX, but tries to point
67 out implementation-dependent details. With few exceptions, these dependencies
68 follow directly from the underlying properties of the hardware; the various
69 compilers are generally quite compatible.
73 There are six classes of tokens\ -\
74 identifiers, keywords, constants, strings, operators, and other separators.
75 Blanks, tabs, new\(hylines,
76 and comments (collectively, ``white space'') as described below
77 are ignored except as they serve to separate
79 Some white space is required to separate
80 otherwise adjacent identifiers,
81 keywords, and constants.
83 If the input stream has been parsed into tokens
84 up to a given character, the next token is taken
85 to include the longest string of characters
86 which could possibly constitute a token.
94 introduce a comment which terminates
101 An identifier is a sequence of letters and digits.
102 The first character must be a letter.
106 Uppercase and lowercase letters
108 Although there is no limit on the length of a name,
109 only initial characters are significant: at least
110 eight characters of a non-external name, and perhaps
111 fewer for external names.
112 Moreover, some implementations may collapse case
113 distinctions for external names.
114 The external name sizes include:
118 PDP-11 7 characters, 2 cases
119 VAX-11 >100 characters, 2 cases
120 AT&T 3B 20 >100 characters, 2 cases
127 The following identifiers are reserved for use
128 as keywords and may not be used otherwise:
130 .ta 0.8i 1.6i 2.4i 3.2i 4.0i
131 \fBauto do for return typedef
132 break double goto short union
133 case else if sizeof unsigned
134 char enum int static void
135 continue external long struct while
136 default float register switch\fR
140 Some implementations also reserve the words
142 fortran, asm, gfloat, hfloat
150 There are several kinds
152 Each has a type; an introduction to types is given in ``NAMES.''
153 Hardware characteristics that affect sizes are summarized in
154 ``Hardware Characteristics'' under ``LEXICAL CONVENTIONS.''
159 An integer constant consisting of a sequence of digits
161 to be octal if it begins with
166 An octal constant consists of the digits \fB0\fR through \fB7\fR only.
167 A sequence of digits preceded by
175 (digit zero) is taken to be a hexadecimal integer.
176 The hexadecimal digits include
192 with values 10 through 15.
193 Otherwise, the integer constant is taken to be decimal.
194 A decimal constant whose value exceeds the largest
195 signed machine integer is taken to be
197 an octal or hex constant which exceeds the largest unsigned machine integer
198 is likewise taken to be
202 Otherwise, integer constants are \fBint\fR.
204 Explicit Long Constants
207 A decimal, octal, or hexadecimal integer constant immediately followed
220 integer and long values may be considered identical.
225 A character constant is a character enclosed in single quotes,
227 The value of a character constant is the numerical value of the
228 character in the machine's character set.
230 Certain nongraphic characters,
235 may be represented according to the following table
240 new\(hyline NL (LF) \en
241 horizontal tab HT \et
244 carriage return CR \er
248 bit pattern \fIddd\fR\^ \e\fIddd\fR\^
254 consists of the backslash followed by 1, 2, or 3 octal digits
255 which are taken to specify the value of the
257 A special case of this construction is
262 by a digit), which indicates the character
266 If the character following a backslash is not one
267 of those specified, the
268 behavior is undefined.
269 A new-line character is illegal in a character constant.
270 The type of a character constant is \fBint\fR.
275 A floating constant consists of
276 an integer part, a decimal point, a fraction part,
283 and an optionally signed integer exponent.
284 The integer and fraction parts both consist of a sequence
286 Either the integer part or the fraction
287 part (not both) may be missing.
288 Either the decimal point or
293 and the exponent (not both) may be missing.
294 Every floating constant has type \fBdouble\fR.
296 Enumeration Constants
299 Names declared as enumerators
300 (see ``Structure, Union, and Enumeration Declarations'' under
306 A string is a sequence of characters surrounded by
311 ``array of \fBchar\fR'' and storage class
314 and is initialized with
315 the given characters.
319 at the end of each string so that programs
320 which scan the string can
322 In a string, the double quote character
327 in addition, the same escapes as described for character
328 constants may be used.
335 the immediately following new\(hyline are ignored.
336 All strings, even when written identically, are distinct.
338 Hardware Characteristics
340 The following figure summarize
341 certain hardware properties that vary from machine to machine.
347 l | l1 lp8 | l1 lp8 | l1 lp8.
348 DEC PDP\-11 DEC VAX-11 AT&T 3B
349 (ASCII) (ASCII) (ASCII)
352 char 8 bits 8 bits 8bits
358 float range \(+-10 \(+-38 \(+-10 \(+-38 \(+-10 \(+-38
360 double range \(+-10 \(+-38 \(+-10 \(+-38 \(+-10 \(+-308
363 .\" .FG 4 4 1 "DEC PDP-11 HARDWARE CHARACTERISTICS"
369 Syntactic categories are indicated by
374 and literal words and characters
378 Alternative categories are listed on separate lines.
379 An optional terminal or nonterminal symbol is
380 indicated by the subscript ``opt,'' so that
382 { \fIexpression\v'0.5'\s-2opt\s0\v'-0.5'\fR }
385 indicates an optional expression enclosed in braces.
386 The syntax is summarized in ``SYNTAX SUMMARY''.
390 The C language bases the interpretation of an
391 identifier upon two attributes of the identifier \(mi its
398 The storage class determines the location and lifetime
399 of the storage associated with an identifier;
401 the meaning of the values
402 found in the identifier's storage.
406 .\" The original text had borrowed BL, LI and LE from the mm macros.
407 .\" That way madness lies.
408 There are four declarable storage classes:
420 Automatic variables are local to each invocation of
421 a block (see ``Compound Statement or Block'' in
422 ``STATEMENTS'') and are discarded upon exit from the block.
423 Static variables are local to a block but retain
424 their values upon reentry to a block even after control
426 External variables exist and retain their values throughout
427 the execution of the entire program and
428 may be used for communication between
429 functions, even separately compiled functions.
430 Register variables are (if possible) stored in the fast registers
431 of the machine; like automatic
432 variables, they are local to each block and disappear on exit from the block.
436 The C language supports several
439 Objects declared as characters
441 are large enough to store any member of the implementation's
443 If a genuine character from that character set is
444 stored in a \fBchar\fR variable,
445 its value is equivalent to the integer code for that character.
446 Other quantities may be stored into character variables, but
447 the implementation is machine dependent.
448 In particular, \fBchar\fR may be signed or unsigned by default.
450 Up to three sizes of integer, declared
462 Longer integers provide no less storage than shorter ones,
463 but the implementation may make either short integers or long integers,
464 or both, equivalent to plain integers.
465 ``Plain'' integers have the natural size suggested
466 by the host machine architecture.
467 The other sizes are provided to meet special needs.
469 The properties of \fBenum\fR types (see ``Structure, Union, and Enumeration Declarations''
470 under ``DECLARATIONS'')
471 are identical to those of
473 The implementation may use the range of values to
474 determine how to allocate storage.
481 obey the laws of arithmetic modulo
482 2\v'-0.5'\fIn\fR\v'0.5'
483 where \fIn\fR is the number of bits in the representation.
486 unsigned long quantities are not supported.)
488 Single-precision floating point
490 and double precision floating point
492 may be synonymous in some implementations.
494 Because objects of the foregoing types can usefully be interpreted
495 as numbers, they will be referred to as
504 of all sizes whether \fBunsigned\fR or not, and
508 will collectively be called
521 types will collectively be called
532 specifies an empty set of values.
533 It is used as the type returned by functions that
536 Besides the fundamental arithmetic types, there is a
537 conceptually infinite class of derived types constructed
538 from the fundamental types in the following ways:
540 of objects of most types
542 which return objects of a given type
544 to objects of a given type
546 containing a sequence of objects of various types
548 capable of containing any one of several objects of various types.
550 In general these methods
551 of constructing objects can
552 be applied recursively.
560 is a manipulatable region of storage.
565 is an expression referring to an object.
566 An obvious example of an lvalue
567 expression is an identifier.
568 There are operators which yield lvalues:
574 is an expression of pointer type, then
579 expression referring to the object to which
584 The name ``lvalue'' comes from the assignment expression
588 in which the left operand
593 an lvalue expression.
594 The discussion of each operator
595 below indicates whether it expects lvalue operands and whether it
600 A number of operators may, depending on their operands,
601 cause conversion of the value of an operand from one type to another.
602 This part explains the result to be expected from such
604 The conversions demanded by most ordinary operators are summarized under
605 ``Arithmetic Conversions.''
606 The summary will be supplemented
607 as required by the discussion
610 Characters and Integers
612 A character or a short integer may be used wherever an
615 the value is converted to an integer.
616 Conversion of a shorter integer
617 to a longer preserves sign.
618 Whether or not sign-extension occurs for characters is machine
619 dependent, but it is guaranteed that a member of the
620 standard character set is non-negative.
621 Of the machines treated here,
631 variables range in value from
633 The more explicit type
640 forces the values to range from 0 to 255.
642 On machines that treat characters as signed,
643 the characters of the
645 set are all non-negative.
646 However, a character constant specified
647 with an octal escape suffers sign extension
648 and may appear negative;
655 When a longer integer is converted to a shorter
661 it is truncated on the left.
662 Excess bits are simply discarded.
666 All floating arithmetic in C is carried out in double precision.
671 appears in an expression it is lengthened to
675 by zero padding its fraction.
683 for example by an assignment,
694 This result is undefined if it cannot be represented as a float.
695 On the VAX, the compiler can be directed to use single precision for expressions
696 containing only float and integer operands.
698 Floating and Integral
700 Conversions of floating values to integral type
701 are rather machine dependent.
702 In particular, the direction of truncation of negative numbers
704 The result is undefined if
705 it will not fit in the space provided.
707 Conversions of integral values to floating type
709 Some loss of accuracy occurs
710 if the destination lacks sufficient bits.
712 Pointers and Integers
714 An expression of integral type may be added to or subtracted from
715 a pointer; in such a case,
716 the first is converted as
717 specified in the discussion of the addition operator.
718 Two pointers to objects of the same type may be subtracted;
719 in this case, the result is converted to an integer
720 as specified in the discussion of the subtraction
725 Whenever an unsigned integer and a plain integer
726 are combined, the plain integer is converted to unsigned
727 and the result is unsigned.
729 is the least unsigned integer congruent to the signed
730 integer (modulo 2\v'-0.3'\s-2wordsize\s+2\v'0.3').
731 In a 2's complement representation,
732 this conversion is conceptual; and there is no actual change in the
735 When an unsigned \fBshort\fR integer is converted to
737 the value of the result is the same numerically as that of the
739 Thus the conversion amounts to padding with zeros on the left.
741 Arithmetic Conversions
743 A great many operators cause conversions
744 and yield result types in a similar way.
745 This pattern will be called the ``usual arithmetic conversions.''
747 First, any operands of type
757 and any operands of type \fBunsigned char\fR
758 or \fBunsigned short\fR are converted
759 to \fBunsigned int\fR.
761 Then, if either operand is
765 the other is converted to
769 and that is the type of the result.
771 Otherwise, if either operand is \fBunsigned long\fR,
772 the other is converted to \fBunsigned long\fR and that
773 is the type of the result.
775 Otherwise, if either operand is
777 the other is converted to
781 and that is the type of the result.
783 Otherwise, if one operand is \fBlong\fR, and
784 the other is \fBunsigned int\fR, they are both
785 converted to \fBunsigned long\fR and that is
786 the type of the result.
788 Otherwise, if either operand is
792 the other is converted to
796 and that is the type of the result.
798 Otherwise, both operands must be
800 and that is the type of the result.
805 The (nonexistent) value of a
809 object may not be used in any way,
810 and neither explicit nor implicit conversion may be applied.
811 Because a void expression denotes a nonexistent value,
812 such an expression may be used only
813 as an expression statement
814 (see ``Expression Statement'' under ``STATEMENTS'')
815 or as the left operand
816 of a comma expression (see ``Comma Operator'' under ``EXPRESSIONS'').
818 An expression may be converted to
824 For example, this makes explicit the discarding of the value
825 of a function call used as an expression statement.
829 The precedence of expression operators is the same
830 as the order of the major
831 subsections of this section, highest precedence first.
832 Thus, for example, the expressions referred to as the operands of
836 (see ``Additive Operators'')
837 are those expressions defined under ``Primary Expressions'',
838 ``Unary Operators'', and ``Multiplicative Operators''.
839 Within each subpart, the operators have the same
841 Left- or right-associativity is specified
842 in each subsection for the operators
844 The precedence and associativity of all the expression
845 operators are summarized in the
846 grammar of ``SYNTAX SUMMARY''.
848 Otherwise, the order of evaluation of expressions
849 is undefined. In particular, the compiler
850 considers itself free to
851 compute subexpressions in the order it believes
853 even if the subexpressions
854 involve side effects.
855 The order in which subexpression evaluation takes place is unspecified.
856 Expressions involving a commutative and associative
863 may be rearranged arbitrarily even in the presence
865 to force a particular order of evaluation,
866 an explicit temporary must be used.
868 The handling of overflow and divide check
869 in expression evaluation
871 Most existing implementations of C ignore integer overflows;
873 division by 0 and all floating-point exceptions
874 varies between machines and is usually
875 adjustable by a library function.
882 subscripting, and function calls
885 \fIprimary-expression:
890 primary-expression [ expression ]
891 primary-expression ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
892 primary-expression . identifier
893 primary-expression \(mi> identifier\fR
898 expression-list , expression\fR
901 An identifier is a primary expression provided it has been
902 suitably declared as discussed below.
903 Its type is specified by its declaration.
904 If the type of the identifier is ``array of .\|.\|.'',
905 then the value of the identifier expression
907 to the first object in the array; and the
908 type of the expression is
909 ``pointer to .\|.\|.''.
910 Moreover, an array identifier is not an lvalue
912 Likewise, an identifier which is declared
913 ``function returning .\|.\|.'',
914 when used except in the function-name position
915 of a call, is converted to ``pointer to function returning .\|.\|.''.
918 constant is a primary expression.
926 depending on its form.
927 Character constants have type
931 and floating constants have type
936 A string is a primary expression.
937 Its type is originally ``array of
940 the same rule given above for identifiers,
941 this is modified to ``pointer to
944 result is a pointer to the first character
946 (There is an exception in certain initializers;
947 see ``Initialization'' under ``DECLARATIONS.'')
949 A parenthesized expression is a primary expression
950 whose type and value are identical
951 to those of the unadorned expression.
952 The presence of parentheses does
953 not affect whether the expression is an
956 A primary expression followed by an expression in square
957 brackets is a primary expression.
958 The intuitive meaning is that of a subscript.
959 Usually, the primary expression has type ``pointer to .\|.\|.'',
960 the subscript expression is
962 and the type of the result is ``\|.\|.\|.\|''.
968 identical (by definition) to
970 \(**((E1)\(plE2))\fR.
973 this notation are contained in this subpart together
975 in ``Unary Operators'' and ``Additive Operators'' on identifiers,
984 The implications are summarized under ``Arrays, Pointers, and Subscripting''
985 under ``TYPES REVISITED.''
987 A function call is a primary expression followed by parentheses
988 containing a possibly
989 empty, comma-separated list of expressions
990 which constitute the actual arguments to the
992 The primary expression must be of type ``function returning .\|.\|.,''
993 and the result of the function call is of type ``\|.\|.\|.\|''.
995 below, a hitherto unseen identifier followed
996 immediately by a left parenthesis
997 is contextually declared
998 to represent a function returning
1000 thus in the most common case, integer-valued functions
1001 need not be declared.
1003 Any actual arguments of type
1025 Array names are converted to pointers.
1026 No other conversions are performed automatically;
1027 in particular, the compiler does not compare
1028 the types of actual arguments with those of formal
1030 If conversion is needed, use a cast;
1031 see ``Unary Operators'' and ``Type Names'' under
1034 In preparing for the call to a function,
1035 a copy is made of each actual parameter.
1036 Thus, all argument passing in C is strictly by value.
1038 change the values of its formal parameters, but
1039 these changes cannot affect the values
1040 of the actual parameters.
1042 to pass a pointer on the understanding
1043 that the function may change the value
1044 of the object to which the pointer points.
1045 An array name is a pointer expression.
1046 The order of evaluation of arguments is undefined by the language;
1047 take note that the various compilers differ.
1048 Recursive calls to any
1049 function are permitted.
1051 A primary expression followed by a dot followed by an identifier
1053 The first expression must be a structure or a union, and the identifier
1054 must name a member of the structure or union.
1055 The value is the named member of the structure or union, and it is
1056 an lvalue if the first expression is an lvalue.
1058 A primary expression followed by an arrow (built from
1067 followed by an identifier
1069 The first expression must be a pointer to a structure or a union
1070 and the identifier must name a member of that structure or union.
1071 The result is an lvalue referring to the named member
1072 of the structure or union
1073 to which the pointer expression points.
1082 Structures and unions are discussed in
1083 ``Structure, Union, and Enumeration Declarations'' under
1088 Expressions with unary operators
1089 group right to left.
1092 \fIunary-expression:
1102 ( type-name ) expression\fR
1103 sizeof\fI expression\fR
1104 sizeof\fI ( type-name )\fR
1117 the expression must be a pointer, and the result
1118 is an lvalue referring to the object to
1119 which the expression points.
1120 If the type of the expression is ``pointer to .\|.\|.,''
1121 the type of the result is ``\|.\|.\|.\|''.
1123 The result of the unary
1127 operator is a pointer
1128 to the object referred to by the
1130 If the type of the lvalue is ``\|.\|.\|.\|'',
1131 the type of the result is ``pointer to .\|.\|.''.
1139 is the negative of its operand.
1140 The usual arithmetic conversions are performed.
1141 The negative of an unsigned quantity is computed by
1142 subtracting its value from
1143 2\v'-0.5'\fIn\fR\^\v'0.5' where \fIn\fR\^ is the number of bits in
1144 the corresponding signed type.
1153 The result of the logical negation operator
1157 is one if the value of its operand is zero, zero if the value of its
1159 The type of the result is
1163 It is applicable to any arithmetic type
1170 operator yields the one's complement of its operand.
1171 The usual arithmetic conversions are performed.
1172 The type of the operand must be integral.
1174 The object referred to by the lvalue operand of prefix
1179 The value is the new value of the operand
1180 but is not an lvalue.
1187 See the discussions ``Additive Operators'' and ``Assignment
1188 Operators'' for information on conversions.
1190 The lvalue operand of prefix
1206 is applied to an lvalue,
1207 the result is the value of the object referred to by the lvalue.
1208 After the result is noted, the object
1209 is incremented in the same
1210 manner as for the prefix
1215 The type of the result is the same as the type of the lvalue expression.
1221 is applied to an lvalue,
1222 the result is the value of the object referred to by the lvalue.
1223 After the result is noted, the object
1224 is decremented in the manner as for the prefix
1229 The type of the result is the same as the type of the lvalue
1232 An expression preceded by the parenthesized name of a data type
1233 causes conversion of the value of the expression to the named type.
1234 This construction is called a
1238 Type names are described in ``Type Names'' under ``Declarations.''
1244 operator yields the size
1245 in bytes of its operand.
1250 is undefined by the language
1251 except in terms of the value of
1255 However, in all existing implementations,
1256 a byte is the space required to hold a
1258 When applied to an array, the result is the total
1259 number of bytes in the array.
1260 The size is determined from
1262 the objects in the expression.
1263 This expression is semantically an
1268 be used anywhere a constant is required.
1269 Its major use is in communication with routines
1270 like storage allocators and I/O systems.
1277 may also be applied to a parenthesized type name.
1278 In that case it yields the size in bytes of an object
1279 of the indicated type.
1282 \fBsizeof(\fItype\|\fR\^)\fR\^
1283 is taken to be a unit,
1285 \fBsizeof(\fItype\|\fB)-2\fR
1287 \fB(sizeof(\fItype\|\fB))-2\fR.
1289 Multiplicative Operators
1291 The multiplicative operators
1298 group left to right.
1299 The usual arithmetic conversions are performed.
1301 \fImultiplicative expression:
1302 expression \(** expression
1303 expression / expression
1304 expression % expression\fR
1311 operator indicates multiplication.
1316 operator is associative,
1317 and expressions with several multiplications at the same
1318 level may be rearranged by the compiler.
1323 operator indicates division.
1329 operator yields the remainder
1330 from the division of the first expression by the second.
1331 The operands must be integral.
1333 When positive integers are divided, truncation is toward 0;
1334 but the form of truncation is machine-dependent
1335 if either operand is negative.
1336 On all machines covered by this manual,
1337 the remainder has the same sign as the dividend.
1338 It is always true that
1340 (a/b)\(**b\ \(pl a%b
1354 The additive operators
1362 group left to right.
1363 The usual arithmetic conversions are performed.
1364 There are some additional type possibilities for each operator.
1366 \fIadditive-expression:
1367 expression \(pl expression
1368 expression \(mi expression\fR
1375 operator is the sum of the operands.
1376 A pointer to an object in an array and
1377 a value of any integral type
1379 The latter is in all cases converted to
1382 by the length of the object to which the
1384 The result is a pointer
1385 of the same type as the original pointer
1386 which points to another object in the same array,
1387 appropriately offset from the original object.
1393 to an object in an array, the expression
1398 to the next object in the array.
1399 No further type combinations are allowed for pointers.
1405 operator is associative,
1406 and expressions with several additions at the same level may
1407 be rearranged by the compiler.
1413 operator is the difference of the operands.
1414 The usual arithmetic conversions are performed.
1416 a value of any integral type
1417 may be subtracted from a pointer,
1418 and then the same conversions for addition apply.
1420 If two pointers to objects of the same type are subtracted,
1421 the result is converted
1422 (by division by the length of the object)
1427 representing the number of
1429 the pointed-to objects.
1430 This conversion will in general give unexpected
1431 results unless the pointers point
1432 to objects in the same array, since pointers, even
1433 to objects of the same type, do not necessarily differ
1434 by a multiple of the object length.
1446 group left to right.
1447 Both perform the usual arithmetic conversions on their operands,
1448 each of which must be integral.
1449 Then the right operand is converted to
1451 the type of the result is that of the left operand.
1452 The result is undefined if the right operand is negative
1453 or greater than or equal to the length of the object in bits.
1454 On the VAX a negative right operand is interpreted as reversing
1455 the direction of the shift.
1457 \fIshift-expression:
1458 expression << expression
1459 expression >> expression\fR
1470 (interpreted as a bit
1471 pattern) left-shifted
1476 Vacated bits are 0 filled.
1490 The right shift is guaranteed to be logical
1498 otherwise, it may be
1501 Relational Operators
1503 The relational operators group left to right.
1505 \fIrelational-expression:
1506 expression < expression
1507 expression > expression
1508 expression <= expression
1509 expression >= expression\fR
1520 (greater than), \fB<=\fR
1526 (greater than or equal to)
1527 all yield 0 if the specified relation is false
1528 and 1 if it is true.
1529 The type of the result is
1532 The usual arithmetic conversions are performed.
1533 Two pointers may be compared;
1534 the result depends on the relative locations in the address space
1535 of the pointed-to objects.
1536 Pointer comparison is portable only when the pointers point to objects
1542 \fIequality-expression:
1543 expression == expression
1544 expression != expression\fR
1555 (not equal to) operators
1556 are exactly analogous to the relational
1557 operators except for their lower
1571 have the same truth value).
1573 A pointer may be compared to an integer
1575 integer is the constant 0.
1576 A pointer to which 0 has been assigned is guaranteed
1577 not to point to any object
1578 and will appear to be equal to 0.
1579 In conventional usage, such a pointer is considered to be null.
1581 Bitwise \s-1AND\s0 Operator
1585 expression & expression\fR
1592 operator is associative,
1593 and expressions involving
1598 The usual arithmetic conversions are performed.
1599 The result is the bitwise
1601 function of the operands.
1602 The operator applies only to integral
1605 Bitwise Exclusive \s-1OR\s0 Operator
1607 \fIexclusive-or-expression:
1608 expression ^ expression\fR
1615 operator is associative,
1616 and expressions involving
1621 The usual arithmetic conversions are performed;
1623 the bitwise exclusive
1627 The operator applies only to integral
1630 Bitwise Inclusive \s-1OR\s0 Operator
1632 \fIinclusive-or-expression:
1633 expression | expression\fR
1640 operator is associative,
1641 and expressions involving
1646 The usual arithmetic conversions are performed;
1647 the result is the bitwise inclusive
1649 function of its operands.
1650 The operator applies only to integral
1653 Logical \s-1AND\s0 Operator
1655 \fIlogical-and-expression:
1656 expression && expression\fR
1663 operator groups left to right.
1664 It returns 1 if both its operands
1665 evaluate to nonzero, 0 otherwise.
1671 guarantees left to right
1672 evaluation; moreover, the second operand is not evaluated
1673 if the first operand is 0.
1675 The operands need not have the same type, but each
1676 must have one of the fundamental
1677 types or be a pointer.
1678 The result is always
1683 Logical \s-1OR\s0 Operator
1685 \fIlogical-or-expression:
1686 expression || expression\fR
1693 operator groups left to right.
1694 It returns 1 if either of its operands
1695 evaluates to nonzero, 0 otherwise.
1701 guarantees left to right evaluation; moreover,
1702 the second operand is not evaluated
1703 if the value of the first operand is nonzero.
1705 The operands need not have the same type, but each
1707 have one of the fundamental types
1709 The result is always
1714 Conditional Operator
1716 \fIconditional-expression:
1717 expression ? expression : expression\fR
1720 Conditional expressions group right to left.
1721 The first expression is evaluated;
1722 and if it is nonzero, the result is the value of the
1723 second expression, otherwise that of third expression.
1724 If possible, the usual arithmetic conversions are performed
1725 to bring the second and third expressions to a common type.
1726 If both are structures or unions of the same type,
1727 the result has the type of the structure or union.
1728 If both pointers are of the same type,
1729 the result has the common type.
1730 Otherwise, one must be a pointer and the other the constant 0,
1731 and the result has the type of the pointer.
1732 Only one of the second and third
1733 expressions is evaluated.
1735 Assignment Operators
1737 There are a number of assignment operators,
1738 all of which group right to left.
1739 All require an lvalue as their left operand,
1740 and the type of an assignment expression is that
1741 of its left operand.
1742 The value is the value stored in the
1743 left operand after the assignment has taken place.
1744 The two parts of a compound assignment operator are separate
1747 \fIassignment-expression:
1749 lvalue \(pl= expression
1750 lvalue \(mi= expression
1751 lvalue \(**= expression
1752 lvalue /= expression
1753 lvalue %= expression
1754 lvalue >>= expression
1755 lvalue <<= expression
1756 lvalue &= expression
1757 lvalue ^= expression
1758 lvalue |= expression\fR
1761 In the simple assignment with
1763 the value of the expression replaces that of the object
1766 If both operands have arithmetic type,
1767 the right operand is converted to the type of the left
1768 preparatory to the assignment.
1769 Second, both operands may be structures or unions of the same type.
1770 Finally, if the left operand is a pointer, the right operand must in general be a pointer
1772 However, the constant 0 may be assigned to a pointer;
1773 it is guaranteed that this value will produce a null
1774 pointer distinguishable from a pointer to any object.
1776 The behavior of an expression
1778 \fBE1\fR\^ \fIop\fR\^ = \fBE2\fR\^
1780 taking it as equivalent to
1781 \fBE1 = E1 \fIop\fR\^ (\fBE2\fR\^);
1786 is evaluated only once.
1793 the left operand may be a pointer; in which case, the (integral) right
1794 operand is converted as explained
1795 in ``Additive Operators.''
1796 All right operands and all nonpointer left operands must
1797 have arithmetic type.
1801 \fIcomma-expression:
1802 expression , expression\fR
1805 A pair of expressions separated by a comma is evaluated
1806 left to right, and the value of the left expression is
1808 The type and value of the result are the
1809 type and value of the right operand.
1810 This operator groups left to right.
1811 In contexts where comma is given a special meaning,
1812 e.g., in lists of actual arguments
1813 to functions (see ``Primary Expressions'') and lists
1814 of initializers (see ``Initialization'' under ``DECLARATIONS''),
1815 the comma operator as described in this subpart
1816 can only appear in parentheses. For example,
1818 \fBf(a, (t=3, t\(pl2), c)\fR
1821 has three arguments, the second of which has the value 5.
1825 Declarations are used to specify the interpretation
1826 which C gives to each identifier; they do not necessarily
1827 reserve storage associated with the identifier.
1828 Declarations have the form
1831 decl-specifiers declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;\fR
1834 The declarators in the declarator-list
1835 contain the identifiers being declared.
1837 consist of a sequence of type and storage class specifiers.
1840 type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
1841 sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'\fR
1844 The list must be self-consistent in a way described below.
1846 Storage Class Specifiers
1848 The sc-specifiers are:
1862 specifier does not reserve storage
1863 and is called a ``storage class specifier'' only for syntactic convenience.
1864 See ``Typedef'' for more information.
1865 The meanings of the various storage classes were discussed in ``Names.''
1874 declarations also serve as definitions
1875 in that they cause an appropriate amount of storage to be reserved.
1881 there must be an external definition (see ``External Definitions'')
1882 for the given identifiers
1883 somewhere outside the function in which they are declared.
1889 declaration is best thought of as an
1893 declaration, together with a hint to the compiler
1894 that the variables declared will be heavily used.
1896 such declarations in each function are effective.
1897 Moreover, only variables of certain types will be stored in registers;
1905 One other restriction applies to register variables:
1906 the address-of operator
1910 cannot be applied to them.
1911 Smaller, faster programs can be expected if register declarations
1912 are used appropriately,
1913 but future improvements in code generation
1914 may render them unnecessary.
1916 At most, one sc-specifier may be given in a declaration.
1917 If the sc-specifier is missing from a declaration, it
1933 The type-specifiers are
1936 struct-or-union-specifier
1939 basic-type-specifier:
1941 basic-type basic-type-specifiers
1953 At most one of the words \fBlong\fR or \fBshort\fR
1954 may be specified in conjunction with \fBint\fR;
1955 the meaning is the same as if \fBint\fR were not mentioned.
1956 The word \fBlong\fR may be specified in conjunction with
1958 the meaning is the same as \fBdouble\fR.
1959 The word \fBunsigned\fR may be specified alone, or
1960 in conjunction with \fBint\fR or any of its short
1961 or long varieties, or with \fBchar\fR.
1963 Otherwise, at most on type-specifier may be
1964 given in a declaration.
1965 In particular, adjectival use of \fBlong\fR,
1966 \fBshort\fR, or \fBunsigned\fR is not permitted
1967 with \fBtypedef\fR names.
1968 If the type-specifier is missing from a declaration,
1969 it is taken to be \fBint\fR.
1971 Specifiers for structures, unions, and enumerations are discussed in
1972 ``Structure, Union, and Enumeration Declarations.''
1977 names are discussed in ``Typedef.''
1981 The declarator-list appearing in a declaration
1982 is a comma-separated sequence of declarators,
1983 each of which may have an initializer.
1987 init-declarator , declarator-list
1991 declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'\fR
1994 Initializers are discussed in ``Initialization''.
1995 The specifiers in the declaration
1996 indicate the type and storage class of the objects to which the
1998 Declarators have the syntax:
2005 declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]\fR
2009 the same as in expressions.
2011 Meaning of Declarators
2013 Each declarator is taken to be
2014 an assertion that when a construction of
2015 the same form as the declarator appears in an expression,
2016 it yields an object of the indicated
2017 type and storage class.
2019 Each declarator contains exactly one identifier; it is this identifier that
2021 If an unadorned identifier appears
2022 as a declarator, then it has the type
2023 indicated by the specifier heading the declaration.
2025 A declarator in parentheses is identical to the unadorned declarator,
2026 but the binding of complex declarators may be altered by parentheses.
2027 See the examples below.
2029 Now imagine a declaration
2038 is a type-specifier (like
2046 Suppose this declaration makes the identifier have type
2052 where the ``\|.\|.\|.\|'' is empty if
2056 is just a plain identifier
2057 (so that the type of
2074 the type of the contained identifier is
2075 ``\|.\|.\|.\| pointer to
2090 then the contained identifier has the type
2091 ``\|.\|.\|. function returning
2100 \fBD\|[\|\fIconstant-expression\fB\|]\fR
2108 then the contained identifier has type
2109 ``\|.\|.\|.\| array of
2111 In the first case, the constant
2114 whose value is determinable at compile time
2118 and whose value is positive.
2119 (Constant expressions are defined precisely in ``Constant Expressions.'')
2120 When several ``array of'' specifications are adjacent, a multidimensional
2122 the constant expressions which specify the bounds
2123 of the arrays may be missing only for the first member of the sequence.
2124 This elision is useful when the array is external
2125 and the actual definition, which allocates storage,
2127 The first constant expression may also be omitted
2128 when the declarator is followed by initialization.
2129 In this case the size is calculated from the number
2130 of initial elements supplied.
2132 An array may be constructed from one of the basic types, from a pointer,
2133 from a structure or union,
2134 or from another array (to generate a multidimensional array).
2136 Not all the possibilities
2137 allowed by the syntax above are actually
2139 The restrictions are as follows:
2140 functions may not return
2142 although they may return pointers;
2143 there are no arrays of functions although
2144 there may be arrays of pointers to functions.
2145 Likewise, a structure or union may not contain a function;
2146 but it may contain a pointer to a function.
2148 As an example, the declaration
2150 \fBint i, \(**ip, f(), \(**fip(), (\(**pfi)();\fR
2164 returning an integer,
2169 returning a pointer to an integer,
2176 It is especially useful to compare the last two.
2185 The declaration suggests,
2186 and the same construction in an expression
2187 requires, the calling of a function
2191 Using indirection through the (pointer) result
2192 to yield an integer.
2195 the extra parentheses are necessary, as they are also
2196 in an expression, to indicate that indirection through
2197 a pointer to a function yields a function, which is then called;
2198 it returns an integer.
2202 \fBfloat fa[17], \(**afp[17];\fR
2205 declares an array of
2209 numbers and an array of
2217 \fBstatic int x3d[3][5][7];\fR
2220 declares a static 3-dimensional array of integers,
2221 with rank 3\(mu5\(mu7.
2226 is an array of three items;
2227 each item is an array of five arrays;
2228 each of the latter arrays is an array of seven
2230 Any of the expressions
2237 may reasonably appear in an expression.
2238 The first three have type ``array''
2239 and the last has type
2244 Structure and Union Declarations
2247 is an object consisting of a sequence of named members.
2248 Each member may have any type.
2249 A union is an object which may, at a given time, contain any one
2251 Structure and union specifiers have the same form.
2253 \fIstruct-or-union-specifier:
2254 struct-or-union { struct-decl-list }
2255 struct-or-union identifier { struct-decl-list }
2256 struct-or-union identifier
2259 \fIstruct-or-union:\fB
2267 is a sequence of declarations for the members of the structure or union:
2269 \fIstruct-decl-list:
2271 struct-declaration struct-decl-list
2274 \fIstruct-declaration:
2275 type-specifier struct-declarator-list ;
2278 \fIstruct-declarator-list:
2280 struct-declarator , struct-declarator-list\fR
2283 In the usual case, a struct-declarator is just a declarator
2284 for a member of a structure or union.
2285 A structure member may also consist of a specified number of bits.
2286 Such a member is also called a
2291 a non-negative constant expression,
2292 is set off from the field name by a colon.
2294 \fIstruct-declarator:
2296 declarator : constant-expression
2297 : constant-expression\fR
2300 Within a structure, the objects declared
2301 have addresses which increase as the declarations
2302 are read left to right.
2303 Each nonfield member of a structure
2304 begins on an addressing boundary appropriate
2306 therefore, there may
2307 be unnamed holes in a structure.
2308 Field members are packed into machine integers;
2309 they do not straddle words.
2310 A field which does not fit into the space remaining in a word
2311 is put into the next word.
2312 No field may be wider than a word.
2314 Fields are assigned right to left
2319 left to right on the 3B 20.
2321 A struct-declarator with no declarator, only a colon and a width,
2322 indicates an unnamed field useful for padding to conform
2323 to externally-imposed layouts.
2324 As a special case, a field with a width of 0
2325 specifies alignment of the next field at an implementation dependent boundary.
2327 The language does not restrict the types of things that
2328 are declared as fields,
2329 but implementations are not required to support any but
2336 fields may be considered to be unsigned.
2339 fields are not signed and have only integer values;
2342 fields declared with
2346 are treated as containing a sign.
2348 it is strongly recommended that fields be declared as
2352 In all implementations,
2353 there are no arrays of fields,
2354 and the address-of operator
2358 may not be applied to them, so that there are no pointers to
2361 A union may be thought of as a structure all of whose members
2362 begin at offset 0 and whose size is sufficient to contain
2364 At most, one of the members can be stored in a union
2367 A structure or union specifier of the second form, that is, one of
2369 \fBstruct \fIidentifier { struct-decl-list \fR}
2370 \fBunion \fIidentifier { struct-decl-list \fR}
2373 declares the identifier to be the
2378 of the structure specified by the list.
2379 A subsequent declaration may then use
2380 the third form of specifier, one of
2382 \fBstruct \fIidentifier\fR
2383 \fBunion \fIidentifier\fR
2386 Structure tags allow definition of self-referential
2387 structures. Structure tags also
2388 permit the long part of the declaration to be
2389 given once and used several times.
2390 It is illegal to declare a structure or union
2391 which contains an instance of
2392 itself, but a structure or union may contain a pointer to an instance of itself.
2394 The third form of a structure or union specifier may be
2395 used prior to a declaration which gives the complete specification
2396 of the structure or union in situations in which the size
2397 of the structure or union is unnecessary.
2398 The size is unnecessary in two situations: when a
2399 pointer to a structure or union is being declared and
2400 when a \fBtypedef\fR name is declared to be a synonym
2401 for a structure or union.
2402 This, for example, allows the declaration of a pair
2403 of structures which contain pointers to each other.
2405 The names of members and tags do not conflict
2406 with each other or with ordinary variables.
2407 A particular name may not be used twice
2408 in the same structure,
2409 but the same name may be used in several different structures in the same scope.
2411 A simple but important example of a structure declaration is
2412 the following binary tree structure:
2418 struct tnode \(**left;
2419 struct tnode \(**right;
2423 which contains an array of 20 characters, an integer, and two pointers
2424 to similar structures.
2425 Once this declaration has been given, the
2428 \fBstruct tnode s, \(**sp;\fR
2435 to be a structure of the given sort
2440 to be a pointer to a structure
2442 With these declarations, the expression
2451 field of the structure to which
2460 refers to the left subtree pointer
2465 \fBs.right->tword[0]\fR
2468 refers to the first character of the
2472 member of the right subtree of
2478 Enumeration Declarations
2480 Enumeration variables and constants have integral type.
2482 \fIenum-specifier:\fB
2483 enum\fI { enum-list \fR}\fB
2484 enum \fIidentifier { enum-list \fR}\fB
2489 enum-list , enumerator
2493 identifier = constant-expression\fR
2496 The identifiers in an enum-list are declared as constants
2497 and may appear wherever constants are required.
2498 If no enumerators with
2502 appear, then the values of the
2503 corresponding constants begin at 0 and increase by 1 as the declaration is
2504 read from left to right.
2509 gives the associated identifier the value
2510 indicated; subsequent identifiers continue the progression from the assigned value.
2512 The names of enumerators in the same scope must all be distinct
2513 from each other and from those of ordinary variables.
2515 The role of the identifier in the enum-specifier
2516 is entirely analogous to that of the structure tag
2517 in a struct-specifier; it names a particular enumeration.
2520 \fBenum color { chartreuse, burgundy, claret=20, winedark };
2522 enum color *cp, col;
2527 if (*cp == burgundy) ...\fR
2534 the enumeration-tag of a type describing various colors,
2539 as a pointer to an object of that type,
2544 as an object of that type.
2545 The possible values are drawn from the set {0,1,20,21}.
2549 A declarator may specify an initial value for the
2550 identifier being declared.
2551 The initializer is preceded by
2556 consists of an expression or a list of values nested in braces.
2560 = { initializer-list }
2561 = { initializer-list , }
2564 \fIinitializer-list:
2566 initializer-list , initializer-list\fR
2567 { \fIinitializer-list \fR}
2568 { \fIinitializer-list\fR , }
2571 All the expressions in an initializer
2572 for a static or external variable must be constant
2573 expressions, which are described in ``CONSTANT EXPRESSIONS'',
2574 or expressions which reduce to the address of a previously
2575 declared variable, possibly offset by a constant expression.
2576 Automatic or register variables may be initialized by arbitrary
2577 expressions involving constants and previously declared variables and functions.
2579 Static and external variables that are not initialized are
2580 guaranteed to start off as zero.
2581 Automatic and register variables that are not initialized
2582 are guaranteed to start off as garbage.
2584 When an initializer applies to a
2588 (a pointer or an object of arithmetic type),
2589 it consists of a single expression, perhaps in braces.
2590 The initial value of the object is taken from
2591 the expression; the same conversions as for assignment are performed.
2593 When the declared variable is an
2597 (a structure or array),
2598 the initializer consists of a brace-enclosed, comma-separated list of
2599 initializers for the members of the aggregate
2600 written in increasing subscript or member order.
2601 If the aggregate contains subaggregates, this rule
2602 applies recursively to the members of the aggregate.
2603 If there are fewer initializers in the list than there are members of the aggregate,
2604 then the aggregate is padded with zeros.
2605 It is not permitted to initialize unions or automatic aggregates.
2607 Braces may in some cases be omitted.
2608 If the initializer begins with a left brace, then
2609 the succeeding comma-separated list of initializers initializes
2610 the members of the aggregate;
2611 it is erroneous for there to be more initializers than members.
2612 If, however, the initializer does not begin with a left brace,
2613 then only enough elements from the list are taken to account
2614 for the members of the aggregate; any remaining members
2615 are left to initialize the next member of the aggregate of which
2616 the current aggregate is a part.
2618 A final abbreviation allows a
2622 array to be initialized by a string.
2623 In this case successive characters of the string
2624 initialize the members of the array.
2628 \fBint x[] = { 1, 3, 5 };\fR
2631 declares and initializes
2635 as a one-dimensional array which has three members, since no size was specified
2636 and there are three initializers.
2646 is a completely-bracketed initialization:
2647 1, 3, and 5 initialize the first row of
2657 Likewise, the next two lines initialize
2665 The initializer ends early and therefore
2669 is initialized with 0.
2670 Precisely, the same effect could have been achieved by
2674 1, 3, 5, 2, 4, 6, 3, 5, 7
2682 begins with a left brace but that for
2687 therefore, three elements from the list are used.
2688 Likewise, the next three are taken successively for
2700 { 1 }, { 2 }, { 3 }, { 4 }
2704 initializes the first column of
2708 (regarded as a two-dimensional array)
2709 and leaves the rest 0.
2713 \fBchar msg[] = "Syntax error on line %s\en";\fR
2716 shows a character array whose members are initialized
2721 In two contexts (to specify type conversions explicitly
2723 and as an argument of
2725 it is desired to supply the name of a data type.
2726 This is accomplished using a ``type name'', which in essence
2727 is a declaration for an object of that type which omits the name of
2731 type-specifier abstract-declarator
2734 \fIabstract-declarator:
2736 ( abstract-declarator )
2737 \(** abstract-declarator
2738 abstract-declarator ()
2739 abstract-declarator\fR\^ [ \fIconstant-expression\v'0.5'\s-2opt\s0\v'-0.5' \fR\^]
2745 \fI( abstract-declarator \fR)
2750 is required to be nonempty.
2751 Under this restriction,
2752 it is possible to identify uniquely the location in the abstract-declarator
2753 where the identifier would appear if the construction were a declarator
2755 The named type is then the same as the type of the
2756 hypothetical identifier.
2768 name respectively the types ``integer,'' ``pointer to integer,''
2769 ``array of three pointers to integers,''
2770 ``pointer to an array of three integers,''
2771 ``function returning pointer to integer,''
2772 ``pointer to function returning an integer,''
2773 and ``array of three pointers to functions returning an integer.''
2777 Declarations whose ``storage class'' is
2781 do not define storage but instead
2782 define identifiers which can be used later
2783 as if they were type keywords naming fundamental
2790 Within the scope of a declaration involving
2792 each identifier appearing as part of
2793 any declarator therein becomes syntactically
2794 equivalent to the type keyword
2796 associated with the identifier
2797 in the way described in ``Meaning of Declarators.''
2801 \fBtypedef int MILES, \(**KLICKSP;
2802 typedef struct { double re, im; } complex;\fR
2808 extern KLICKSP metricp;
2809 complex z, \(**zp;\fR
2812 are all legal declarations; the type of
2822 is ``pointer to \fBint\fR, ''
2827 is the specified structure.
2832 is a pointer to such a structure.
2838 does not introduce brand-new types, only synonyms for
2839 types which could be specified in another way.
2841 in the example above
2845 is considered to have exactly the same type as
2854 Except as indicated, statements are executed in sequence.
2856 Expression Statement
2858 Most statements are expression statements, which have
2864 Usually expression statements are assignments or function
2867 Compound Statement or Block
2869 So that several statements can be used where one is expected,
2870 the compound statement (also, and equivalently, called ``block'') is provided:
2872 \fIcompound-statement:
2873 { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
2876 \fIdeclaration-list:
2878 declaration declaration-list
2883 statement statement-list\fR
2886 If any of the identifiers
2887 in the declaration-list were previously declared,
2888 the outer declaration is pushed down for the duration of the block,
2889 after which it resumes its force.
2891 Any initializations of
2899 variables are performed each time the block is entered at the top.
2900 It is currently possible
2901 (but a bad practice)
2902 to transfer into a block;
2903 in that case the initializations are not performed.
2908 variables are performed only once when the program
2914 declarations do not reserve storage
2915 so initialization is not permitted.
2917 Conditional Statement
2919 The two forms of the conditional statement are
2921 \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2922 \fBif\fR\^ ( \fIexpression\fR\^ ) \fIstatement \fBelse \fIstatement\fR\^
2925 In both cases, the expression is evaluated;
2926 and if it is nonzero, the first substatement
2928 In the second case, the second substatement is executed
2929 if the expression is 0.
2930 The ``else'' ambiguity is resolved by connecting
2935 with the last encountered
2947 statement has the form
2949 \fBwhile\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
2952 The substatement is executed repeatedly
2953 so long as the value of the
2954 expression remains nonzero.
2955 The test takes place before each execution of the
2964 statement has the form
2966 \fBdo \fIstatement \fBwhile\fR\^ ( \fIexpression \fR\^) ;
2969 The substatement is executed repeatedly until
2970 the value of the expression becomes 0.
2971 The test takes place after each execution of the
2980 statement has the form:
2982 \fBfor\fI ( exp-1\v'0.5'\s-2opt\s0\v'-0.5' ; exp-2\v'0.5'\s-2opt\s0\v'-0.5' ; exp-3\v'0.5'\s-2opt\s0\v'-0.5' ) statement\fR
2986 Except for the behavior of \fBcontinue\fR,
2987 this statement is equivalent to
2990 \fBwhile\fR\^ ( \fIexp-2\ ) \fR\^
2997 Thus the first expression specifies initialization
2998 for the loop; the second specifies
2999 a test, made before each iteration, such
3000 that the loop is exited when the expression becomes
3002 The third expression often specifies an incrementing
3003 that is performed after each iteration.
3005 Any or all of the expressions may be dropped.
3015 clause equivalent to
3017 other missing expressions are simply
3018 dropped from the expansion above.
3026 statement causes control to be transferred
3027 to one of several statements depending on
3028 the value of an expression.
3031 \fBswitch\fR\^ ( \fIexpression\fR\^ ) \fIstatement\fR\^
3034 The usual arithmetic conversion is performed on the
3035 expression, but the result must be
3039 The statement is typically compound.
3040 Any statement within the statement
3041 may be labeled with one or more case prefixes
3044 \fBcase \fIconstant-expression \fR:
3053 No two of the case constants in the same switch
3054 may have the same value.
3055 Constant expressions are precisely defined in ``CONSTANT EXPRESSIONS.''
3057 There may also be at most one statement prefix of the
3067 statement is executed, its expression
3068 is evaluated and compared with each case constant.
3069 If one of the case constants is
3070 equal to the value of the expression,
3071 control is passed to the statement
3072 following the matched case prefix.
3073 If no case constant matches the expression
3077 passes to the prefixed
3079 If no case matches and if there is no
3082 none of the statements in the
3093 do not alter the flow of control,
3094 which continues unimpeded across such prefixes.
3095 To exit from a switch, see
3096 ``Break Statement.''
3098 Usually, the statement that is the subject of a switch is compound.
3099 Declarations may appear at the head of this
3102 initializations of automatic or register variables
3112 causes termination of the smallest enclosing
3119 control passes to the
3120 statement following the terminated statement.
3129 causes control to pass to the loop-continuation portion of the
3135 statement; that is to the end of the loop.
3136 More precisely, in each of the statements
3139 lw(2i) lw(2i) lw(2i).
3140 \fBwhile (\|.\|.\|.\|) { do { for (\|.\|.\|.\|) {\fR
3141 \fIstatement ; statement ; statement ;\fR
3142 \fBcontin: ; contin: ; contin: ;
3143 } } while (...); }\fR
3159 is a null statement, see ``Null Statement''.)
3163 A function returns to its caller by means of
3168 statement which has one of the
3172 return \fIexpression \fR;
3175 In the first case, the returned value is undefined.
3176 In the second case, the value of the expression
3177 is returned to the caller
3179 If required, the expression is converted,
3180 as if by assignment, to the type of
3181 function in which it appears.
3182 Flowing off the end of a function is
3183 equivalent to a return with no returned value.
3184 The expression may be parenthesized.
3188 Control may be transferred unconditionally by means of
3191 \fBgoto \fIidentifier \fR;
3194 The identifier must be a label
3195 (see ``Labeled Statement'')
3196 located in the current function.
3200 Any statement may be preceded by
3201 label prefixes of the form
3206 which serve to declare the identifier
3208 The only use of a label is as a target of a
3212 The scope of a label is the current function,
3213 excluding any subblocks in which the same identifier has been redeclared.
3214 See ``SCOPE RULES.''
3218 The null statement has the form
3223 A null statement is useful to carry a label just before the
3227 of a compound statement or to supply a null
3228 body to a looping statement such as
3233 External Definitions
3235 A C program consists of a sequence of external definitions.
3236 An external definition declares an identifier to
3246 The type-specifier (see ``Type Specifiers'' in
3247 ``DECLARATIONS'') may also be empty, in which
3248 case the type is taken to be
3252 The scope of external definitions persists to the end
3253 of the file in which they are declared just as the effect
3254 of declarations persists to the end of a block.
3255 The syntax of external definitions is the same
3256 as that of all declarations except that
3257 only at this level may the code for functions be given.
3259 External Function Definitions
3261 Function definitions have the form
3263 \fIfunction-definition:
3264 decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body\fR
3267 The only sc-specifiers
3269 among the decl-specifiers
3276 see ``Scope of Externals'' in
3277 ``SCOPE RULES'' for the distinction between them.
3278 A function declarator is similar to a declarator
3279 for a ``function returning .\|.\|.\|'' except that
3280 it lists the formal parameters of
3281 the function being defined.
3283 \fIfunction-declarator:
3284 declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
3289 identifier , parameter-list\fR
3296 declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement\fR
3299 The identifiers in the parameter list, and only those identifiers,
3300 may be declared in the declaration list.
3301 Any identifiers whose type is not given are taken to be
3305 The only storage class which may be specified is
3307 if it is specified, the corresponding actual parameter
3308 will be copied, if possible, into a register
3309 at the outset of the function.
3311 A simple example of a complete function definition is
3318 m = (a > b) ? a : b;
3319 return((m > c) ? m : c);
3327 is the type-specifier;
3331 is the function-declarator;
3335 is the declaration-list for
3340 block giving the code for the statement.
3342 The C program converts all
3349 so formal parameters declared
3353 have their declaration adjusted to read
3357 All \fBchar\fR and \fBshort\fR formal parameter
3358 declarations are similarly adjusted
3360 Also, since a reference to an array in any context
3361 (in particular as an actual parameter)
3363 a pointer to the first element of the array,
3364 declarations of formal parameters declared ``array of .\|.\|.\|''
3365 are adjusted to read ``pointer to .\|.\|.\|.''
3367 External Data Definitions
3369 An external data definition has the form
3375 The storage class of such data may be
3379 (which is the default)
3393 A C program need not all
3394 be compiled at the same time. The source text of the
3396 may be kept in several files, and precompiled
3397 routines may be loaded from
3399 Communication among the functions of a program
3400 may be carried out both through explicit calls
3401 and through manipulation of external data.
3403 Therefore, there are two kinds of scopes to consider:
3404 first, what may be called the
3407 of an identifier, which is essentially the
3408 region of a program during which it may
3409 be used without drawing ``undefined identifier''
3411 and second, the scope
3412 associated with external identifiers,
3413 which is characterized by the rule
3414 that references to the same external
3415 identifier are references to the same object.
3419 The lexical scope of identifiers declared in external definitions
3420 persists from the definition through
3421 the end of the source file
3422 in which they appear.
3423 The lexical scope of identifiers which are formal parameters
3424 persists through the function with which they are
3426 The lexical scope of identifiers declared at the head of a block
3427 persists until the end of the block.
3428 The lexical scope of labels is the whole of the
3429 function in which they appear.
3431 In all cases, however,
3432 if an identifier is explicitly declared at the head of a block,
3433 including the block constituting a function,
3434 any declaration of that identifier outside the block
3435 is suspended until the end of the block.
3437 Remember also (see ``Structure, Union, and Enumeration Declarations'' in
3438 ``DECLARATIONS'') that tags, identifiers associated with
3440 and identities associated with structure and union members
3441 form three disjoint classes
3442 which do not conflict.
3443 Members and tags follow the same scope rules
3444 as other identifiers.
3445 The \fBenum\fR constants are in the same
3446 class as ordinary variables and follow the same scope rules.
3451 names are in the same class as ordinary identifiers.
3452 They may be redeclared in inner blocks, but an explicit
3453 type must be given in the inner declaration:
3455 \fBtypedef float distance;
3467 must be present in the second declaration,
3468 or it would be taken to be
3469 a declaration with no declarators and type
3476 If a function refers to an identifier declared to be
3478 then somewhere among the files or libraries
3479 constituting the complete program
3480 there must be at least one external definition
3482 All functions in a given program which refer to the same
3483 external identifier refer to the same object,
3484 so care must be taken that the type and size
3485 specified in the definition
3486 are compatible with those specified
3487 by each function which references the data.
3489 It is illegal to explicitly initialize any external
3490 identifier more than once in the set of files and libraries
3491 comprising a multi-file program.
3492 It is legal to have more than one data definition
3493 for any external non-function identifier;
3494 explicit use of \fBextern\fR does not
3495 change the meaning of an external declaration.
3497 In restricted environments, the use of the \fBextern\fR
3498 storage class takes on an additional meaning.
3499 In these environments, the explicit appearance of the
3500 \fBextern\fR keyword in external data declarations of
3501 identities without initialization indicates that
3502 the storage for the identifiers is allocated elsewhere,
3503 either in this file or another file.
3504 It is required that there be exactly one definition of
3505 each external identifier (without \fBextern\fR)
3506 in the set of files and libraries
3507 comprising a mult-file program.
3509 Identifiers declared
3513 at the top level in external definitions
3514 are not visible in other files.
3515 Functions may be declared
3521 Compiler Control Lines
3523 The C compiler contains a preprocessor capable
3524 of macro substitution, conditional compilation,
3525 and inclusion of named files.
3526 Lines beginning with
3531 with this preprocessor.
3532 There may be any number of blanks and horizontal tabs
3533 between the \fB#\fR and the directive.
3534 These lines have syntax independent of the rest of the language;
3535 they may appear anywhere and have effect which lasts (independent of
3536 scope) until the end of the source program file.
3541 A compiler-control line of the form
3543 \fB#define \fIidentifier token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3546 causes the preprocessor to replace subsequent instances
3547 of the identifier with the given string of tokens.
3548 Semicolons in or at the end of the token-string are part of that string.
3551 \fB#define \fIidentifier(identifier, ... )token-string\v'0.5'\s-2opt\s0\v'-0.5'\fR
3554 where there is no space between the first identifier
3557 is a macro definition with arguments.
3558 There may be zero or more formal parameters.
3559 Subsequent instances of the first identifier followed
3562 a sequence of tokens delimited by commas, and a
3565 by the token string in the definition.
3566 Each occurrence of an identifier mentioned in the formal parameter list
3567 of the definition is replaced by the corresponding token string from the call.
3568 The actual arguments in the call are token strings separated by commas;
3569 however, commas in quoted strings or protected by
3570 parentheses do not separate arguments.
3571 The number of formal and actual parameters must be the same.
3572 Strings and character constants in the token-string are scanned
3573 for formal parameters, but
3574 strings and character constants in the rest of the program are
3575 not scanned for defined identifiers
3578 In both forms the replacement string is rescanned for more
3579 defined identifiers.
3581 a long definition may be continued on another line
3586 at the end of the line to be continued.
3588 This facility is most valuable for definition of ``manifest constants,''
3591 \fB#define TABSIZE 100
3593 int table\|[\|TABSIZE\|]\|;\fR
3596 A control line of the form
3598 \fB#undef \fIidentifier\fR
3602 identifier's preprocessor definition (if any) to be forgotten.
3604 If a \fB#define\fRd identifier is the subject of a subsequent
3605 \fB#define\fR with no intervening \fB#undef\fR, then
3606 the two token-strings are compared textually.
3607 If the two token-strings are not identical
3608 (all white space is considered as equivalent), then
3609 the identifier is considered to be redefined.
3614 A compiler control line of
3617 \fB#include\fI "filename\|\fR"
3620 causes the replacement of that
3621 line by the entire contents of the file
3625 The named file is searched for first in the directory
3626 of the file containing the \fB#include\fR,
3627 and then in a sequence of specified or standard places.
3628 Alternatively, a control line of the form
3630 \fB#include\fI <filename\|\fR>
3633 searches only the specified or standard places
3634 and not the directory of the \fB#include\fR.
3635 (How the places are specified is not part of the language.)
3641 Conditional Compilation
3643 A compiler control line of the form
3645 \fB#if \fIrestricted-constant-expression\fR
3648 checks whether the restricted-constant expression evaluates to nonzero.
3649 (Constant expressions are discussed in ``CONSTANT EXPRESSIONS'';
3650 the following additional restrictions apply here:
3651 the constant expression may not contain
3655 casts, or an enumeration constant.)
3657 A restricted constant expression may also contain the
3658 additional unary expression
3660 \fBdefined \fIidentifier\fR
3664 \fBdefined( \fIidentifier )\fR
3666 which evaluates to one if the identifier is currently
3667 defined in the preprocessor and zero if it is not.
3669 All currently defined identifiers in restricted-constant-expressions
3670 are replaced by their token-strings (except those identifiers
3671 modified by \fBdefined\fR) just as in normal text.
3672 The restricted constant expression will be evaluated only
3673 after all expressions have finished.
3674 During this evaluation, all undefined (to the procedure)
3675 identifiers evaluate to zero.
3677 A control line of the form
3679 \fB#ifdef \fIidentifier\fR
3682 checks whether the identifier is currently defined
3683 in the preprocessor; i.e., whether it has been the
3689 It is equivalent to \fB#ifdef(\fIidentifier\fB)\fR.
3690 A control line of the form
3692 \fB#ifndef \fIidentifier\fR
3695 checks whether the identifier is currently undefined
3696 in the preprocessor.
3699 \fB#if !\|defined(\fIidentifier\fB)\fR.
3702 All three forms are followed by an arbitrary number of lines,
3703 possibly containing a control line
3708 and then by a control line
3713 If the checked condition is true,
3724 If the checked condition is false, then any lines between
3737 These constructions may be nested.
3742 For the benefit of other preprocessors which generate C programs,
3745 \fB#line \fIconstant "filename\fR"
3748 causes the compiler to believe, for purposes of error
3750 that the line number of the next source line is given by the constant and the current input
3751 file is named by "\fIfilename\fR".
3752 If "\fIfilename\fR" is absent, the remembered file name does not change.
3755 Implicit Declarations
3757 It is not always necessary to specify
3758 both the storage class and the type
3759 of identifiers in a declaration.
3760 The storage class is supplied by
3761 the context in external definitions
3762 and in declarations of formal parameters
3763 and structure members.
3764 In a declaration inside a function,
3765 if a storage class but no type
3766 is given, the identifier is assumed
3769 if a type but no storage class is indicated,
3770 the identifier is assumed to
3775 An exception to the latter rule is made for
3780 functions do not exist.
3781 If the type of an identifier is ``function returning .\|.\|.\|,''
3782 it is implicitly declared to be
3787 In an expression, an identifier
3792 and not already declared
3794 declared to be ``function returning
3801 This part summarizes the operations
3802 which can be performed on objects of certain types.
3805 Structures and Unions
3807 Structures and unions may be assigned, passed as arguments to functions,
3808 and returned by functions.
3809 Other plausible operators, such as equality comparison
3810 and structure casts,
3811 are not implemented.
3814 to a structure or union member, the
3816 of the \fB->\fR or the \fB.\fR
3817 must specify a member of the aggregate
3818 named or pointed to by the expression
3820 In general, a member of a union may not be inspected
3821 unless the value of the union has been assigned using that same member.
3822 However, one special guarantee is made by the language in order
3823 to simplify the use of unions:
3824 if a union contains several structures that share a common initial sequence
3825 and if the union currently contains one of these structures,
3826 it is permitted to inspect the common initial part of any of
3827 the contained structures.
3828 For example, the following is a legal fragment:
3849 u.nf.floatnode = 3.14;
3851 if (u.n.type == FLOAT)
3852 ... sin(u.nf.floatnode) ...\fR
3859 There are only two things that
3860 can be done with a function \fBm\fR,
3861 call it or take its address.
3862 If the name of a function appears in an
3863 expression not in the function-name position of a call,
3864 a pointer to the function is generated.
3865 Thus, to pass one function to another, one
3874 Then the definition of
3894 explicitly in the calling routine since its appearance
3905 Arrays, Pointers, and Subscripting
3907 Every time an identifier of array type appears
3908 in an expression, it is converted into a pointer
3909 to the first member of the array.
3910 Because of this conversion, arrays are not
3912 By definition, the subscript operator
3923 \(**((E1)\(plE2))\fR.
3925 Because of the conversion rules
3950 despite its asymmetric
3951 appearance, subscripting is a commutative operation.
3953 A consistent rule is followed in the case of
3954 multidimensional arrays.
3968 appearing in an expression is converted to
3969 a pointer to an (n-1)-dimensional
3976 operator, either explicitly
3977 or implicitly as a result of subscripting,
3978 is applied to this pointer,
3979 the result is the pointed-to (n-1)-dimensional array,
3980 which itself is immediately converted into a pointer.
3982 For example, consider
3991 is a 3\(mu5 array of integers.
3996 appears in an expression, it is converted
3997 to a pointer to (the first of three) 5-membered arrays of integers.
4000 which is equivalent to
4005 is first converted to a pointer as described;
4010 is converted to the type of
4012 which involves multiplying
4017 length the object to which the pointer points,
4018 namely 5-integer objects.
4019 The results are added and indirection applied to
4020 yield an array (of five integers) which in turn is converted to
4021 a pointer to the first of the integers.
4022 If there is another subscript, the same argument applies
4023 again; this time the result is an integer.
4025 Arrays in C are stored
4026 row-wise (last subscript varies fastest)
4027 and the first subscript in the declaration helps determine
4028 the amount of storage consumed by an array.
4029 Arrays play no other part in subscript calculations.
4032 Explicit Pointer Conversions
4034 Certain conversions involving pointers are permitted
4035 but have implementation-dependent aspects.
4036 They are all specified by means of an explicit type-conversion
4037 operator, see ``Unary Operators'' under``EXPRESSIONS'' and
4038 ``Type Names''under ``DECLARATIONS.''
4040 A pointer may be converted to any of the integral types large
4050 is required is machine dependent.
4051 The mapping function is also machine dependent but is intended
4052 to be unsurprising to those who know the addressing structure
4054 Details for some particular machines are given below.
4056 An object of integral type may be explicitly converted to a pointer.
4057 The mapping always carries an integer converted from a pointer back to the same pointer
4058 but is otherwise machine dependent.
4060 A pointer to one type may be converted to a pointer to another type.
4061 The resulting pointer may cause addressing exceptions
4063 the subject pointer does not refer to an object suitably aligned in storage.
4064 It is guaranteed that
4065 a pointer to an object of a given size may be converted to a pointer to an object
4067 and back again without change.
4070 a storage-allocation routine
4071 might accept a size (in bytes)
4072 of an object to allocate, and return a
4077 it might be used in this way.
4079 \fBextern char \(**malloc();
4082 dp = (double \(**) malloc(sizeof(double));
4083 \(**dp = 22.0 / 7.0;\fR
4090 must ensure (in a machine-dependent way)
4091 that its return value is suitable for conversion to a pointer to
4097 of the function is portable.
4100 representation on the
4102 corresponds to a 16-bit integer and
4107 have no alignment requirements; everything else must have an even address.
4111 pointers are 32 bits long and measure bytes.
4112 Elementary objects are aligned on a boundary equal to their
4117 quantities need be aligned only on even 4-byte boundaries.
4118 Aggregates are aligned on the strictest boundary required by
4119 any of their constituents.
4121 The 3B 20 computer has 24-bit pointers placed into 32-bit quantities.
4123 aligned on 4-byte boundaries. \fBShort\fRs are aligned in all cases on
4124 2-byte boundaries. Arrays of characters, all structures,
4125 \fBint\fR\^s, \fBlong\fR\^s, \fBfloat\fR\^s, and \fBdouble\fR\^s are aligned on 4-byte
4126 boundaries; but structure members may be packed tighter.
4129 CONSTANT EXPRESSIONS
4131 In several places C requires expressions that evaluate to
4135 as array bounds, and in initializers.
4136 In the first two cases, the expression can
4137 involve only integer constants, character constants,
4138 casts to integral types,
4139 enumeration constants,
4144 expressions, possibly
4145 connected by the binary operators
4148 \(pl \(mi \(** / % & | ^ << >> == != < > <= >= && ||
4151 or by the unary operators
4156 or by the ternary operator
4161 Parentheses can be used for grouping
4162 but not for function calls.
4164 More latitude is permitted for initializers;
4165 besides constant expressions as discussed above,
4166 one can also use floating constants
4167 and arbitrary casts and
4168 can also apply the unary
4172 operator to external or static objects
4173 and to external or static arrays subscripted
4174 with a constant expression.
4180 be applied implicitly
4181 by appearance of unsubscripted arrays and functions.
4182 The basic rule is that initializers must
4183 evaluate either to a constant or to the address
4184 of a previously declared external or static object plus or minus a constant.
4187 Portability Considerations
4189 Certain parts of C are inherently machine dependent.
4190 The following list of potential trouble spots
4191 is not meant to be all-inclusive
4192 but to point out the main ones.
4194 Purely hardware issues like
4195 word size and the properties of floating point arithmetic and integer division
4196 have proven in practice to be not much of a problem.
4197 Other facets of the hardware are reflected
4198 in differing implementations.
4200 particularly sign extension
4201 (converting a negative character into a negative integer)
4202 and the order in which bytes are placed in a word,
4203 are nuisances that must be carefully watched.
4204 Most of the others are only minor problems.
4210 variables that can actually be placed in registers
4211 varies from machine to machine
4212 as does the set of valid types.
4213 Nonetheless, the compilers all do things properly for their own machine;
4218 declarations are ignored.
4220 Some difficulties arise only when
4221 dubious coding practices are used.
4222 It is exceedingly unwise to write programs
4224 on any of these properties.
4226 The order of evaluation of function arguments
4227 is not specified by the language.
4228 The order in which side effects take place
4229 is also unspecified.
4231 Since character constants are really objects of type
4233 multicharacter character constants may be permitted.
4234 The specific implementation
4235 is very machine dependent
4236 because the order in which characters
4237 are assigned to a word
4238 varies from one machine to another.
4240 Fields are assigned to words and characters to integers right to left
4242 and left to right on other machines.
4243 These differences are invisible to isolated programs
4244 that do not indulge in type punning (e.g.,
4253 pointer and inspecting the pointed-to storage)
4254 but must be accounted for when conforming to externally-imposed
4260 This summary of C syntax is intended more for aiding comprehension
4261 than as an exact statement of the language.
4267 The basic expressions are:
4281 \fBsizeof\fI expression
4282 \fBsizeof (\fItype-name\fB)\fI
4283 ( type-name ) expression
4284 expression binop expression
4285 expression ? expression : expression
4286 lvalue asgnop expression
4287 expression , expression
4295 primary ( expression-list\v'0.5'\s-2opt\s0\v'-0.5' )
4296 primary [ expression ]
4297 primary . identifier
4298 primary \(mi identifier
4303 primary [ expression ]
4305 primary \(mi identifier
4311 The primary-expression operators
4317 have highest priority and group left to right.
4320 \(** & \(mi ! \s+2~\s0 \(pl\(pl \(mi\(mi \fBsizeof\fI ( type-name \fR)
4323 have priority below the primary operators
4324 but higher than any binary operator
4325 and group right to left.
4327 group left to right; they have priority
4343 The conditional operator groups right to left.
4345 Assignment operators all have the same
4346 priority and all group right to left.
4349 = \(pl= \(mi= \(**= /= %= >>= <<= &= ^= |=
4352 The comma operator has the lowest priority and groups left to right.
4359 decl-specifiers init-declarator-list\v'0.5'\s-2opt\s0\v'-0.5' ;
4363 type-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4364 sc-specifier decl-specifiers\v'0.5'\s-2opt\s0\v'-0.5'
4376 struct-or-union-specifier
4379 basic-type-specifier:
4381 basic-type basic-type-specifiers
4393 \fIenum-specifier:\fB
4394 enum\fI { enum-list }\fB
4395 enum \fIidentifier { enum-list }\fB
4401 enum-list , enumerator
4406 identifier = constant-expression
4409 \fIinit-declarator-list:
4411 init-declarator , init-declarator-list
4415 declarator initializer\v'0.5'\s-2opt\s0\v'-0.5'
4423 declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4426 \fIstruct-or-union-specifier:\fB
4427 struct\fI { struct-decl-list }\fB
4428 struct \fIidentifier { struct-decl-list }\fB
4429 struct \fIidentifier\fB
4430 union { \fIstruct-decl-list }\fB
4431 union \fIidentifier { struct-decl-list }\fB
4435 \fIstruct-decl-list:
4437 struct-declaration struct-decl-list
4440 \fIstruct-declaration:
4441 type-specifier struct-declarator-list ;
4444 \fIstruct-declarator-list:
4446 struct-declarator , struct-declarator-list
4449 \fIstruct-declarator:
4451 declarator : constant-expression
4452 : constant-expression
4457 = { initializer-list }
4458 = { initializer-list , }
4461 \fIinitializer-list:
4463 initializer-list , initializer-list
4464 { initializer-list }
4465 { initializer-list , }
4469 type-specifier abstract-declarator
4472 \fIabstract-declarator:
4474 ( abstract-declarator )
4475 \(** abstract-declarator
4476 abstract-declarator ()
4477 abstract-declarator [ constant-expression\v'0.5'\s-2opt\s0\v'-0.5' ]
4488 \fIcompound-statement:
4489 { declaration-list\v'0.5'\s-2opt\s0\v'-0.5' statement-list\v'0.5'\s-2opt\s0\v'-0.5' }
4492 \fIdeclaration-list:
4494 declaration declaration-list
4499 statement statement-list
4505 \fBif\fI ( expression ) statement
4506 \fBif\fI ( expression ) statement \fBelse\fI statement
4507 \fBwhile\fI ( expression ) statement
4508 \fBdo\fI statement \fBwhile\fI ( expression ) ;
4509 \fBfor\fI (exp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fB;\fIexp\v'0.3'\s-2opt\s0\v'-0.3'\fI) statement
4510 \fBswitch\fI ( expression ) statement
4511 \fBcase\fI constant-expression : statement
4512 \fBdefault\fI : statement
4516 return\fI expression ;
4517 \fBgoto\fI identifier ;
4518 identifier : statement
4523 External definitions
4528 external-definition program
4531 \fIexternal-definition:
4536 \fIfunction-definition:
4537 decl-specifier\v'0.5'\s-2opt\s0\v'-0.5' function-declarator function-body
4540 \fIfunction-declarator:
4541 declarator ( parameter-list\v'0.5'\s-2opt\s0\v'-0.5' )
4546 identifier , parameter-list
4550 declaration-list\v'0.5'\s-2opt\s0\v'-0.5' compound-statement
4554 \fBextern\fI declaration\fB ;
4555 \fBstatic\fI declaration\fB ;
4560 \fB#define\fI identifier token-string\v'0.3'\s-2opt\s0\v'-0.3'\fB
4561 \fB#define\fI identifier\fB(\fIidentifier\fB,...)\fItoken-string\v'0.5'\s-2opt\s0\v'-0.5'\fB
4562 \fB#undef\fI identifier\fB
4563 \fB#include "\fIfilename\|\fB"
4564 #include <\fIfilename\|\fB>
4565 \fB#if\fI restricted-constant-expression\fB
4566 \fB#ifdef\fI identifier\fB
4567 \fB#ifndef\fI identifier\fB
4570 \fB#line\fI constant \fB"\fIfilename\|\fB"